본문으로 건너뛰기
Skillpedia
보안6.5k · #14011

reentrancy

하는 일

이 플레이북은 스마트 컨트랙트에서 재진입 약점을 찾는 방법을 안내합니다. 위험한 외부 호출이 안전한지 확인하려는 감사자와 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓컨트랙트가 값을 보내거나 상태를 바꾸는 외부 호출을 할 때.
  • ✓여러 함수가 같은 저장소를 공유할 때.
  • ✓호출 중에 읽기 전용 함수가 오래된 값을 반환할 수 있는 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

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.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“우리 금고 컨트랙트에서 재진입 버그를 확인하고, 출금 함수가 안전한지 알려 주시겠어요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 외부 호출을 찾고, 상태 변경이 그 전에 일어나는지, 재진입 가드가 적용되는지 확인한 뒤, 결과를 테스트합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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)
자주 묻는 질문

전형적인 해결책은 무엇인가요?

외부 호출 전에 상태를 먼저 갱신하는 것이며, 검사, 효과, 상호작용 순서를 따르는 방식입니다.

읽기 전용 재진입이란 무엇인가요?

호출 중 뷰 함수가 오래된 값을 반환할 수 있고, 다른 컨트랙트가 그 값에 의존할 수 있는 경우입니다.

발견 사항은 어떻게 확인하나요?

컨트랙트 잔액이 예치금보다 커지는지 확인하는 Foundry 테스트로 확인합니다.

상세 정보

작성자의 원본 설명

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

repo: BitterSecurity/Decepticon

인기도

GitHub 스타
6.5k
순위
#14011
라이선스
Apache-2.0
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬