Skip to content
Skillpedia
Security6.5k · #14011

reentrancy

What it does

This playbook guides the search for reentrancy weaknesses in smart contracts. It is for auditors and developers who want to confirm each risky external call is safe.

When to use it

  • ✓When a contract makes an external call that sends value or changes state.
  • ✓When several functions in a contract share the same storage.
  • ✓When a read-only function may return stale values during a call.

Skill link

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/reentrancy/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/reentrancy/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Can you check our vault contract for reentrancy bugs and confirm whether the withdraw function is safe?”

5 new skills a week. 1 minute to read.

How it works

The agent finds external calls, checks whether state changes happen before them and whether a reentrancy guard is applied, then tests the result.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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:
    • Is there a state write BEFORE the external call?
    • Is ReentrancyGuard's nonReentrant modifier applied?
    • Does it follow checks-effects-interactions?
  3. 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

  • Direct fund drain: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H = 10.0
  • Read-only with downstream impact: 8.1-9.1 depending on impact

Known exemplars

  • The DAO (2016)
  • Lendf.Me (2020, ERC777 hook reentrancy, $25M)
  • Cream Finance (2021)
  • Rari Capital (2022)
  • Curve pool read-only reentrancy (2023)
FAQ

What is the classic fix?

Update state before the external call, following the checks, effects, then interactions pattern.

What is read-only reentrancy?

A view function can return stale values during a call, and another contract may rely on them.

How is a finding confirmed?

With a Foundry test that checks whether the contract balance grows beyond its deposit.

Details

Original description by the author

Hunt and validate reentrancy bugs — classic cross-function, same-function, read-only, and cross-contract variants.

repo: BitterSecurity/Decepticon

Popularity

GitHub stars
6.5k
Ranking position
#14011
License
Apache-2.0
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills