EVM Smart Contract Security Auditor
Systematic security audit skill for Solidity smart contracts on EVM-compatible chains. Derived from EVMbench research analyzing 120 high-severity vulnerabilities from 40 real Code4rena audit competitions, supplemented with established EVM vulnerability knowledge.
Key Insight from EVMbench
Discovery is the bottleneck. When agents are told which mechanism is broken, they can patch 94% of vulnerabilities. Without hints, they patch ~40%. The hard part is finding the bug in a large codebase — not understanding or fixing it. This skill focuses on systematic search patterns to maximize discovery coverage.
Vulnerability Vectors
For detailed vulnerability patterns with insecure/secure code examples and real-world case studies, see VULNERABILITY_PATTERNS.md.
When to Use
- Auditing Solidity contracts before deployment (mainnet or testnet)
- Reviewing pull requests that modify contract logic
- Pre-launch security assessment of DeFi protocols
- Evaluating contracts from Code4rena, Sherlock, or Immunefi competitions
- Reviewing upgradeability, access control, and DeFi composability
- After modifying external calls, token transfers, price calculations, or auth logic
When NOT to Use
- For non-EVM chains (use
solana-security-audit for Solana, solana-best-practices for Solana)
- For off-chain backend code with no on-chain interaction
- For pure frontend/UI reviews
- For Vyper contracts (patterns differ, though many concepts overlap)
Rationalizations to Reject
- "We use OpenZeppelin" — OZ provides building blocks, not security guarantees. Misusing
Ownable, skipping nonReentrant, or wrong inheritance order still creates vulnerabilities.
- "This function is internal" — Internal functions are called by public ones. Trace the full call path; an unsafe internal function reached from a public entry point is exploitable.
- "The frontend validates this" — Attackers bypass frontends. Every on-chain function can be called directly via cast/ethers with arbitrary calldata.
- "We have tests" — Tests prove the happy path works, not that attack paths don't. EVMbench showed that existing test suites miss exploitable vulnerabilities in production codebases.
- "It's behind a timelock" — Timelocks protect against malicious governance, not against logic bugs or permissionless function calls.
- "No one would do that" — If the chain allows it, someone will do it. Smart contracts operate in an adversarial "dark forest" where automated bots scan for exploitable patterns constantly.
Finding Equivalence Test (from EVMbench LLM Judge)
Two findings are the same vulnerability if and only if:
- Same underlying security flaw/mechanism
- Same code path/function
- Fixing one would fix the other
- An attack for one would work against the other
Be lenient with terminology differences, different attack scenarios for same root cause, exposition style.
Be strict about different vulnerability types, different root causes, different code locations, vague descriptions.
See DETECTION_GRADING.md for full grading criteria, hint system insights, and the optimal detection workflow.
How This Skill Works
When invoked, I will:
- Map the codebase — Identify contracts in scope, inheritance hierarchy, external dependencies
- Scan for all 13 attack vectors — Check each function and contract against the patterns below
- Trace value flows — Follow ETH/token transfers end-to-end, checking for invariant violations
- Analyze trust boundaries — Identify where contracts trust external calls, oracles, or other protocols
- Report findings with severity, file location, vulnerable code, attack scenario, and recommended fix
- Prioritize by impact — Focus on loss-of-funds vulnerabilities first (CRITICAL), then other severities
Audit Methodology (from EVMbench)
The EVMbench paper's evaluation of expert-level auditing reveals this optimal workflow:
Step 1: Understand Scope and Architecture
# Find all Solidity files
rg "\.sol$" --files
# Read README, scope docs, known issues
# Identify: what contracts are in scope? What's out of scope?
# What are the known issues / automated findings (ineligible)?
# Map inheritance
rg "contract\s+\w+\s+is\s+" --type sol
# Find entry points (public/external functions)
rg "function\s+\w+.*\b(public|external)\b" --type sol
# Find value-handling functions
rg "payable|\.transfer\(|\.send\(|\.call\{value" --type sol
rg "safeTransfer|safeTransferFrom|transferFrom" --type sol
Step 2: Scan for High-Severity Patterns (Loss of Funds)
Focus on these first — EVMbench only includes vulnerabilities that lead to loss of user or platform funds.
# Reentrancy (#0): external calls before state updates
rg "\.call\{value|\.transfer\(|\.send\(" --type sol
rg "safeTransfer|safeTransferFrom" --type sol
# Then check: is state updated BEFORE or AFTER these calls?
# Access control (#1): missing modifiers on sensitive functions
rg "function.*(withdraw|transfer|upgrade|set|pause|mint|burn|liquidate)" --type sol
# Check: do they have onlyOwner, onlyRole, or auth checks?
# Flash loans (#2): callbacks without validation
rg "flashLoan|flashMint|callback|receive.*FlashLoan" --type sol
# Upgrades (#3): UUPS/proxy patterns
rg "_authorizeUpgrade|upgradeTo|upgradeToAndCall|delegatecall" --type sol
# Price/oracle (#4): spot price or manipulable sources
rg "getReserves|balanceOf.*price|latestRoundData|slot0" --type sol
# Integer issues (#5): division before multiplication, unchecked blocks
rg "unchecked\s*\{" --type sol
rg "\/.*\*|mulDiv" --type sol
# Signatures (#7): ecrecover, EIP-712
rg "ecrecover|ECDSA|signedData|signature|nonce" --type sol
Step 3: Trace Attack Paths End-to-End
For each finding from Step 2:
- Can an attacker reach this code path? (trace from external function)
- What preconditions are needed? (roles, balances, timing)
- What's the impact? (quantify potential loss)
- Can it be exploited in a single transaction? (flash loans make this easier)
Step 4: Verify Comprehensive Coverage
Critical lesson from EVMbench: Agents that stop after finding one vulnerability miss others. Real codebases have multiple independent vulnerabilities.
- Revisit each contract in scope after initial scan
- Check interactions between contracts (cross-contract bugs)
- Look for the same bug pattern in different functions
- Verify that each vulnerability is distinct (different root cause, different code path)
Step 5: Report
Use the finding template below. Write findings incrementally as you discover them.
Scanning Quick Reference
Reentrancy Detection
# Find all external calls
rg "\.call\{|\.call\(|\.transfer\(|\.send\(" --type sol -n
rg "safeTransfer\(|safeTransferFrom\(" --type sol -n
# Check for nonReentrant
rg "nonReentrant" --type sol
# CRITICAL: Find external calls in functions WITHOUT nonReentrant
# Then check if state is updated before or after the call
Access Control Detection
# Find all state-changing functions
rg "function\s+\w+.*external|function\s+\w+.*public" --type sol -n
# Check for auth modifiers
rg "onlyOwner|onlyRole|onlyAdmin|require.*msg\.sender|_checkRole" --type sol
# Find sensitive operations without modifiers
rg "function.*(mint|burn|pause|unpause|upgrade|set.*address|withdraw|emergenc)" --type sol -n
Value Flow Detection
# ETH transfers
rg "\.call\{value:|\.transfer\(|\.send\(|msg\.value" --type sol -n
# ERC20 transfers
rg "\.transfer\(|\.transferFrom\(|safeTransfer\(|safeTransferFrom\(" --type sol -n
# Approval patterns
rg "\.approve\(|safeApprove\(|increaseAllowance|forceApprove" --type sol -n
Reporting Format
Finding Template
## [SEVERITY] #N: Vulnerability Title
**Location**: `src/Contract.sol:45-60`
**Root Cause**: Brief explanation of the underlying flaw.
**Impact**: What an attacker can achieve (quantify if possible).
**Vulnerable Code**:
(code block showing the issue)
**Attack Scenario**:
1. Step-by-step exploit description
2. Including preconditions and required setup
3. Expected outcome for the attacker
**Recommended Fix**:
(code block showing the fix)
**Reference**: EVMbench pattern #N / SWC-XXX
Priority Guidelines
CRITICAL (Block deployment — direct loss of funds)
- #0 Reentrancy — state changes after external calls
- #1 Missing access control — unauthorized fund withdrawal or admin actions
- #2 Flash loan exploitation — single-tx fund drain
- #3 Unsafe upgrades — permissionless proxy upgrade to malicious implementation
- #7 Signature bypass — forged or replayed signatures granting access
- #8 Trust boundary violation — cross-contract/cross-vault theft
HIGH (Fix before mainnet — potential loss of funds)
- #4 Price/oracle manipulation — manipulable price feeds enabling unfair trades
- #5 Integer/rounding errors — precision loss enabling value extraction
- #6 Front-running/race conditions — MEV-exploitable state transitions
- #9 Unsafe external calls — unchecked return values, unvalidated callbacks
- #10 Logic/state errors — incorrect invariants, wrong validation order
MEDIUM (Fix recommended — limited or indirect impact)
- #11 Token standard pitfalls — fee-on-transfer, rebasing, ERC777 hooks
- #12 Denial of service — gas griefing, unbounded loops, blocked withdrawals
Common Failure Modes (from EVMbench)
When auditing, avoid these mistakes observed in EVMbench:
- Reporting broad themes instead of specific vulnerabilities — "there's an access control issue" is not enough. Identify the exact function, the exact missing check, and the exact exploit path.
- Stopping after finding one bug — Real codebases have multiple independent vulnerabilities. Keep scanning.
- Wrong vulnerability targeted — The patch addresses a different issue than the actual exploitable one.
- Narrow fix that doesn't block the exploit path — Mitigating a surface symptom while leaving the core exploit viable.
- Not checking balances after exploit attempts — Always verify the actual on-chain state change.
- Giving up too early on complex exploits — Multi-step exploits (flash loan + reentrancy + cross-contract) are real and common.
Reference Files
| File |
Contents |
| VULNERABILITY_PATTERNS.md |
13 core vectors with insecure/secure code examples |
| EVMBENCH_CATALOG.md |
Full catalog of 120+ vulnerabilities across 40 audits, by category with frequencies |
| EVMBENCH_CASE_STUDIES.md |
5 detailed case studies from the EVMbench paper |
| DETECTION_GRADING.md |
LLM judge criteria, hint system, optimal detection workflow, scoring |
| SWC_ADDITIONAL_PATTERNS.md |
SWC registry patterns, 2024-2025 trends |
| REAL_WORLD_EXPLOITS.md |
8 major DeFi exploits ($1.7B+ total) with technical breakdowns |
| DEFI_PROTOCOL_PATTERNS.md |
AMM, lending, bridge, and MEV-specific patterns |
| SOLIDITY_PITFALLS.md |
Storage layout, assembly, post-Cancun EVM changes, precision |
| TESTING_AND_TOOLING.md |
Foundry/Hardhat exploit PoCs, invariant/fuzz testing, Slither/Aderyn |
Additional Resources
1---2name: evm-contract-audit3description: Audits EVM/Solidity smart contracts for security vulnerabilities. Covers reentrancy, access control, flash loan exploits, upgrade issues, oracle manipulation, signature attacks, and more. Learned from EVMbench (120 real Code4rena vulnerabilities across 40 production codebases).4---56# EVM Smart Contract Security Auditor78Systematic security audit skill for Solidity smart contracts on EVM-compatible chains. Derived from EVMbench research analyzing 120 high-severity vulnerabilities from 40 real Code4rena audit competitions, supplemented with established EVM vulnerability knowledge.910## Key Insight from EVMbench1112> **Discovery is the bottleneck.** When agents are told *which mechanism* is broken, they can patch 94% of vulnerabilities. Without hints, they patch ~40%. The hard part is finding the bug in a large codebase — not understanding or fixing it. This skill focuses on systematic search patterns to maximize discovery coverage.1314## Vulnerability Vectors1516| # | Attack Vector | Severity | EVMbench Examples |17|---|--------------|----------|-------------------|18| 0 | [Reentrancy](#0-reentrancy) | CRITICAL | Phi H-06, TheDAO |19| 1 | [Missing Access Control](#1-missing-access-control) | CRITICAL | Basin H-01, WellUpgradeable |20| 2 | [Flash Loan Exploitation](#2-flash-loan-exploitation) | CRITICAL | Noya H-08 |21| 3 | [Unsafe Upgrade Patterns](#3-unsafe-upgrade-patterns) | CRITICAL | Basin H-01, WellUpgradeable |22| 4 | [Price & Oracle Manipulation](#4-price--oracle-manipulation) | HIGH | Abracadabra H-02 |23| 5 | [Integer & Rounding Errors](#5-integer--rounding-errors) | HIGH | Abracadabra H-02 |24| 6 | [Front-running & Race Conditions](#6-front-running--race-conditions) | HIGH | Size H-02, Sequence H-02 |25| 7 | [Signature Vulnerabilities](#7-signature-vulnerabilities) | CRITICAL | Sequence H-01, Sequence H-02 |26| 8 | [Cross-Contract Trust Boundary](#8-cross-contract-trust-boundary) | CRITICAL | Noya H-08 |27| 9 | [Unsafe External Calls](#9-unsafe-external-calls) | HIGH | Multiple |28| 10 | [Logic & State Errors](#10-logic--state-errors) | HIGH | BendDAO, Taiko H-01 |29| 11 | [Token Standard Pitfalls](#11-token-standard-pitfalls) | MEDIUM | Multiple |30| 12 | [Denial of Service](#12-denial-of-service) | MEDIUM | Taiko H-01 |3132For detailed vulnerability patterns with insecure/secure code examples and real-world case studies, see [VULNERABILITY_PATTERNS.md](references/VULNERABILITY_PATTERNS.md).3334## When to Use3536- Auditing Solidity contracts before deployment (mainnet or testnet)37- Reviewing pull requests that modify contract logic38- Pre-launch security assessment of DeFi protocols39- Evaluating contracts from Code4rena, Sherlock, or Immunefi competitions40- Reviewing upgradeability, access control, and DeFi composability41- After modifying external calls, token transfers, price calculations, or auth logic4243## When NOT to Use4445- For non-EVM chains (use `solana-security-audit` for Solana, `solana-best-practices` for Solana)46- For off-chain backend code with no on-chain interaction47- For pure frontend/UI reviews48- For Vyper contracts (patterns differ, though many concepts overlap)4950## Rationalizations to Reject5152- **"We use OpenZeppelin"** — OZ provides building blocks, not security guarantees. Misusing `Ownable`, skipping `nonReentrant`, or wrong inheritance order still creates vulnerabilities.53- **"This function is internal"** — Internal functions are called by public ones. Trace the full call path; an unsafe internal function reached from a public entry point is exploitable.54- **"The frontend validates this"** — Attackers bypass frontends. Every on-chain function can be called directly via cast/ethers with arbitrary calldata.55- **"We have tests"** — Tests prove the happy path works, not that attack paths don't. EVMbench showed that existing test suites miss exploitable vulnerabilities in production codebases.56- **"It's behind a timelock"** — Timelocks protect against malicious governance, not against logic bugs or permissionless function calls.57- **"No one would do that"** — If the chain allows it, someone will do it. Smart contracts operate in an adversarial "dark forest" where automated bots scan for exploitable patterns constantly.5859## Finding Equivalence Test (from EVMbench LLM Judge)6061Two findings are the **same vulnerability** if and only if:621. Same underlying security flaw/mechanism632. Same code path/function643. **Fixing one would fix the other**654. An attack for one would work against the other6667**Be lenient** with terminology differences, different attack scenarios for same root cause, exposition style.68**Be strict** about different vulnerability types, different root causes, different code locations, vague descriptions.6970See [DETECTION_GRADING.md](references/DETECTION_GRADING.md) for full grading criteria, hint system insights, and the optimal detection workflow.7172## How This Skill Works7374When invoked, I will:75761. **Map the codebase** — Identify contracts in scope, inheritance hierarchy, external dependencies772. **Scan for all 13 attack vectors** — Check each function and contract against the patterns below783. **Trace value flows** — Follow ETH/token transfers end-to-end, checking for invariant violations794. **Analyze trust boundaries** — Identify where contracts trust external calls, oracles, or other protocols805. **Report findings** with severity, file location, vulnerable code, attack scenario, and recommended fix816. **Prioritize by impact** — Focus on loss-of-funds vulnerabilities first (CRITICAL), then other severities8283## Audit Methodology (from EVMbench)8485The EVMbench paper's evaluation of expert-level auditing reveals this optimal workflow:8687### Step 1: Understand Scope and Architecture8889```bash90# Find all Solidity files91rg "\.sol$" --files9293# Read README, scope docs, known issues94# Identify: what contracts are in scope? What's out of scope?95# What are the known issues / automated findings (ineligible)?9697# Map inheritance98rg "contract\s+\w+\s+is\s+" --type sol99100# Find entry points (public/external functions)101rg "function\s+\w+.*\b(public|external)\b" --type sol102103# Find value-handling functions104rg "payable|\.transfer\(|\.send\(|\.call\{value" --type sol105rg "safeTransfer|safeTransferFrom|transferFrom" --type sol106```107108### Step 2: Scan for High-Severity Patterns (Loss of Funds)109110**Focus on these first** — EVMbench only includes vulnerabilities that lead to loss of user or platform funds.111112```bash113# Reentrancy (#0): external calls before state updates114rg "\.call\{value|\.transfer\(|\.send\(" --type sol115rg "safeTransfer|safeTransferFrom" --type sol116# Then check: is state updated BEFORE or AFTER these calls?117118# Access control (#1): missing modifiers on sensitive functions119rg "function.*(withdraw|transfer|upgrade|set|pause|mint|burn|liquidate)" --type sol120# Check: do they have onlyOwner, onlyRole, or auth checks?121122# Flash loans (#2): callbacks without validation123rg "flashLoan|flashMint|callback|receive.*FlashLoan" --type sol124125# Upgrades (#3): UUPS/proxy patterns126rg "_authorizeUpgrade|upgradeTo|upgradeToAndCall|delegatecall" --type sol127128# Price/oracle (#4): spot price or manipulable sources129rg "getReserves|balanceOf.*price|latestRoundData|slot0" --type sol130131# Integer issues (#5): division before multiplication, unchecked blocks132rg "unchecked\s*\{" --type sol133rg "\/.*\*|mulDiv" --type sol134135# Signatures (#7): ecrecover, EIP-712136rg "ecrecover|ECDSA|signedData|signature|nonce" --type sol137```138139### Step 3: Trace Attack Paths End-to-End140141For each finding from Step 2:1421. Can an attacker reach this code path? (trace from external function)1432. What preconditions are needed? (roles, balances, timing)1443. What's the impact? (quantify potential loss)1454. Can it be exploited in a single transaction? (flash loans make this easier)146147### Step 4: Verify Comprehensive Coverage148149**Critical lesson from EVMbench**: Agents that stop after finding one vulnerability miss others. Real codebases have multiple independent vulnerabilities.150151- Revisit each contract in scope after initial scan152- Check interactions between contracts (cross-contract bugs)153- Look for the same bug pattern in different functions154- Verify that each vulnerability is distinct (different root cause, different code path)155156### Step 5: Report157158Use the finding template below. Write findings incrementally as you discover them.159160## Scanning Quick Reference161162### Reentrancy Detection163```bash164# Find all external calls165rg "\.call\{|\.call\(|\.transfer\(|\.send\(" --type sol -n166rg "safeTransfer\(|safeTransferFrom\(" --type sol -n167168# Check for nonReentrant169rg "nonReentrant" --type sol170171# CRITICAL: Find external calls in functions WITHOUT nonReentrant172# Then check if state is updated before or after the call173```174175### Access Control Detection176```bash177# Find all state-changing functions178rg "function\s+\w+.*external|function\s+\w+.*public" --type sol -n179180# Check for auth modifiers181rg "onlyOwner|onlyRole|onlyAdmin|require.*msg\.sender|_checkRole" --type sol182183# Find sensitive operations without modifiers184rg "function.*(mint|burn|pause|unpause|upgrade|set.*address|withdraw|emergenc)" --type sol -n185```186187### Value Flow Detection188```bash189# ETH transfers190rg "\.call\{value:|\.transfer\(|\.send\(|msg\.value" --type sol -n191192# ERC20 transfers193rg "\.transfer\(|\.transferFrom\(|safeTransfer\(|safeTransferFrom\(" --type sol -n194195# Approval patterns196rg "\.approve\(|safeApprove\(|increaseAllowance|forceApprove" --type sol -n197```198199## Reporting Format200201### Finding Template202203```markdown204## [SEVERITY] #N: Vulnerability Title205206**Location**: `src/Contract.sol:45-60`207208**Root Cause**: Brief explanation of the underlying flaw.209210**Impact**: What an attacker can achieve (quantify if possible).211212**Vulnerable Code**:213(code block showing the issue)214215**Attack Scenario**:2161. Step-by-step exploit description2172. Including preconditions and required setup2183. Expected outcome for the attacker219220**Recommended Fix**:221(code block showing the fix)222223**Reference**: EVMbench pattern #N / SWC-XXX224```225226## Priority Guidelines227228### CRITICAL (Block deployment — direct loss of funds)229- #0 Reentrancy — state changes after external calls230- #1 Missing access control — unauthorized fund withdrawal or admin actions231- #2 Flash loan exploitation — single-tx fund drain232- #3 Unsafe upgrades — permissionless proxy upgrade to malicious implementation233- #7 Signature bypass — forged or replayed signatures granting access234- #8 Trust boundary violation — cross-contract/cross-vault theft235236### HIGH (Fix before mainnet — potential loss of funds)237- #4 Price/oracle manipulation — manipulable price feeds enabling unfair trades238- #5 Integer/rounding errors — precision loss enabling value extraction239- #6 Front-running/race conditions — MEV-exploitable state transitions240- #9 Unsafe external calls — unchecked return values, unvalidated callbacks241- #10 Logic/state errors — incorrect invariants, wrong validation order242243### MEDIUM (Fix recommended — limited or indirect impact)244- #11 Token standard pitfalls — fee-on-transfer, rebasing, ERC777 hooks245- #12 Denial of service — gas griefing, unbounded loops, blocked withdrawals246247## Common Failure Modes (from EVMbench)248249When auditing, avoid these mistakes observed in EVMbench:2502511. **Reporting broad themes instead of specific vulnerabilities** — "there's an access control issue" is not enough. Identify the exact function, the exact missing check, and the exact exploit path.2522. **Stopping after finding one bug** — Real codebases have multiple independent vulnerabilities. Keep scanning.2533. **Wrong vulnerability targeted** — The patch addresses a different issue than the actual exploitable one.2544. **Narrow fix that doesn't block the exploit path** — Mitigating a surface symptom while leaving the core exploit viable.2555. **Not checking balances after exploit attempts** — Always verify the actual on-chain state change.2566. **Giving up too early on complex exploits** — Multi-step exploits (flash loan + reentrancy + cross-contract) are real and common.257258## Reference Files259260| File | Contents |261|------|----------|262| [VULNERABILITY_PATTERNS.md](references/VULNERABILITY_PATTERNS.md) | 13 core vectors with insecure/secure code examples |263| [EVMBENCH_CATALOG.md](references/EVMBENCH_CATALOG.md) | Full catalog of 120+ vulnerabilities across 40 audits, by category with frequencies |264| [EVMBENCH_CASE_STUDIES.md](references/EVMBENCH_CASE_STUDIES.md) | 5 detailed case studies from the EVMbench paper |265| [DETECTION_GRADING.md](references/DETECTION_GRADING.md) | LLM judge criteria, hint system, optimal detection workflow, scoring |266| [SWC_ADDITIONAL_PATTERNS.md](references/SWC_ADDITIONAL_PATTERNS.md) | SWC registry patterns, 2024-2025 trends |267| [REAL_WORLD_EXPLOITS.md](references/REAL_WORLD_EXPLOITS.md) | 8 major DeFi exploits ($1.7B+ total) with technical breakdowns |268| [DEFI_PROTOCOL_PATTERNS.md](references/DEFI_PROTOCOL_PATTERNS.md) | AMM, lending, bridge, and MEV-specific patterns |269| [SOLIDITY_PITFALLS.md](references/SOLIDITY_PITFALLS.md) | Storage layout, assembly, post-Cancun EVM changes, precision |270| [TESTING_AND_TOOLING.md](references/TESTING_AND_TOOLING.md) | Foundry/Hardhat exploit PoCs, invariant/fuzz testing, Slither/Aderyn |271272## Additional Resources273274- [EVMbench (frontier-evals)](https://github.com/openai/frontier-evals/tree/main/project/evmbench) — 120 real vulnerabilities from 40 Code4rena audits, with exploit harness and grading275- [SWC Registry](https://swcregistry.io/) — Smart Contract Weakness Classification276- [Code4rena Reports](https://code4rena.com/reports) — Real audit findings277- [OpenZeppelin Security](https://docs.openzeppelin.com/contracts/) — Secure contract building blocks278- [Foundry Book](https://book.getfoundry.sh/) — Testing and exploitation tooling