Reentrancy

From PurpleAILAB/Decepticon · View interactive version

Reentrancy is an AI agent skill from the GitHub repository PurpleAILAB/Decepticon. Hunt and validate reentrancy bugs — classic cross-function, same-function, read-only, and cross-contract variants.

How to use this skill

Skill file

Reentrancy Playbook

Variants

  1. Classic — external call before state update (The DAO)
  2. Cross-function — A calls out, reentered into B which reads/writes A's state
  3. Read-only — view function reads stale state during reentrancy, consumed by a second contract making decisions
  4. Cross-contract — same attack pattern across protocol boundaries
  5. ERC777 / ERC1155 hook — onERC*Received callback re-enters

Audit steps

  1. solidity_scan_file flags every .call{value:...} and delegatecall
  2. For each hit, check:
  1. Trace call graph — if any function the call target can invoke reads

or writes the same state slot, that's a reentrancy chain.

PoC via Foundry

foundry_reentrancy_test(target="Vault", function="withdraw", target_path="src/Vault.sol")

Then:

cp generated.t.sol /workspace/foundry/test/
cd /workspace/foundry && forge test -vvv --match-contract Test_withdraw

Success criteria

The attacker contract balance grows by more than its initial deposit

after the attack transaction. The Foundry test should assert this.

CVSS

Known exemplars

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.