.claude/skills/solidity-guard/skills/storage-analyzer/SKILL.md
Analyzes storage layout, proxy patterns, and state variable security in Solidity contracts. Detects storage collisions, uninitialized pointers, and upgrade risks. Use when auditing proxy/upgradeable contracts.
npx skillsauth add alt-research/solidityguard storage-analyzerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Detect storage-related vulnerabilities in Solidity contracts, especially proxy/upgradeable patterns. Storage issues are among the most severe and hardest to detect.
// VULNERABLE (Solidity < 0.5.0)
function processData() external {
Data data; // Uninitialized — points to storage slot 0!
data.value = msg.value; // Overwrites slot 0 (owner!)
}
// Implementation V1
contract V1 {
address public owner; // slot 0
uint256 public value; // slot 1
}
// Implementation V2 — WRONG: changed layout
contract V2 {
uint256 public value; // slot 0 — COLLISION with owner!
address public owner; // slot 1
uint256 public newField; // slot 2
}
// CORRECT V2 — append only
contract V2 {
address public owner; // slot 0 (unchanged)
uint256 public value; // slot 1 (unchanged)
uint256 public newField; // slot 2 (new, appended)
}
contract Parent {
uint256 public value;
}
contract Child is Parent {
uint256 public value; // Shadows Parent.value!
}
// VULNERABLE — relies on exact balance
require(address(this).balance == expectedBalance);
// Attacker can force-send ETH via selfdestruct
Changing variable order, types, or removing variables between upgrade versions.
// VULNERABLE — shared transient slot across delegatecall
contract Base {
function _lock() internal {
assembly { tstore(0x00, 1) } // Slot 0x00
}
}
contract Extension {
function _check() internal {
assembly { tstore(0x00, 1) } // COLLISION via delegatecall!
}
}
// SECURE — namespaced transient storage slots
bytes32 constant LOCK_SLOT = keccak256("myprotocol.base.lock");
assembly { tstore(LOCK_SLOT, 1) }
Transient storage is automatically cleared at end of transaction, but within a transaction values persist across internal calls. Relying on "clean" transient state within a tx can be dangerous.
Delegatecall shares transient storage context with caller, allowing callee to read/write caller's transient slots.
// VULNERABLE — callee reads caller's transient lock state
contract Caller {
function execute(address target) external {
assembly { tstore(0x01, 42) } // Set transient state
target.delegatecall(abi.encodeWithSignature("run()"));
// Target can read/write slot 0x01!
}
}
rg "tstore|tload|TSTORE|TLOAD" contracts/ # Direct assembly
rg "ReentrancyGuardTransient" contracts/ # OZ transient guard
rg "transient" contracts/ # Solidity 0.8.28+ transient keyword
rg "ERC1967|TransparentUpgradeableProxy|UUPSUpgradeable|Beacon" contracts/
rg "delegatecall|fallback\(\)|_implementation\(\)" contracts/
rg "__gap|uint256\[.*\].*gap" contracts/
rg "initializer|_disableInitializers|initialized" contracts/
# Using Foundry
forge inspect ContractV1 storage-layout --pretty
forge inspect ContractV2 storage-layout --pretty
# Compare outputs for mismatches
contract V1 is Initializable {
address public owner;
uint256 public value;
uint256[48] private __gap; // Reserve slots for future
}
// Modern approach — prevents collisions
library StorageLib {
bytes32 constant STORAGE_SLOT = keccak256("myprotocol.storage.main");
struct Storage {
address owner;
uint256 value;
}
function getStorage() internal pure returns (Storage storage s) {
bytes32 slot = STORAGE_SLOT;
assembly { s.slot := slot }
}
}
tools
Advanced Solidity/EVM smart contract security auditor with 104 vulnerability patterns, multi-tool integration, and professional report generation.
development
Comprehensive Solidity contract security scanner detecting 104 vulnerability patterns across reentrancy, access control, arithmetic, DeFi, proxy, and token categories. Integrates Slither, Aderyn, and Mythril with manual analysis.
development
Validates Solidity implementation against specification documents. Extracts behavior from docs (README, specs, NatSpec) and verifies code matches documented intent. Uses Trail of Bits methodology for divergence detection.
testing
Generates professional security audit reports from findings. Creates OpenZeppelin/Trail of Bits style reports with executive summary, methodology, severity-classified findings, and remediation recommendations.