Communitygithub.com

auditing-foundry-smart-contract-security

Foundry 스마트 컨트랙트 사전 배포 감사를 위한 심층 방어 감사 스킬입니다. 정적 분석, 심볼릭 실행, 속성 기반 테스트, 수동 검토를 결합하여 재진입, 접근 제어, 오라클 조작 등 주요 취약점을 탐지합니다.

auditing-foundry-smart-contract-security란 무엇인가요?

이 AI 에이전트 스킬은 Foundry 프로젝트의 Solidity 스마트 컨트랙트를 배포 전에 심층 방어 방식으로 감사합니다. Slither와 Aderyn을 통한 빠른 정적 분석, 선택적으로 Mythril을 사용한 심볼릭 실행, Forge의 퍼징 및 불변 속성 테스트, 그리고 취약점 체크리스트와 키 보안 감사를 포함한 수동 검토 등 네 가지 독립적인 기법을 계층화하여 각각 다른 기법이 놓칠 수 있는 버그를 찾아냅니다. 이 스킬은 개발자 측에서 사전 배포 단계에서 실행되며, 발견된 모든 높음/심각도 정적 분석 결과, 실패한 테스트, 유출된 키, 낮은 커버리지는 배포를 차단합니다. 주로 DeFi 프로토콜, 토큰, 볼트, 스테이킹, AMM, 브리지, 거버넌스 등 가치를 처리하는 컨트랙트에 사용됩니다. 지원 플랫폼은 Foundry, Slither, Aderyn, Mythril이며, 결과는 SWC 식별자, 심각도, 도구 출처, 영향을 받는 컨트랙트/함수/라인 및 수정 권장 사항을 포함한 JSON 감사 보고서(PASS/FAIL 게이트 포함)로 출력됩니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/auditing-foundry-smart-contract-security

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Auditing Foundry Smart Contract Security

개요

배포된 스마트 컨트랙트는 불변이며 실제 자금을 관리하므로 메인넷에 배포된 버그는 패치할 수 없고 악용될 수만 있습니다. 대부분의 치명적인 DeFi 손실은 재진입, 손상된 접근 제어, 오라클/가격 조작, unchecked arithmetic 또는 외부 호출 등 소수의 반복되는 클래스에서 발생합니다.

이 스킬은 Foundry 프로젝트에 대한 심층 방어, 사전 배포 감사를 실행하며, 각각 다른 기법이 놓치는 것을 포착하는 네 가지 독립적인 기술을 계층화합니다:

  1. 정적 분석 — slither (90개 이상의 탐지기) 및 aderyn (Cyfrin, Rust)이 AST/IR을 초 단위로 스캔하여 알려진 안티패턴을 찾습니다.
  2. 심볼릭 실행 — mythril (선택 사항, 느림)이 실행 경로를 탐색하고 SMT 솔버를 통해 심층 산술/재진입 버그를 해결합니다.
  3. 속성 기반 테스트 — forge test와 퍼징(testFuzz_*) 및 불변 테스트(invariant_* + 핸들러 컨트랙트와 ghost 변수)를 통해 프로토콜 수준의 속성이 수백만 개의 무작위 시퀀스에서 유지됨을 증명합니다.
  4. 수동 검토 + 키 보안 — 구조화된 체크리스트 (references/vulnerability-checklist.md 참조) 및 비밀/키스토어 감사를 통해 개인 키가 평문에 존재하지 않고 암호화된 cast 키스토어를 통해 배포되도록 합니다 (references/secure-deployment-and-keys.md 참조).

이 스킬은 개발자 측면, 사전 배포 단계입니다 — SOC가 사고 후에 실행하는 것이 아니라 컨트랙트를 구축하는 엔지니어가 실행합니다. 발견 사항은 배포를 제한합니다: 높음/심각도 정적 분석 결과, 실패한 테스트, 유출된 키 또는 낮은 커버리지 = FAIL.

사용 시기

  • Solidity 컨트랙트를 테스트넷 또는 메인넷 EVM 체인에 배포하기 전.
  • Foundry 프로젝트 (foundry.toml, src/, test/, script/)를 작성하거나 검토할 때.
  • 컨트랙트가 가치(토큰(ERC-20/721/1155), 볼트, 스테이킹, AMM, 브리지, 거버넌스)를 처리할 때.
  • 퍼즈 또는 불변 테스트를 추가하거나, 가치 이동 함수의 커버리지가 알려지지 않은 경우.
  • 배포 스크립트를 연결할 때 — 키가 .env 평문이 아닌 암호화된 키스토어에 있는지 확인하기 위해.
  • 가격 오라클, 외부 호출, delegatecall 또는 업그레이드 가능한 프록시를 통합할 때.
  • Slither/Aderyn 보고서를 분류하고 실제 버그와 오탐지를 구분해야 할 때.

사전 요구 사항

  • Foundry 설치됨 (forge, cast, anvil): curl -L https://foundry.paradigm.xyz | bash && foundryup
  • Slither + solc: pip install slither-analyzer 및 solc-select install <ver> && solc-select use <ver>
  • Aderyn (권장): cargo install aderyn (또는 npm i -g @cyfrin/aderyn)
  • Mythril (선택 사항, 느린 심볼릭 실행): pip install mythril
  • gitleaks (키 유출 스캔): 동반 스킬 implementing-secret-scanning-with-gitleaks 참조
  • 컴파일되는 Foundry 프로젝트 (forge build 성공) — 분석기가 빌드 아티팩트를 필요로 함.
  • Solidity ^0.8.x 가정 (내장 오버플로 검사); 0.8 미만 컨트랙트는 추가 SafeMath 검토 필요.

Python 도구는 virtualenv에 설치하십시오 (외부 관리 배포판에서 권장). 절대 잠금 해제된 지갑이 있는 머신에서 신뢰할 수 없는 컨트랙트 소스에 대해 분석을 실행하지 마십시오.

단계

1단계: 프로젝트 빌드 및 정합성 확인

forge build                    # 분석기는 신선한 아티팩트 필요
forge fmt --check              # 스타일 게이트 (선택 사항)
cat foundry.toml               # solc 버전, 옵티마이저, 리매핑, evm_version 확인

2단계: 정적 분석 (빠름, 매번 실행)

# Slither — 전체 프로젝트 (foundry.toml + 리매핑 자동 사용)
slither . --json slither-report.json

# Aderyn — Cyfrin Rust 분석기, 보완 탐지기
aderyn . -o aderyn-report.json

또는 두 가지를 모두 실행하고 중복을 제거하며 결과를 게이트하는 번들 오케스트레이터 실행:

python3 scripts/agent.py --project . --output audit-report.json

3단계: 중요 컨트랙트에 대한 심볼릭 실행 (선택 사항, 느림)

# 가장 가치가 높은 컨트랙트에만 — Mythril은 경로 폭발적
myth analyze src/Vault.sol --solc-json mythril.config.json --execution-timeout 300 -o json
# 또는: python3 scripts/agent.py --project . --mythril src/Vault.sol

4단계: 속성 기반 테스트 — 퍼즈 + 불변

forge test -vvv                                  # 단위 + 퍼즈 테스트
forge coverage --report summary                  # 가치 이동 코드 커버리지
forge test --match-test invariant_ -vvv          # 불변 스위트 (핸들러 기반)

모든 가치 이동 컨트랙트는 핸들러가 있는 불변 테스트(제한된 입력, ghost 변수, targetContract(handler))를 가져야 합니다 — 단위 테스트만으로는 충분하지 않습니다. 핸들러 패턴은 references/api-reference.md를 참조하고, 각 접근 제어 가드에 대해 test_RevertWhen_* (vm.expectRevert 포함)를 작성하십시오.

5단계: 체크리스트에 따른 수동 검토

모든 컨트랙트에 대해 references/vulnerability-checklist.md를 검토: 재진입(checks-effects-interactions / nonReentrant), 접근 제어, 오라클 조작, delegatecall/프록시 스토리지 레이아웃, unchecked 반환 값, tx.origin, 약한 무작위성, DoS, 프론트러닝/MEV, ERC 특정 함정(approve 경쟁, 수수료 전송, 리베이싱).

6단계: 키 보안 및 안전한 배포

gitleaks detect --no-banner            # 개인 키 / 니모닉 / .env 커밋 금지
git ls-files | grep -E '\.env$|keystore' && echo "경고: git에 추적된 비밀"

# 배포 키를 암호화된 키스토어에 한 번 가져오기 — 절대 평문 PRIVATE_KEY env 사용 금지
cast wallet import deployer --interactive

# 키스토어 계정을 통해 배포 (먼저 테스트넷), --broadcast 전 시뮬레이션
forge script script/Deploy.s.sol --account deployer --rpc-url <testnet> --broadcast --verify

references/secure-deployment-and-keys.md에서 전체 강화 규칙 참조 (MetaMask 위생, 메인넷용 하드웨어 지갑, RPC 신뢰, 배포 후 검증).

7단계: 분류 및 보고

Slither + Aderyn + Mythril + 테스트 결과를 결합하고 (파일, 줄)별로 중복 제거, 확인된 오탐지 제거, 악용 가능성 × 재정적 영향으로 순위 매기고 각각을 SWC ID에 매핑합니다. 오케스트레이터는 PASS/FAIL 게이트가 포함된 audit-report.json을 생성합니다.

예상 출력

SWC 식별자, 심각도, 도구 출처, 영향을 받는 컨트랙트/함수/라인 및 수정 권장 사항이 포함된 JSON 감사 보고서; 테스트/커버리지 요약 및 단일 PASS / FAIL 배포 게이트. 높음/심각도 정적 분석 결과, 실패한 테스트, 유출된 비밀 또는 가치 이동 코드에 대한 구성된 임계값 미만의 커버리지에서 FAIL.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

관련 스킬