Value-centric methodology
The core principle: follow the money. Identify every component that can move funds and every path that leads to it.Inventory value-bearing components
Map out all components that hold or can move value:
- Multisig signers and their threshold configuration
- Oracle contracts and their update permissions
- Bridges and their validator sets
- Automation (Gelato, Chainlink Automation) and their trigger conditions
- Admin keys and timelock configurations
Map to adversarial tactics
Apply MITRE AADAPT tactics to each component:
- Who can call
withdraw(),mint(),upgradeProxy()? - Can flash loans amplify any of these?
- What happens if an oracle is stale or manipulated?
- Can a bridge validator set be corrupted?
Rehearse attack chains
Model end-to-end scenarios that chain multiple primitives:
- Flash loan → oracle manipulation → liquidation → profit
- Compromised signer key → proxy upgrade → drain treasury
- Malicious cross-chain message → mint tokens on destination chain
DeFi exploit patterns
Flash loan amplification
Flash loans allow borrowing arbitrary amounts within a single transaction at zero upfront cost. They amplify any vulnerability that depends on token balances:AMM precision abuse (Uniswap v4 hooks)
Uniswap v4 hooks allow custom logic before/after swaps. Precision and rounding vulnerabilities in hooks can be exploited:- Rounding direction: a hook that rounds fees in favour of the attacker on each swap can drain the pool over many micro-swaps
- Threshold crossing: a hook that triggers a large bonus when liquidity crosses a threshold can be triggered with a tiny swap that costs almost nothing but receives the full bonus
- Virtual balance poisoning: AMMs that cache virtual balances can be poisoned when
totalSupply == 0— the first depositor can set an arbitrary exchange rate
Oracle attacks
Signing workflow compromise
Wallet UIs present transaction data to users for signing. A compromised frontend can mutate the data before it is signed:EIP-712 payload tampering
delegatecall to the implementation — overwriting the masterCopy slot gives the attacker full control.
Mitigations:
- Verify transaction calldata on a trusted device before signing
- Use hardware wallets that display decoded calldata
- Check implementation addresses on-chain before approving upgrades
- Use timelocks on all admin actions to allow monitoring
Bridge attacks
Cross-chain bridges are among the highest-value targets in DeFi (billions lost to bridge hacks):| Attack vector | Example |
|---|---|
| Validator key compromise | Ronin bridge (Axie Infinity) — 5 of 9 validators compromised |
| Signature replay | Submit a message to the destination chain multiple times |
| Infinite mint | Forge a lock event on the source chain to mint on the destination |
| Logic bugs in message validation | Wormhole — verify_signatures could be bypassed |
Bridge testing checklist
- Message nonce/replay protection is enforced on the destination chain
- Validator threshold cannot be reduced to 1 by the bridge admin
- Lock events on the source chain are cryptographically committed before minting on the destination
- Emergency pause/veto mechanism exists and is controlled independently of the bridge admin
- No single key or contract can unilaterally drain the bridge
Key management attacks
Foundry fork testing for exploit development
Resources
- DeFiHackLabs: https://github.com/SunWeb3Sec/DeFiHackLabs — reproduced DeFi exploits in Foundry
- Rekt.news: https://rekt.news — post-mortems of major hacks
- Trail of Bits Smart Contract Guidelines: https://github.com/crytic/building-secure-contracts
- Consensys Diligence: https://consensys.io/diligence/blog