upgradeable-proxy
하는 일
이 플레이북은 업그레이드 가능한 컨트랙트 설계에서 흔한 약점을 다룹니다. 프록시 패턴을 쓰는 감사자와 개발자를 위한 스킬입니다.
사용하는 경우
- ✓컨트랙트가 프록시 뒤에 배포되어 관리자가 업그레이드할 수 있을 때.
- ✓구현 컨트랙트가 프록시가 아닌 다른 사람에 의해 초기화될 수 있을 때.
- ✓업그레이드 후 저장소 레이아웃을 확인해야 하는 경우.
스킬 링크
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/upgradeable-proxy/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“토큰 컨트랙트에 업그레이드 가능한 프록시를 쓰고 있습니다. 설정과 업그레이드 권한을 확인해 주시겠어요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 구현이 직접 설정되지 않도록 잠겨 있는지, 저장소 슬롯이 충돌할 수 있는지, 누가 업그레이드를 승인할 수 있는지 확인합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Upgradeable Proxy Playbook
Proxies separate storage (proxy) from logic (implementation). The
proxy delegatecalls into the implementation, executing logic in the
proxy's storage context. Three common patterns:
- Transparent Proxy (OZ TransparentUpgradeableProxy)
- UUPS (OZ UUPSUpgradeable, OZ 4.1+)
- Diamond / EIP-2535 (multi-facet, much more complex)
Each has distinct bug classes.
Audit checklist
1. Uninitialized implementation
Implementations should be initialized at deployment to prevent third-party initialization:
// Vulnerable — anyone can call initialize() on the implementation
// directly (not via proxy) and become its owner
contract VulnImpl {
function initialize(address owner_) external {
owner = owner_;
}
}
// Safe — disable initializers on impl deployment
contract SafeImpl is Initializable {
constructor() { _disableInitializers(); }
function initialize(address owner_) external initializer {
owner = owner_;
}
}
Attack: attacker calls initialize on the impl contract → becomes
"owner" of the impl. While this doesn't immediately drain the proxy,
it CAN matter if _authorizeUpgrade reads impl-side state, or if
selfdestruct is exposed and impl auth is on owner. Past incident:
Parity multisig 2017 — $280M frozen.
# Find unprotected impl
grep -rn 'initialize\|_disableInitializers' src/
2. Storage slot collisions
Proxy and impl share storage. New impl versions must lay storage identical to old:
// V1
contract LogicV1 {
address public owner; // slot 0
uint256 public total; // slot 1
}
// V2 — BUG: inserted new var at top
contract LogicV2 {
uint256 public newVar; // slot 0 — overwrites owner!
address public owner; // slot 1
uint256 public total; // slot 2
}
After upgrade, owner is read from where total was; arbitrary value.
Check:
- New vars only appended at the end
- Inheritance order unchanged
- OZ
__gapreserved slots used in upgradeable libs
# OZ provides a tool
slither-check-upgradeability V1.sol V2.sol --proxy-name MyProxy
3. Function selector collisions (Transparent Proxy specifically)
Transparent proxy: if caller is admin → proxy admin functions; else → delegatecall to impl. If impl has function with selector matching a proxy admin selector → admin sees impl, user sees impl, admin can never call admin functions. Or worse, ABI-trickery.
Common collisions:
upgradeTo(address): selector0x3659cfe6— what if impl defines atransferOwnership(address)that hashes to the same selector?
Slither auto-detects:
slither --print human-summary src/ | grep -i selector
4. _authorizeUpgrade empty / wrong
UUPS pattern: implementation contains the upgrade authorization. Default
OZ _authorizeUpgrade is internal virtual {} — empty body that
reverts, but the function itself is empty. Devs override it:
// VULNERABLE — empty body, no actual auth check
function _authorizeUpgrade(address newImplementation) internal override {}
// SAFE
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
Attack: anyone calls upgradeTo(maliciousImpl) → all storage now
controlled by malicious code.
grep -rn '_authorizeUpgrade' src/
5. delegatecall to attacker-controlled address
If the impl contains a function that performs delegatecall(arbitrary_address),
attackers can pass their own contract → execute arbitrary code in
proxy storage context, including selfdestruct.
grep -rn 'delegatecall' src/
6. Constructor logic in upgradeable contracts
Constructors run on the implementation only — proxy storage is
untouched. Storage initialization must happen in initialize(). If
critical state is set in the constructor, the proxy will read zero
values:
// VULNERABLE — admin set in constructor, proxy reads 0x0
contract Impl {
address public admin;
constructor() { admin = msg.sender; } // sets admin on IMPL only
}
7. Diamond / EIP-2535 specific bugs
- Facet selector collisions — two facets define same selector
- Diamond storage position not unique → cross-facet storage corruption
diamondCutaccess control — must be gated, often forgotten
# Inspect facet selectors
slither . --print function-summary | grep -A1 'Facet'
8. Storage gap for inheritance
OZ upgradeable libs use `
자주 묻는 질문
주요 프록시 패턴은 무엇인가요?
플레이북은 Transparent Proxy, UUPS, Diamond 패턴을 나열합니다.
구현을 잠가야 하는 이유는 무엇인가요?
외부 누군가 구현을 초기화해 설정을 장악하지 못하도록 하기 위해서입니다.
저장소 충돌이란 무엇인가요?
프록시와 로직 컨트랙트가 같은 저장소 위치를 써서 데이터가 덮어써지는 경우입니다.
상세 정보
작성자의 원본 설명
Proxy upgrade patterns and their bugs — uninitialized implementation, storage slot collisions, selector clashes, unprotected upgrade auth.
인기도
- GitHub 스타
- 6.5k
- 순위
- #14014
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
detector-overview
6.5k에이전트가 스캐너가 표시한 코드를 읽고, 표시된 곳 중 어디가 실제 보안 버그이고 어디가 오탐인지 판단하도록 돕습니다.
exploiter-overview
6.5k에이전트가 확인된 여러 보안 약점을 하나의 테스트 체인으로 묶고, 그 체인이 어디까지 닿을 수 있는지 확인하도록 돕습니다.
llm-redteam-overview
6.5k에이전트가 프롬프트 인젝션부터 모델 악용까지 15개 전술 그룹 중 테스트에 맞는 AI 레드팀 가이드를 찾도록 돕습니다.
aatmf-t01-prompt-injection
6.5k숨겨진 지시가 AI 시스템을 덮어쓰려 하는 프롬프트 인젝션을 설명해, 보안 테스터가 이를 점검할 수 있게 합니다.