A few weeks ago I wrote about deployed state: whether the code at an address is the code you read. This article is about the next layer down. Assume the bytecode matches the audited commit exactly. The protocol still is not the commit.
Two lending markets can run byte-identical code, one with a 75% loan-to-value ratio and an oracle for the right asset, the other with 99% and an oracle for a different asset. They are different protocols. An audit of the code says very little about which one is live. That depends on values that were chosen after the audit, by a deploy script, a multisig transaction or a governance proposal, and those are reviewed far less carefully than the code, when they are reviewed at all.
None of these are in src/:
Constructor arguments, appended to the creation code in the deployment transaction.
Initializer calldata, for anything behind a proxy, passed with the proxy deployment or in a separate transaction.
Deploy scripts, such as
script/*.s.sol, hardhat-deploy folders or a team's own tooling, which sometimes sit in the audited repository but are rarely in scope.Post-deploy setters:
setOracle,setCap,grantRole,transferOwnership, run once by the deployer and never looked at again.Multisig and governance transactions, including the upgrade payloads that change all of the above later.
An auditor who only reads src/ has reviewed the function that checks a value, but not the value itself.
Both are well documented, and I will keep to what is widely reported.
A value that disabled a check. In August 2022 the Nomad bridge lost roughly $190 million. A routine upgrade initialized the contract's trusted root to zero. An unproven message also maps to the zero root, so after the upgrade the contract treated every message as already proven. Once the first exploit transaction was public, many other addresses copied it and swapped in their own recipient. The verification logic did what it was written to do. The value it was initialized with turned it off.
A contract nobody initialized. In November 2017, Parity multisig wallets delegated their logic to a shared library contract that had been deployed but never initialized. An account called its initialization function, became its owner, and self-destructed it. Every wallet that depended on the library was frozen, with more than 500,000 ETH in them. The wallets' code had not changed. One missing call on one deployment broke them all.
Neither incident needed a bug in the sense of a wrong line of logic. Both needed a wrong, or missing, value on chain.
Surface | Where it is set | What goes wrong |
|---|---|---|
Initializer values | initializer calldata | a zero or sentinel value disables a check |
Uninitialized implementation | the implementation contract itself | anyone initializes it and becomes its owner |
Front-runnable initializer | proxy deployed and initialized in two transactions | someone else initializes it first |
Role holders |
| the deployer's hot key keeps admin; a role goes to the wrong address |
Dependency addresses | constructor arguments or setters | an oracle for the wrong asset or chain, wrong decimals, a feed nobody updates |
Numeric parameters | setters and governance | caps, ratios and fees outside the range the audit assumed; a timelock delay of zero |
Upgrade payloads |
| a storage layout collision, a reinitializer that resets state, a changed init value |
Most audit reports state their assumptions about these somewhere: "the owner is a trusted multisig", "the oracle is assumed correct", "parameters are set within safe bounds". Every one of those sentences is a check nobody has run yet.
All of this can be checked from the chain with cast, at one pinned block so every read describes the same moment.
B=<pinned block>; R=<rpc url>
# 1. Which implementation is live, and who can replace it (EIP-1967 slots)
cast storage $PROXY 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc --block $B -r $R
cast storage $PROXY 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103 --block $B -r $R
# 2. Is the implementation itself initialized? (OpenZeppelin 5.x Initializable, ERC-7201 slot)
cast storage $IMPL 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00 --block $B -r $R
# expect 0xffffffffffffffff in the low bytes if the constructor called _disableInitializers()
# 3. Who holds power
cast call $C "owner()(address)" --block $B -r $R
cast code $OWNER --block $B -r $R # 0x means an EOA, not a multisig
cast call $OWNER "getThreshold()(uint256)" --block $B -r $R
cast logs --from-block $DEPLOY_BLOCK --to-block $B --address $C \
"RoleGranted(bytes32,address,address)" -r $R # then subtract RoleRevoked
cast call $TIMELOCK "getMinDelay()(uint256)" --block $B -r $R
# 4. What it depends on
cast call $FEED "description()(string)" --block $B -r $R
cast call $FEED "decimals()(uint8)" --block $B -r $R
cast call $TOKEN "decimals()(uint8)" --block $B -r $R
# 5. How it got that way
cast tx $DEPLOY_TX input -r $R # constructor arguments are at the end
cast run $UPGRADE_TX -r $R # replay an upgrade with a full trace
Three notes on those reads.
The Initializable slot depends on the version. In OpenZeppelin 5.x, the flag lives at the namespaced slot above. In 4.x, _initialized is an ordinary state variable in the contract's own layout, so find it with forge inspect <Contract> storageLayout before reading it. Either way, an implementation contract whose flag reads zero is one anyone can initialize.
Role enumeration needs both events. RoleGranted without RoleRevoked overstates who holds a role. hasRole at the pinned block is the final word for any single address you are unsure about.
An EOA owner is a finding about trust, not necessarily a bug. It changes what "the owner is trusted" means in the audit report, and it is worth writing down next to that sentence.
An upgrade that changes the order or the types of state variables corrupts existing storage silently, and the new code reads old values as something else. The check is two commands and a diff:
git checkout <deployed-commit> && forge inspect Vault storageLayout > before.txt
git checkout <upgrade-commit> && forge inspect Vault storageLayout > after.txt
diff before.txt after.txt
Anything other than new variables appended at the end, or a correctly used storage gap, needs an explanation. Tooling such as the OpenZeppelin upgrades plugins automates this check. The manual version takes a minute and needs no plugin.
Then go one step further and replay the upgrade itself on a fork, at the block before it, with the real calldata. If you have an invariant suite, point it at the forked post-upgrade state rather than at a fresh new Vault() in setUp(). A suite that has only ever run against freshly deployed contracts has never seen the parameters the protocol actually runs with.
The single most useful artifact I know of for this is one page, written before deployment and diffed against the chain afterwards:
PARAMETER SHEET [one row per value]
name expected source on chain @B
owner 0x...Safe (3 of 5) script/Deploy.s.sol:41 [ ]
oracle ETH/USD feed, 8 dec governance proposal 12 [ ]
ltv 7500 (bps) risk memo, section 2 [ ]
timelockDelay 172800 (48h) script/Deploy.s.sol:57 [ ]
impl init flag disabled constructor [ ]
For an audit team, asking for this sheet in the scope letter turns "parameters are assumed to be set safely" from an assumption into a review item. For a protocol team, it makes the post-deployment check something anyone can repeat.
Parameter findings sit awkwardly in most bounty programs. Many exclude anything that needs an admin to make a mistake, and "the owner set a bad value" usually falls under that. Read the program rules before you spend time on it.
The parameter findings that do get past those rules are the ones an outsider can trigger without anyone else acting: an implementation contract anyone can initialize, an initializer anyone can front-run, or a live value that already disables a check anyone can reach. Those are not about trusting the admin. The admin has already acted, and the result is on chain at a block you can name.
The reads are EVM-shaped. The same questions apply on other chains, but the slots, calls and tools differ.
A matching parameter sheet is not safety. It shows the values are the ones somebody intended. Whether those values are safe is a risk question the sheet only makes visible.
The incidents are summaries. Both have detailed public post-mortems, and the details matter more than my two paragraphs.
Some parameters are not readable. Off-chain keepers, signer sets held in a service, and values behind access-controlled getters need the team's cooperation, or a different method.
Take the last protocol you audited or hunted. Find the sentence in the report that starts "we assume". Then run the reads above at today's block and check whether the assumption is true.
It takes about half an hour. It is the half hour that covers the part of the protocol nobody else looked at.
The audit covered the code. The attacker gets the deployment. Read the deployment.

