web3-audit
它能做什么
这项技能教智能体如何审计智能合约中常见的 DeFi 漏洞。它涵盖 Solidity 和 Rust 合约,并包含帮助判断某个协议是否值得审查的检查项。
适用场景
- ✓当审计人员审查 Solidity 或 Rust 智能合约的 DeFi 风险的时候。
- ✓当猎人需要判断某个 DeFi 赏金目标是否值得花时间的时候。
- ✓当研究人员想用 Foundry 测试来证明某个疑似合约漏洞的时候。
技能链接
https://github.com/awarexone/Agentic-Bug-Hunter/blob/main/skills/web3-audit/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查这个借贷合约的同类函数是否缺少访问检查,并告诉我它是否值得深入审查。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会先对规模、过往审计和赏金价值进行快速检查,然后阅读合约,将每个函数与其同类函数进行比较,并检查十类漏洞。疑似漏洞会通过 Foundry 测试加以确认。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
WEB3 SMART CONTRACT AUDIT
10 bug classes. Pre-dive kill signals. Foundry PoC template. Real paid examples.
PRE-DIVE KILL SIGNALS (check BEFORE any code review)
ZKsync lesson: $322M TVL + OZ audit + 750K LOC + 5 sessions = 0 findings. Large well-audited bridges are extremely hard.
- TVL < $500K → max payout capped too low for effort
- 2+ top-tier audits (Halborn, ToB, Cyfrin, OpenZeppelin) on simple protocol → bugs already found
- Protocol < 500 lines, single A→B→C flow → minimal attack surface
- Formula:
max_realistic_payout = min(10% × TVL, program_cap)— if < $10K, skip
Soft kill: OZ/ToB/Cyfrin audit on current version + codebase > 500K LOC → expect 40+ hours for maybe 1 finding. Only proceed if bounty floor > $50K AND you have protocol-specific expertise.
Target scoring (go if >= 6/10):
- TVL > $10M: +2
- Immunefi program with Critical >= $50K: +2
- No top-tier audit on current version: +2
- < 30 days since deploy: +1
- Protocol you've hunted before: +1
- Source code + natspec comments: +1
- Upgradeable proxies: +1
THE ONE RULE
"Read ALL sibling functions. If
vote()has a modifier, checkpoke(),reset(),harvest(). The missing modifier on the sibling IS the bug."
This single rule explains 19% of all Critical findings.
1. ACCOUNTING STATE DESYNCHRONIZATION
#1 Critical bug class — 28% of all Criticals on Immunefi.
What It Is
Two state variables supposed to stay in sync. One code path updates A but forgets B. Later code reads both and makes decisions based on stale B.
Real Value = A - B
If A updated but B isn't → Real Value appears larger → phantom value
Root Cause Patterns
Variant 1: Phantom Yield (Yeet protocol — 35 duplicate reports)
function startUnstake(uint256 amount) external {
totalSupply -= amount; // decremented BEFORE transfer
// aToken.balanceOf(this) still reflects old value
// yieldAmount = aToken.balanceOf - totalSupply = phantom yield
}
Variant 2: Fast Path Skips State Update (Alchemix V3)
function claimRedemption(uint256 tokenId) external {
if (transmuter.balance >= amount) {
transmuter.transfer(user, amount);
_burn(tokenId);
return; // EARLY RETURN — cumulativeEarmarked, _redemptionWeight, totalDebt never updated
}
// Slow path: updates all state vars correctly
alchemist.redeem(...);
}
Variant 3: Update Happens in Wrong Order (Alchemix)
function deposit(uint256 amount) external {
_shares = (amount * totalShares) / totalAssets; // calculated BEFORE deposit
totalAssets += amount; // assets added AFTER shares calculated → wrong rate
}
Grep Patterns
# Find all accounting variables
grep -rn "totalSupply\|totalShares\|totalAssets\|totalDebt\|cumulativeReward\|rewardPerShare" contracts/
# Find all early returns in claim/redeem functions
grep -rn "\breturn\b" contracts/ -B3 | grep -B3 "if\b"
# For each early return: which state updates in normal path are skipped?
2. ACCESS CONTROL
#2 Critical — 19% of Criticals. $953M lost in 2024 alone.
Variant 1: Missing Modifier on Sibling Function
function vote(uint256 tokenId) external onlyNewEpoch(tokenId) { // guarded
function reset(uint256 tokenId) external onlyNewEpoch(tokenId) { // guarded
function poke(uint256 tokenId) external { // NO GUARD → infinite FLUX inflation
}
Variant 2: Wrong Check (Existence vs Ownership)
function split(uint256 tokenId, uint256 amount) external {
_requireOwned(tokenId); // checks if token EXISTS, not if caller OWNS it
_burn(tokenId);
_mint(msg.sender, amount); // attacker steals tokens they don't own
}
Variant 3: Silent Modifier (if vs require)
// VULNERABLE — non-admin silently gets through:
modifier onlyAdmin() {
if (msg.sender == admin) {
_; // body only executes for admin, but non-admin doesn't revert
}
}
// CORRECT: require(msg.sender == admin, "Not admin"); _;
Variant 4: Uninitialized Proxy
function initialize(address _owner) public { // MISSING: initializer modifier
owner = _owner; // anyone can call → become owner
}
// Fix: constructor() { _disableInitializers(); }
Grep Patterns
# Find sibling function families — do ALL have the same modifier set?
grep -rn "function vote\|function poke\|function reset\|function update\|
常见问题
最核心的规则是什么?
这项技能说明,应阅读所有同类函数,因为某个同类函数缺少修饰器往往就是漏洞所在。
什么是终止信号?
例如总锁仓价值低于 50 万美元,或某协议已被多家顶级机构审计过。
它涵盖哪些语言?
它涵盖 Solidity 和 Rust 智能合约。
详情
作者的原始描述
Smart contract security audit — 10 DeFi bug classes (accounting desync, access control, incomplete path, off-by-one, oracle, ERC4626, reentrancy, flash loan, signature replay, proxy), pre-dive kill signals (TVL < $500K etc), Foundry PoC template, grep patterns for each class, and real Immunefi paid examples. Use for any Solidity/Rust contract audit or when deciding whether a DeFi target is worth hunting.
热度
- GitHub 星标
- 5.5k
- 排名
- #14798
- 许可证
- MIT
- 更新时间
- 2026/10/28
评论
- …
同一仓库的更多技能
bug-bounty
5.5k帮你的智能体分阶段规划漏洞赏金审查,从检查项目范围、梳理资产,到测试线索、验证影响并撰写报告。
agentic-app-audit
5.5k帮你的智能体从外部审查正在运行的 AI 助手,检查其是否存在工具调用被劫持、记忆被投毒,以及以超出用户权限的方式执行操作等风险。
argus
5.5k帮你的智能体运行六种自动化扫描器,检查常见的 Web 和 AI 应用缺陷,例如开放的跨域访问、JWT 弱点,以及通过带外确认的盲注漏洞。
bb-methodology
5.5k帮你的智能体规划一次漏洞赏金测试会话,分阶段选择下一步和合适的检查,并舍弃无法造成真正危害的想法。