Overview
Proxy and upgrade patterns are ubiquitous in modern DeFi — UUPS, Transparent Proxy, Beacon Proxy, and Diamond (EIP-2535) are all in production. Each introduces a unique class of vulnerabilities around delegatecall, storage layout collisions, and unprotected upgrade functions. ChainProof currently has no coverage for these patterns.
Vulnerability Patterns to Detect
1. Storage Slot Collision in Proxy Contracts
// Proxy.sol
contract Proxy {
address public implementation; // slot 0
// Implementation.sol
contract Implementation {
address public owner; // also slot 0 — COLLISION
}
When the proxy delegatecalls into the implementation, writes to owner overwrite implementation.
2. Unprotected upgradeTo / _authorizeUpgrade
function _authorizeUpgrade(address newImpl) internal override {} // empty body
Any address can upgrade the contract to arbitrary logic.
3. Uninitialized Implementation Contract
The implementation contract of a proxy can be self-destructed if its initialize() function is callable by anyone and sets ownership to the caller — a known attack vector (Parity hack).
4. delegatecall to User-Controlled Address
function execute(address target, bytes calldata data) external {
target.delegatecall(data); // attacker can supply a malicious target
}
5. Function Selector Clashing (Diamond Proxy)
Two facets registering the same 4-byte function selector, causing one to shadow the other.
Proposed Rule: CP-118
Detection approach:
- Identify proxy patterns via storage variable naming heuristic (
_implementation, implementation, _IMPLEMENTATION_SLOT)
- Detect
delegatecall to non-constant address (parameter or state variable that can change)
- Check
_authorizeUpgrade and upgradeTo functions for access control guards
- Detect storage layout conflicts by enumerating slot 0 in proxy vs implementation
- Flag uninitialized implementation contracts (initialize callable without state guard)
Acceptance Criteria
References
Overview
Proxy and upgrade patterns are ubiquitous in modern DeFi — UUPS, Transparent Proxy, Beacon Proxy, and Diamond (EIP-2535) are all in production. Each introduces a unique class of vulnerabilities around
delegatecall, storage layout collisions, and unprotected upgrade functions. ChainProof currently has no coverage for these patterns.Vulnerability Patterns to Detect
1. Storage Slot Collision in Proxy Contracts
When the proxy
delegatecalls into the implementation, writes toowneroverwriteimplementation.2. Unprotected
upgradeTo/_authorizeUpgradeAny address can upgrade the contract to arbitrary logic.
3. Uninitialized Implementation Contract
The implementation contract of a proxy can be self-destructed if its
initialize()function is callable by anyone and sets ownership to the caller — a known attack vector (Parity hack).4.
delegatecallto User-Controlled Address5. Function Selector Clashing (Diamond Proxy)
Two facets registering the same 4-byte function selector, causing one to shadow the other.
Proposed Rule: CP-118
Detection approach:
_implementation,implementation,_IMPLEMENTATION_SLOT)delegatecallto non-constant address (parameter or state variable that can change)_authorizeUpgradeandupgradeTofunctions for access control guardsAcceptance Criteria
packages/core/src/rules/cp118-proxy-delegate.tsexamples/contracts/proxy/References