behavioral-state-analy…
Token-efficient smart contract security auditing via Behavioral State Analysis (BSA). Scopes analysis to contract type, runs only…
Detects vulnerabilities in upgradeable proxy smart contracts including storage layout collisions, uninitialized implementations, function selector clashing, delegatecall context issues, and upgrade path safety. Covers Transparent Proxy, UUPS (EIP-1822), Beacon, Diamond
$ npx -y skills add quillai-network/quillshield_skills --skill proxy-upgrade-safety --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/proxy-upgrade-safetyContext preview
The summary Claude sees to decide when to auto-load this skill.
Detects vulnerabilities in upgradeable proxy smart contracts including storage layout collisions, uninitialized implementations, function selector clashing, delegatecall context issues, and upgrade path safety. Covers Transparent Proxy, UUPS (EIP-1822), Beacon, Diamond
name: proxy-upgrade-safety description: Detects vulnerabilities in upgradeable proxy smart contracts including storage layout collisions, uninitialized implementations, function selector clashing, delegatecall context issues, and upgrade path safety. Covers Transparent Proxy, UUPS (EIP-1822), Beacon, Diamond (EIP-2535), and Minimal Proxy (EIP-1167) patterns. Use when auditing upgradeable contracts, reviewing implementation upgrades, analyzing delegatecall architectures, or verifying proxy pattern compliance.
Detect vulnerabilities specific to **upgradeable proxy architectures** — the most widely deployed contract pattern on Ethereum (54.2% of contracts). Proxy bugs cause storage corruption, unauthorized upgrades, and complete contract takeover.
When Proxy calls Implementation via `delegatecall`:
┌─────────────────────┐ delegatecall ┌─────────────────────┐ │ PROXY │ ──────────────────→ │ IMPLEMENTATION │ │ │ │ │ │ Storage: │ Implementation code │ Code only: │ │ slot 0: admin │ executes in proxy's │ No persistent │ │ slot 1: impl addr │ storage context │ storage │ │ slot 2: user data │ │ │ │ slot 3: user data │ │ │ └─────────────────────┘ └─────────────────────┘
**Key Rule:** The implementation's code reads/writes the PROXY's storage slots. If storage layouts don't match, data corruption occurs.
**Between Proxy and Implementation:**
// Proxy contract
contract Proxy {
address public admin; // slot 0
address public implementation; // slot 1
fallback() external payable {
delegatecall(implementation);
}
}
// Implementation contract
contract ImplementationV1 {
uint256 public totalSupply; // slot 0 — COLLIDES with admin!
mapping(address => uint256) public balances; // slot 1 — COLLIDES with implementation!
}**Detection:** Compare storage slot assignments between proxy and implementation. Any overlap = CRITICAL vulnerability.
**Between Implementation Versions:**
// V1
contract ImplementationV1 {
uint256 public totalSupply; // slot 0
address public owner; // slot 1
mapping(address => uint256) balances; // slot 2
}
// V2 — DANGEROUS: inserted variable before existing ones
contract ImplementationV2 {
bool public paused; // slot 0 — COLLIDES with totalSupply!
uint256 public totalSupply; // slot 1 — COLLIDES with owner!
address public owner; // slot 2 — COLLIDES with balances!
mapping(address => uint256) balances; // slot 3
}**Safe V2:**
contract ImplementationV2 {
uint256 public totalSupply; // slot 0 — same
address public owner; // slot 1 — same
mapping(address => uint256) balances; // slot 2 — same
bool public paused; // slot 3 — NEW, appended at end
}Proxy pattern uses `initialize()` instead of `constructor()`. If the implementation contract itself is not initialized, an attacker can call `initialize()` directly on it.
contract ImplementationV1 is Initializable {
address public owner;
function initialize(address _owner) external initializer {
owner = _owner;
}
function selfDestruct() external {
require(msg.sender == owner);
selfdestruct(payable(msg.sender));
}
}**Attack:**
1. Implementation deployed but initialize() not called on impl itself 2. Attacker calls implementation.initialize(attacker_address) 3. Attacker is now owner of the IMPLEMENTATION contract 4. Attacker calls selfDestruct() on implementation 5. Proxy now delegatecalls to destroyed contract 6. ALL proxy calls return empty data — contract bricked
**Detection:**
For each implementation contract: 1. Does it have initialize() or any initializer function? 2. Was initialize() called on the implementation address (not just the proxy)? 3. Does the constructor call _disableInitializers()? 4. If no → UNINITIALIZED IMPLEMENTATION vulnerability
Solidity function selectors are only 4 bytes. Collisions between proxy admin functions and implementation functions cause unexpected behavior.
// Proxy has admin function function upgrade(address newImpl) external; // selector: 0x0900f010 // Implementation has user function with SAME selector function collide(uint256 amount) external; // selector: 0x0900f010 // When user calls collide(), proxy intercepts it as upgrade()!
**Transparent Proxy Mitigation:** Admin can only call admin functions; users can only call implementation functions. But this must be correctly implemented.
**Detection:**
For each function in the proxy:
selector_proxy = keccak256(signature)[:4]
For each function in the implementation:
selector_impl = keccak256(signature)[:4]
If selector_proxy == selector_impl:
→ FUNCTION SELECTOR CLASH**UUPS Pattern
AI agent skills for advanced smart contract security auditing. These skills teach AI agents (Claude, Cursor) the QuillShield methodology for detecting vulnerabilities that traditional static analysis tools miss.
Token-efficient smart contract security auditing via Behavioral State Analysis (BSA). Scopes analysis to contract type, runs only…
Blue-team release-gate analysis for smart contract deployment and upgrade readiness. Classifies repositories, checks…
Detects Denial of Service and griefing vulnerabilities in smart contracts. Covers unbounded loop DoS, block gas limit exhaustion,…
Detects unsafe external call patterns and token integration vulnerabilities in smart contracts. Covers unchecked…
Detects input validation failures and arithmetic vulnerabilities in smart contracts. Covers missing zero-address and zero-amount…
Detects price oracle manipulation and flash loan attack vectors in DeFi smart contracts. Classifies oracle trust models…