| name | review-smart-contract-security |
| description | Use when auditing a Solidity smart contract or reviewing a protocol before deployment — systematically checking all 10 OWASP Smart Contract Top 10 vulnerability classes with Slither/Foundry test procedures. |
| source | OWASP Smart Contract Top 10 (owasp.org/www-project-smart-contract-top-10/); SWC Registry (swcregistry.io); Slither documentation; Trail of Bits audit methodology |
| tags | ["security","owasp","solidity","smart-contracts","audit","ethereum","blockchain"] |
Review Smart Contract Security
Audit smart contracts against the OWASP Smart Contract Top 10 using Slither static analysis and Foundry invariant testing — covering SC01 through SC10 with specific test procedures, detection commands, and remediation steps.
Why This Is Best Practice
Adopted by: OWASP Smart Contract Top 10 is the authoritative vulnerability taxonomy. Trail of Bits, OpenZeppelin Security, and Consensys Diligence — the three most prominent smart contract audit firms — all use structured checklists covering SC01–SC10 equivalent categories. Slither (Trail of Bits) is the standard static analysis tool, used in Ethereum Foundation security tooling. MakerDAO, Compound, and Uniswap conduct external audits plus internal pre-deployment reviews against these classes before each major release.
Impact: Smart contract audit findings consistently cluster in these 10 categories. Immunefi's "DeFi Bug Bounty Report" (2023) found that 73% of critical findings were in categories covered by SC01–SC10. Protocols that undergo structured audits have 4× lower incident rates than unaudited protocols (DeFi Safety score analysis, 2022). The $1B+ in DeFi losses attributed to smart contract exploits in 2022–2023 would have been significantly reduced by systematic SC01–SC10 review.
Why best: Manual code review without a structured checklist misses vulnerability classes — a reviewer focused on reentrancy may overlook integer overflow or oracle manipulation. The SC01–SC10 framework provides completeness; Slither and Foundry provide automated detection for the mechanical findings, freeing human reviewers to focus on business logic vulnerabilities that tools miss.
Sources: OWASP Smart Contract Top 10; SWC Registry; Trail of Bits Slither documentation; Immunefi Bug Bounty Report (2023)
Steps
Pre-Audit Setup
pip install slither-analyzer
forge install foundry-rs/forge-std
slither . --checklist --markdown-root "contracts/"
slither . --detect reentrancy-eth,reentrancy-no-eth
slither . --detect unprotected-upgrade,suicidal
slither . --detect oracle-manipulation,msg-value-loop
SC01 — Access Control
slither . --detect unprotected-upgrade,suicidal,controlled-delegatecall
Check:
SC02 — Integer Overflow/Underflow (pre-Solidity 0.8.x)
slither . --detect overflow-before-cast,tautology
Check:
SC03 — Timestamp Dependence
slither . --detect weak-prng,timestamp
Check:
SC04 — Reentrancy
slither . --detect reentrancy-eth,reentrancy-no-eth,reentrancy-benign,reentrancy-events
Check:
SC05 — Unprotected Ether Withdrawal (SWC-105)
slither . --detect suicidal,locked-ether,arbitrary-send-eth
Check:
SC06 — Oracle Manipulation
grep -r "slot0()" contracts/
grep -r "getReserves()" contracts/
Check:
SC07 — Logic Errors (Business Logic Bugs)
forge test --match-test invariant
Write invariant tests:
// Foundry invariant: total supply never exceeds max
function invariant_totalSupplyLeqMax() external view {
assertLe(token.totalSupply(), MAX_SUPPLY);
}
// Invariant: vault solvency — assets >= liabilities
function invariant_vaultSolvent() external view {
assertGe(vault.totalAssets(), vault.totalLiabilities());
}
SC08 — Insecure Randomness
slither . --detect weak-prng
grep -r "block\.timestamp\|block\.number\|blockhash\|block\.prevrandao" contracts/
Check:
SC09 — Gas Limit and Denial of Service
slither . --detect costly-loop,msg-value-loop
Check:
SC10 — Front-Running
grep -rn "amountOutMinimum: 0\|minAmountOut: 0" contracts/
grep -rn "deadline.*block\.timestamp" contracts/
Check:
Final Checklist
Audit Summary:
□ SC01 Access Control — all privileged functions protected
□ SC02 Integer Safety — 0.8.x or SafeMath, no unsafe unchecked
□ SC03 Timestamp — no block vars for randomness
□ SC04 Reentrancy — CEI + nonReentrant on all external calls
□ SC05 Ether Withdrawal — no arbitrary send, no locked ETH
□ SC06 Oracle — TWAP/Chainlink with staleness checks
□ SC07 Logic — invariant tests written and passing
□ SC08 Randomness — Chainlink VRF for all random outcomes
□ SC09 Gas/DoS — no unbounded loops, pull payment pattern
□ SC10 Front-running — slippage protection, deadline params
□ Slither 0 high/medium findings
□ External audit completed (for TVL > $100k)
Rules
- Run Slither before every PR merge — CI integration:
slither . --fail-on high.
- All high/critical Slither findings must be fixed or documented with a false-positive justification.
- Invariant tests must cover core financial invariants (solvency, supply caps, fee bounds).
- Any protocol with TVL > $100k should have an external professional audit before mainnet deployment.
Common Mistakes
- Only auditing the main contract, not libraries and interfaces — reentrancy and oracle bugs often exist in inherited contracts or libraries.
- Treating Slither PASS as audit complete — Slither catches mechanical patterns but misses business logic bugs (wrong formula, wrong price direction) that require human review.
- Testing only on local fork, not on mainnet fork — Foundry
vm.createFork(mainnet_rpc) tests real oracle conditions and real liquidity depths.
- Not re-auditing after contract changes — a minor change to fee calculation or access control can introduce new vulnerability paths; re-run the full checklist after any significant change.