搜索与研究
web3-methodology-research
External research synthesis from Trail of Bits, SlowMist, ConsenSys, Immunefi, and Cyfrin. Use this for advanced audit methodology, Echidna/Medusa fuzzing setup, Slither custom detector writing, attack pattern deep dives, or the 4-phase learning roadmap.
Awarexone · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Awarexone/web3-bug-bounty-hunting-ai-skills --skill web3-methodology-research技能说明
name: web3-methodology-research description: External research synthesis from Trail of Bits, SlowMist, ConsenSys, Immunefi, and Cyfrin. Use this for advanced audit methodology, Echidna/Medusa fuzzing setup, Slither custom detector writing, attack pattern deep dives, or the 4-phase learning roadmap.
METHODOLOGY & RESEARCH SYNTHESIS
Sources: Trail of Bits, SlowMist, ConsenSys, Immunefi Web3 Security Library, Cyfrin Audit Course, Lido Audits Library, Nethermind PublicAuditReports.
TRAIL OF BITS
Their Toolset
| Tool | What It Does | When to Use |
|---|---|---|
| Slither | Static analysis for Solidity/Vyper | Always — run first |
| Echidna | Property-based fuzzer (write invariants, it breaks them) | Write 3-5 invariants before reading code |
| Medusa | Next-gen fuzzer, multi-core, parallel corpus | Deeper campaigns after Echidna |
| Manticore | Symbolic execution — confirms if a path is truly reachable | Specific PoC confirmation |
| Halmos | Symbolic unit testing — proves for ALL inputs | Math-heavy functions |
Slither Commands
# Install
pip3 install slither-analyzer
# First pass — protocol overview
slither . --print human-summary
slither . --print contract-summary
# Targeted detectors
slither . --detect reentrancy-eth,reentrancy-no-eth,unchecked-lowlevel
slither . --detect arbitrary-send-erc20,controlled-delegatecall
slither . --detect uninitialized-state,uninitialized-storage
slither . --detect suicidal,controlled-array-length
# Visualization
slither . --print inheritance-graph
slither . --print function-summary
slither . --print call-graph
# Filtered run (skip tests and libs)
slither . --exclude-low --filter-paths "test|lib"
Echidna Quick Start
// Write invariants BEFORE fully reading the code
contract VaultInvariants {
Vault vault;
// Protocol should never owe more than it holds
function echidna_solvency() public view returns (bool) {
return vault.totalAssets() >= vault.totalDebt();
}
// Share math must be consistent
function echidna_share_math() public view returns (bool) {
return vault.balanceOf(address(this)) <= vault.totalSupply();
}
// cumulativeRewardPerShare only ever increases
function echidna_reward_monotonic() public view returns (bool) {
return vault.cumulativeRewardPerShare() >= lastRewardPerShare;
}
}
echidna contracts/VaultInvariants.sol --contract VaultInvariants --test-mode assertion
# With config
echidna Test.sol --contract EchidnaTest --config echidna.yaml
# echidna.yaml
testLimit: 50000
seqLen: 100
workers: 4
corpusDir: corpus/
Medusa Setup
# Install
# github.com/crytic/medusa
go install github.com/crytic/medusa@latest
# Run (coverage-guided, multi-core)
medusa fuzz --config medusa.json
# medusa.json
{
"fuzzing": {
"workers": 4,
"testLimit": 500000,
"corpusDirectory": "corpus"
}
}
Medusa vs Echidna: Medusa is faster on large contracts due to coverage-guided exploration. Use Echidna for first pass, Medusa for extended campaigns.
Trail of Bits Audit Methodology
1. THREAT MODEL FIRST
- What are the assets? (tokens, governance power, user funds)
- What are the trust boundaries? (who can call what?)
- What are the attack surfaces? (entry points, external calls)
2. STATIC ANALYSIS
- Run Slither with all detectors
- Examine SlithIR output for complex functions
- Map ALL state variables and who can write them
3. WRITE INVARIANTS BEFORE READING EVERYTHING
- "totalAssets >= totalDebt always"
- "shares * pricePerShare == underlying always"
- "user can always withdraw their full deposit"
- Run Echidna. Watch it break them.
4. SYMBOLIC EXECUTION ON HIGH-VALUE PATHS
- Use Manticore/Halmos for precise reachability confirmation
- Confirms "can an attacker actually reach state X?"
5. MANUAL REVIEW — FOCUS ON
- Business logic (not syntax — Slither caught that)
- Economic invariants (is the math right under adversarial conditions?)
- Access control (who can call what, when, with what params?)
6. DIFFERENTIAL TESTING
- Compare against reference implementation
- "Function A does X. Function B does the same thing differently. Why?"
- The inconsistency IS the bug.
Key Bug Classes From Real ToB Audits
EVM / Solidity:
REENTRANCY VARIANTS (still common)
- Cross-function: lock in depositA, reenter via depositB before state update
- Cross-contract: callback to attacker contract via safeTransfer
- Read-only: view function reads stale state during reentrant call
(Curve $70M — most underestimated variant)
ROUNDING ERRORS
- Division before multiplication: (a / b) * c vs (a * c) / b
- Wrong rounding direction (should round up for safety, rounds down)
- Precision loss in sequential operations
WEAK FIAT-SHAMIR (ZK SYSTEMS — ToB IEEE S&P 2023)
- ZK proof prover can forge proofs if transcript not fully committed
- Missing: challenge must bind all public inputs
- Check: is the verifier challenge a hash of EVERYTHING the prover touches?
ACCESS CONTROL GAPS
- Function A has onlyOwner → sibling function B does NOT
- Emergency functions callable by non-emergency roles
- Initializer called after deployment without restrictions
UNSAFE UPGRADES
- Storage slot collision between proxy and implementation
- Uninitialized implementation contract (selfdestruct vector)
- delegatecall to address from storage (attacker controls target)
SIGNATURE REPLAY
- Missing nonce in signed message
- Missing chainId in signed message
- Missing contract address in signed message
DeFi-Specific (from Uniswap, Frax, Reserve Protocol, Scroll audits):
LIQUIDITY MATH EDGE CASES
- Integer overflow at extreme tick values (Uniswap V3 type)
- Rounding direction matters at boundary
ORACLE MANIPULATION
- TWAP too short → manipulable in same block
- Spot price used directly → 1
阅读完整来源 ↗