What a Protocol v2 Audit Reveals About Solidity Review Work
A recent OpenZeppelin audit offers a good lens on recurring Solidity risks. Focus your reviews on privilege boundaries, initialization, validation, accounting edges, and dependency drift.
Smart contract audits matter because most protocol failures are still boring. Access control drifts. Upgrade paths stay open longer than expected. Arithmetic around fees or shares rounds the wrong way under stress. The cost shows up later, when integrations and users assume the code matches the docs.
OpenZeppelin’s Brickken Protocol v2 audit is a useful prompt here. The report notes issues around role handling, initialization, and validation logic. Those details are common across many Solidity systems. If you build or review contracts, the value is in the pattern, not in the name of the protocol.
You do not need a full audit budget to read these patterns well. You need a repeatable review path. Start with privileges. Move to initialization. Then inspect value accounting and external interactions. Most serious defects cluster there.
Inspect privilege boundaries first
Many contract systems fail at the edges of authority. A role exists for an operational reason, then gains one extra function, then one more. After a few iterations, one signer or one admin contract controls too much.
Your first pass should produce a privilege map.
- List every privileged role.
- List every function each role reaches.
- Mark which functions move assets, mint claims, pause flows, upgrade logic, or change dependencies.
- Mark whether each action is immediate, delayed, or subject to multi-signature approval.
In upgradeable systems, inspect three layers, not one.
- The application roles inside the implementation.
- The proxy admin or upgrade authority.
- Any off-chain process or signer set that controls those roles.
A common mistake is reviewing onlyOwner and AccessControl checks while ignoring proxy administration. If a proxy admin sits in a hot wallet, your role design inside the logic contract does not save you.
Read for role composition too. A contract often looks safe in isolation, but two permissions combine into a dangerous path. For example:
- Role A updates a trusted registry.
- Role B pulls configuration from that registry.
- Together, they redirect funds or approvals.
When you write tests, encode these compositions directly. Do not stop at “unauthorized caller reverts.” Add tests for cross-role escalation paths, stale admins, and emergency roles used outside emergencies.
Treat initialization as part of the attack surface
Upgradeable contracts push critical setup into initializer functions. That design solves one problem and creates another. If initialization order is wrong, or a contract stays initializable after deployment, an attacker or operator error can take control of the system.
This class of issue keeps recurring because initialization is often treated like deployment plumbing instead of business logic.
Check these points every time:
- Is the implementation contract itself disabled with
_disableInitializers()? - Does the proxy call the correct initializer exactly once?
- Are parent initializers called in the right order?
- Are versioned reinitializers gated to true upgrade needs?
- Do initializer parameters set any trusted external addresses, fee recipients, or role bearers?
Then inspect invariants immediately after setup. Ask what must be true before any public state-changing call runs. Examples:
- Total fee basis points stay within a hard cap.
- Treasury address is non-zero and changeable only by a constrained path.
- Asset decimals or share precision are stored once and never inferred loosely later.
- Upgrade authority is transferred away from the deployer account.
Where teams go wrong is simple. They test the happy deployment path on a fresh local chain. They do not test redeploys, partial deployments, failed initializer calls, or migration from a prior storage layout.
For Solidity projects using OpenZeppelin upgrade patterns, store a deployment checklist in the repository and make CI enforce parts of it. Static tests help here. A script should fail if an implementation exposes an initializer in a state where it should be locked.
Verify input validation where state meaning changes
Validation bugs are less dramatic than reentrancy, but they break systems in quieter ways. A wrong bounds check in a config setter or issuance function creates invalid state, and invalid state tends to spread through every downstream calculation.
Focus on functions where inputs change the meaning of balances, entitlements, or permissions.
High-risk examples include:
- Fee setters.
- Share-to-asset conversion parameters.
- Whitelist or registry updates.
- Oracle or price source references.
- Document hashes and metadata anchors.
- Batch operations with array inputs.
Your review should separate syntactic validation from semantic validation.
Syntactic validation asks:
- Is the address non-zero?
- Do arrays have equal length?
- Does the enum value fit?
Semantic validation asks:
- Does the new fee preserve protocol limits?
- Does this asset already exist under another identifier?
- Does this change break assumptions in another module?
- Does this timestamp window make settlement impossible or unfair?
Many teams do the first set and miss the second.
This is where property tests pay off. Write invariants around system meaning, not around single functions. For example:
assert(totalFeesBps <= MAX_BPS);
assert(totalSupply == sumOfAllAccountBalances());
assert(approvedAsset[id] != address(0));
Then fuzz state transitions across modules. You are looking for combinations where each individual call is valid but the resulting state is nonsense.
Batch functions deserve special care. They often skip checks for gas efficiency and assume equal trust across all elements in the batch. One malformed item in the middle of a loop can leave partial state changes if the code uses low-level calls or external hooks poorly.
Read value accounting with rounding and edge states in mind
If your contract issues shares, tracks claims, splits proceeds, or applies fees, the hard part is rarely the main formula. The hard part is what happens at the boundaries.
Review these scenarios with concrete numbers:
- First depositor or first issuance.
- Last withdrawal.
- Zero supply with non-zero assets.
- Small balances under fee deductions.
- Repeated mint and burn cycles.
- Different decimal systems across integrated tokens.
Rounding direction matters. A floor in one function and a ceiling in another can leak value over time. The leak may be tiny per transaction and still become material under automation.
You want two things in code review.
First, explicit rounding choices. A helper like mulDiv with a named rounding mode is easier to reason about than scattered division.
Second, tests with hostile magnitudes. Use tiny values, max values, and mismatched decimals. If an ERC-20 with 6 decimals meets internal accounting built around 18-decimal assumptions, silent loss or blocked redemptions follow.
Do not ignore paused or emergency states here. Systems often handle accounting correctly in normal operation and break when assets are recovered, migrated, or settled after a pause. Review any admin rescue function as if it were a user withdrawal path with fewer safeguards, because in effect it is.
Check external calls, trust assumptions, and upgrade drift
A protocol rarely stands alone. It calls tokens, registries, transfer agents, signature verifiers, or document stores. Each dependency carries assumptions. If those assumptions are undocumented, your threat model is incomplete.
Build a dependency table.
- External contract address.
- What trust the system places in it.
- Whether it is upgradeable.
- Who controls it.
- What happens if it reverts, returns false, or changes behavior.
This catches a common review gap. Teams audit their own contracts and treat dependencies as constants. In practice, many dependencies are proxies controlled by another admin set. Your code may be stable while your system is not.
Technical checks here are straightforward.
- Use safe token transfer wrappers and inspect return-value handling.
- Confirm reentrancy assumptions around callbacks and hooks.
- Verify events fire on all state-changing paths integrations depend on.
- Confirm storage layout discipline across upgrades.
- Diff ABI and state invariants before and after each implementation change.
Upgrade drift deserves more attention than it gets. A clean v1 design accumulates edge-case patches. By v2 or v3, the code still compiles and unit tests still pass, but the original security model no longer fits reality.
One practical control is a machine-readable security spec checked in with the codebase. Keep a short file listing privileged functions, invariant caps, trusted dependencies, and pause assumptions. Review it on every pull request that changes storage, authority, or external call paths. The point is not formality. The point is noticing when the design moved.
What to watch next
Audit reports are most useful when they sharpen your own review process. The recurring signals are stable. Map privilege. Lock initialization. Validate state meaning, not input shape alone. Test accounting at edges. Track dependency trust and upgrade drift.
If you do those five things well, you catch a large share of the defects that keep appearing in production Solidity systems, including the quieter ones that look minor in isolation and expensive in aggregate.