Reentrancy Auditor
When to Use
- Auditing external calls, token transfers, state management
- User mentions: reentrancy, ERC777, callback, CEI pattern, nonReentrant, external call, state update
- Analyzing call order, state synchronization, view functions
- Reviewing token transfer patterns, external integrations
Audit Workflow
IMPORTANT: Announce skill usage at the start of analysis
Begin with: "I'm using the audit-reentrancy skill to analyze this contract for reentrancy vulnerabilities..."
Scan for reentrancy vectors
- Search:
transfer, call, delegatecall, external, nonReentrant, ERC777, tokensReceived, onERC721Received
- Focus: external calls, token transfers, state updates, callback hooks
Check against vulnerability patterns
- Reference
reference.md for complete checklist
- Compare code against
example.md
Validate exploitability
- Check access control first - grep for
onlyOwner|onlyAdmin|onlyGovernance modifiers
- Can non-privileged actors exploit the reentrancy?
- Are state updates after external calls?
- Can callbacks reenter different functions?
- Do view functions read stale state during reentrancy?
- Can attackers control callback timing?
- Verify no compensating protections exist
- Downgrade severity if admin-only unless cross-function attack exists
Generate report
- Use deliverable template below
- Include attack flow and PoC
- Rank by severity
Core Vulnerability Patterns
See reference.md for full checklist. Key patterns:
- Token transfer reentrancy → ERC777/callback tokens allow reentrancy during transfers
- State update after external call → transfer-before-update pattern enables draining
- Cross-function reentrancy → reenter different functions to manipulate shared state
- Read-only reentrancy → read stale state during reentrancy for profit
Code examples: See example.md
Severity Criteria
Critical: State updates after external calls enabling direct fund draining, cross-function reentrancy manipulating critical shared state, MUST be exploitable by non-privileged actors
High: Token transfer reentrancy without nonReentrant protection, read-only reentrancy enabling price manipulation exploits, MUST be exploitable by non-privileged actors
Medium: Partial CEI violations with limited impact, missing nonReentrant on non-critical functions, admin-only CEI violations with cascading impact
Low: View function reentrancy without exploitable impact, theoretical reentrancy with no attack vector, admin-only CEI issues without immediate user impact
IMPORTANT: Admin-only functions (onlyOwner, onlyAdmin) with CEI violations are LOW severity unless:
- Admin function makes external calls that can reenter user-facing functions
- CEI violation enables governance attack to drain user funds
- Missing nonReentrant allows admin+user reentrancy combo attack
False Positives - Do NOT Flag
- Internal functions (not externally callable)
- View functions reading non-critical state
- Contracts explicitly designed for trusted tokens only
- External calls with documented reentrancy safety analysis
- Functions with nonReentrant modifier properly applied
Deliverable Format
MANDATORY: Before deliverable, verify each checklist.md item against codebase. Flag violations as findings.
Use template: templates/report-template.md
Each finding includes: severity, pattern #, file/lines, description, vulnerable code, attack flow, PoC showing fund draining, remediation.
Key Principles
- CEI pattern - Checks, Effects, Interactions (state changes before external calls)
- Mutex protection - nonReentrant modifier on state-changing functions
- Token awareness - assume any token can have callbacks
- Cross-function analysis - consider reentering different functions
- Read safety - view functions must handle reentrancy
Output Guidelines
DO:
- Reference specific lines and functions
- Provide complete attack flow with reentry point
- Show PoCs demonstrating fund draining
- Identify all shared state accessed
- Map cross-function reentrancy paths
DON'T:
- Report theoretical reentrancy without exploit path
- Flag internal functions (not exploitable)
- Ignore nonReentrant modifiers already in place
- Miss cross-function reentrancy (most common miss)
1---2name: audit-reentrancy3description: Audits Solidity smart contracts for reentrancy vulnerabilities including token transfer reentrancy via ERC777/callback tokens, state updates after external calls enabling draining, cross-function reentrancy manipulating shared state, and read-only reentrancy exploiting stale state during callbacks (project)4license: MIT5---67# Reentrancy Auditor89## When to Use10- Auditing external calls, token transfers, state management11- User mentions: reentrancy, ERC777, callback, CEI pattern, nonReentrant, external call, state update12- Analyzing call order, state synchronization, view functions13- Reviewing token transfer patterns, external integrations1415## Audit Workflow1617**IMPORTANT: Announce skill usage at the start of analysis**1819Begin with: "I'm using the **audit-reentrancy** skill to analyze this contract for reentrancy vulnerabilities..."20211. **Scan for reentrancy vectors**22 - Search: `transfer`, `call`, `delegatecall`, `external`, `nonReentrant`, `ERC777`, `tokensReceived`, `onERC721Received`23 - Focus: external calls, token transfers, state updates, callback hooks24252. **Check against vulnerability patterns**26 - Reference `reference.md` for complete checklist27 - Compare code against `example.md`28293. **Validate exploitability**30 - **Check access control first** - grep for `onlyOwner|onlyAdmin|onlyGovernance` modifiers31 - Can non-privileged actors exploit the reentrancy?32 - Are state updates after external calls?33 - Can callbacks reenter different functions?34 - Do view functions read stale state during reentrancy?35 - Can attackers control callback timing?36 - Verify no compensating protections exist37 - Downgrade severity if admin-only unless cross-function attack exists38394. **Generate report**40 - Use deliverable template below41 - Include attack flow and PoC42 - Rank by severity4344## Core Vulnerability Patterns4546See `reference.md` for full checklist. Key patterns:47481. Token transfer reentrancy → ERC777/callback tokens allow reentrancy during transfers492. State update after external call → transfer-before-update pattern enables draining503. Cross-function reentrancy → reenter different functions to manipulate shared state514. Read-only reentrancy → read stale state during reentrancy for profit5253**Code examples:** See `example.md`5455## Severity Criteria5657**Critical:** State updates after external calls enabling direct fund draining, cross-function reentrancy manipulating critical shared state, **MUST be exploitable by non-privileged actors**58**High:** Token transfer reentrancy without nonReentrant protection, read-only reentrancy enabling price manipulation exploits, **MUST be exploitable by non-privileged actors**59**Medium:** Partial CEI violations with limited impact, missing nonReentrant on non-critical functions, admin-only CEI violations with cascading impact60**Low:** View function reentrancy without exploitable impact, theoretical reentrancy with no attack vector, admin-only CEI issues without immediate user impact6162**IMPORTANT:** Admin-only functions (onlyOwner, onlyAdmin) with CEI violations are **LOW severity** unless:63- Admin function makes external calls that can reenter user-facing functions64- CEI violation enables governance attack to drain user funds65- Missing nonReentrant allows admin+user reentrancy combo attack6667## False Positives - Do NOT Flag6869- Internal functions (not externally callable)70- View functions reading non-critical state71- Contracts explicitly designed for trusted tokens only72- External calls with documented reentrancy safety analysis73- Functions with nonReentrant modifier properly applied7475## Deliverable Format7677**MANDATORY:** Before deliverable, verify each `checklist.md` item against codebase. Flag violations as findings.7879Use template: `templates/report-template.md`8081Each finding includes: severity, pattern #, file/lines, description, vulnerable code, attack flow, PoC showing fund draining, remediation.8283## Key Principles8485- **CEI pattern** - Checks, Effects, Interactions (state changes before external calls)86- **Mutex protection** - nonReentrant modifier on state-changing functions87- **Token awareness** - assume any token can have callbacks88- **Cross-function analysis** - consider reentering different functions89- **Read safety** - view functions must handle reentrancy9091## Output Guidelines9293**DO:**94- Reference specific lines and functions95- Provide complete attack flow with reentry point96- Show PoCs demonstrating fund draining97- Identify all shared state accessed98- Map cross-function reentrancy paths99100**DON'T:**101- Report theoretical reentrancy without exploit path102- Flag internal functions (not exploitable)103- Ignore nonReentrant modifiers already in place104- Miss cross-function reentrancy (most common miss)