auditing-foundry-smart-contract-security
Teaches your AI agent to protect apps against attacks and ship projects and manage infrastructure.
What it does
This tool checks the security of smart contracts written in Solidity before they are deployed. It uses various techniques to find common bugs like fund theft (reentrancy) or broken access control, ensuring the code is safe before going live on the network.
When to use it
- ✓Before deploying a contract to any network (testnet or mainnet).
- ✓When working on Foundry projects that handle value (money, tokens).
- ✓When setting up the deployment process to ensure secret keys are not exposed.
Example of what to ask your AI
“Check the security of this smart contract before deploying it to the mainnet.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The tool combines static code analysis, symbolic execution, and automated testing to simulate different scenarios. It also checks if secret keys are protected and not exposed in plain text.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill auditing-foundry-smart-contract-securityOr download just the file:
curl -L https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/main/skills/auditing-foundry-smart-contract-security/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Auditing Foundry Smart Contract Security
Overview
Deployed smart contracts are immutable and custody real funds, so a bug shipped to mainnet cannot be patched — it can only be exploited. Most catastrophic DeFi losses come from a small set of recurring classes: reentrancy, broken access control, oracle/price manipulation, and unchecked arithmetic or external calls.
This skill runs a defense-in-depth, pre-deployment audit of a Foundry project, layering four independent techniques that each catch what the others miss:
- Static analysis —
slither(90+ detectors) andaderyn(Cyfrin, Rust) scan the AST/IR in seconds for known anti-patterns. - Symbolic execution —
mythril(optional, slow) explores execution paths and SMT-solves for deep arithmetic/reentrancy bugs. - Property-based testing —
forge testwith fuzzing (testFuzz_*) and invariant tests (invariant_*+ handler contracts with ghost variables) proves protocol-level properties hold across millions of random sequences. - Manual review + key hygiene — a structured checklist (see
references/vulnerability-checklist.md) and a secrets/keystore audit so no private key ever lives in plaintext and deployment goes through an encryptedcastkeystore (seereferences/secure-deployment-and-keys.md).
The skill is dev-side and pre-deployment — it is run by the engineer building the contract, not by a SOC after an incident. Findings gate the deploy: any high/critical static finding, failing test, leaked key, or low coverage = FAIL.
When to Use
- Before deploying any Solidity contract to a testnet or mainnet EVM chain.
- When writing or reviewing a Foundry project (
foundry.toml,src/,test/,script/). - When a contract handles value: tokens (ERC-20/721/1155), vaults, staking, AMMs, bridges, governance.
- When adding fuzz or invariant tests, or when coverage of value-moving functions is unknown.
- When wiring deployment scripts — to verify keys are in an encrypted keystore, not
.envplaintext. - When integrating a price oracle, external call,
delegatecall, or upgradeable proxy. - When triaging a Slither/Aderyn report and needing to separate real bugs from false positives.
Prerequisites
- Foundry installed (
forge,cast,anvil):curl -L https://foundry.paradigm.xyz | bash && foundryup - Slither + solc:
pip install slither-analyzerandsolc-select install <ver> && solc-select use <ver> - Aderyn (recommended):
cargo install aderyn(ornpm i -g @cyfrin/aderyn) - Mythril (optional, slow symbolic exec):
pip install mythril - gitleaks (key-leak scan): see the companion
implementing-secret-scanning-with-gitleaksskill - A Foundry project that compiles (
forge buildsucceeds) — analyzers need build artifacts. - Solidity ^0.8.x is assumed (built-in overflow checks); pre-0.8 contracts need extra SafeMath review.
Install the Python tools in a virtualenv (recommended on externally-managed distros). Never run analysis against untrusted contract source on a machine with funded wallets unlocked.
Steps
Step 1: Build and sanity-check the project
forge build # analyzers require fresh artifacts
forge fmt --check # style gate (optional)
cat foundry.toml # note solc version, optimizer, remappings, evm_version
Step 2: Static analysis (fast, run every time)
# Slither — full project (uses foundry.toml + remappings automatically)
slither . --json slither-report.json
# Aderyn — Cyfrin Rust analyzer, complementary detectors
aderyn . -o aderyn-report.json
Or run the bundled orchestrator that runs both, deduplicates, and gates the result:
python3 scripts/agent.py --project . --output audit-report.json
Step 3: Symbolic execution on critical contracts (optional, slow)
# Only on the highest-value contract(s) — Mythril is path-explosive
myth analyze src/Vault.sol --solc-json mythril.config.json --execution-timeout 300 -o json
# or: python3 scripts/agent.py --project . --mythril src/Vault.sol
Step 4: Property-based testing — fuzz + invariants
forge test -vvv # unit + fuzz tests
forge coverage --report summary # coverage of value-moving code
forge test --match-test invariant_ -vvv # invariant suite (handler-based)
…
FAQ
What are smart contracts?
They are programs that run on a blockchain. They automatically execute actions when certain conditions are met, like transferring money or tokens.
Why is security important before deployment?
Once a contract is deployed on the blockchain, it usually cannot be changed. If there's a bug, it can be exploited by hackers, leading to loss of funds.
What is Foundry?
Foundry is a toolkit for developers building smart contracts on Ethereum. It helps in writing, testing, and deploying these contracts.
Details
Original description by the author
Pre-deployment security audit of Solidity smart contracts in a Foundry project. Combines static analysis (Slither, Aderyn), symbolic execution (Mythril), and property-based testing (forge fuzz + invariant tests with handlers) to catch reentrancy, access-control, oracle/price manipulation, and arithmetic bugs BEFORE deploying to an EVM chain. Also enforces key hygiene (no plaintext private keys, en
Popularity
- GitHub stars
- 35k
- Ranking position
- #5516
- License
- Apache-2.0
- Updated
- 8/31/2026
Comments
- …
More skills from this repository
abusing-dpapi-for-credential-access
Gives your AI agent ready-made instructions for a specific task, so it does it better and faster.
mukul975/Anthropic-Cybersecurity-Skills
abusing-shadow-credentials-for-privesc
Teaches your AI agent to write clear, well-structured text.
mukul975/Anthropic-Cybersecurity-Skills
achieving-cmmc-level-2-compliance
Helps your agent prepare an environment for CMMC Level 2 compliance. It implements security requirements and manages necessary documentation.
mukul975/Anthropic-Cybersecurity-Skills
acquiring-disk-image-with-dd-and-dcfldd
Helps your agent create exact copies of hard drives. This is useful for ensuring no information is lost or altered during investigations.
mukul975/Anthropic-Cybersecurity-Skills
Similar skills
django-security
Helps your agent implement security practices in Django applications. It focuses on authentication, authorization, and prevention against common attacks, ensuring more secure code.
affaan-m/ECC
laravel-security
Helps your agent secure Laravel applications against threats. Implements security practices for authentication, authorization, and common attack prevention.
affaan-m/ECC
module-regression
Helps your agent manage changes in large projects. Ensures code changes in one part don't break other parts.
affaan-m/ECC