|
|
||
|---|---|---|
| .github | ||
| academy | ||
| lib | ||
| past | ||
| script | ||
| src | ||
| .gitignore | ||
| .gitmodules | ||
| .prettierrc | ||
| add_new_entry.py | ||
| AudiusPocGasReport.gif | ||
| CONTRIBUTING.md | ||
| foundry.lock | ||
| foundry.toml | ||
| README.md | ||
| remappings.txt | ||
| requirements.txt | ||
| test.py | ||
DeFi Hacks Reproduce - Foundry
Reproduce DeFi hack incidents using Foundry.
681 incidents included.
Let's make Web3 secure! Join Discord
Notion: 101 root cause analysis of past DeFi hacked incidents
Disclaimer: This content serves solely as a proof of concept showcasing past DeFi hacking incidents. It is strictly intended for educational purposes and should not be interpreted as encouraging or endorsing any form of illegal activities or actual hacking attempts. The provided information is for informational and learning purposes only, and any actions taken based on this content are solely the responsibility of the individual. The usage of this information should adhere to applicable laws, regulations, and ethical standards.
Table of Contents
- Getting Started
- Who Support Us
- Donate Us
- List of Past DeFi Incidents
- Transaction debugging tools
- Ethereum Signature Database
- Useful tools
- Hacks Dashboard
- List of DeFi Hacks & POCs
Getting Started
-
Follow the instructions to install Foundry.
-
Clone and install dependencies:
git submodule update --init --recursive
Web3 Cybersecurity Academy
All articles are also published on Substack.
OnChain transaction debugging
- Lesson 1: Tools ( English | 中文 | Vietnamese | Korean | Spanish | 日本語 )
- Lesson 2: Warm up ( English | 中文 | Korean | Spanish | 日本語 )
- Lesson 3: Write Your Own PoC (Price Oracle Manipulation) ( English | 中文 | Korean | Spanish | 日本語 )
- Lesson 4: Write Your Own PoC (MEV Bot) ( English | 中文 | Korean | Spanish | 日本語 )
- Lesson 5: Rugpull Analysis ( English | 中文 | Spanish | 日本語 )
- Lesson 6: Write Your Own PoC (Reentrancy) ( English | 中文 | Spanish | 日本語 )
- Lesson 7: Hack Analysis: Nomad Bridge, August 2022 ( English | 中文 | Spanish | 日本語 )
Donate us
If you appreciate our work, please consider donating. Even a small amount helps us continue developing and improving our projects, and promoting web3 security.
- Gitcoin - Donate DeFiHackLabs
- EVM Chains - 0xD7d6215b4EF4b9B5f40baea48F41047Eb67a11D5
- Giveth
List of Past DeFi Incidents
2024
20240703 UnverifiedContr_0x452E25
20240610 UwuLend - Price Manipulation
2023
20231201 UnverifiedContr_0x431abb
20230715 USDTStakingContract28
2022
20221024 MulticallWithoutCheck
20221011 Rabby Wallet SwapRouter
20220908 Ragnarok Online Invasion
20220701 Quixotic - Optimism NFT Marketplace
20220624 Harmony's Horizon Bridge
20220608 Optimism - Wintermute
20220430 Rari Capital/Fei Protocol
2021
Before 2020
Transaction debugging tools
Phalcon | Tx tracer | Cruise | Ethtx | Tenderly | eigenphi
Ethereum Signature Database
Useful tools
ABI to interface | Get ABI for unverified contracts | ETH Calldata Decoder | ETHCMD - Guess ABI | Abi tools
Hacks Dashboard
Slowmist | Defillama | De.Fi | Rekt | Cryptosec | BlockSec
List of DeFi Hacks & POCs
20260120 SynapLogic - Business Logic Flaw
Lost: 27.6 ETH
BASE_ENDPOINT=XXX forge test -vvv --contracts ./src/test/2026-01/SynapLogic_exp.sol
Contract
Link reference
https://x.com/TenArmorAlert/status/2013432861366292520?s=20 https://x.com/hklst4r/status/2013440353844461979?s=20 https://x.com/CertiKAlert/status/2013440963851755610?s=20 https://x.com/nn0b0dyyy/status/2013445844394279260?s=20
20260120 Makina - Price Oracle Manipulation
Lost: 5.1M USD
forge test -vvv --contracts ./src/test/2026-01/makina_exp.sol
Contract
Link reference
https://x.com/nn0b0dyyy/status/2013472538832314630 https://x.com/TenArmorAlert/status/2013460083078836342 https://x.com/CertiKAlert/status/2013473512116363734
20260112 MTToken - Incorrect Fee Logic
Lost: 37K USD
forge test -vvv --contracts ./src/test/2026-01/MTToken_exp.sol
Contract
Link reference
https://x.com/TenArmorAlert/status/2010630024274010460?s=20 https://x.com/nn0b0dyyy/status/2010638145155661942?s=20
20260110 FutureSwap - Unit Mismatch
Lost: 433K USD
forge test -vvv --contracts ./src/test/2026-01/futureswap_exp.sol.sol
Contract
Link reference
https://x.com/nn0b0dyyy/status/2009922304927731717?s=20
20260109 Truebit - OverFlow
Lost: 8540ETH
forge test --contracts ./src/test/2026-01/Truebit_exp.sol -vvv
Contract
Link reference
https://www.certik.com/zh-CN/resources/blog/truebit-incident-analysis
20260101 PRXVT - Bussiness Logic Flaw
Lost: 32.8 ETH
forge test --contracts ./src/test/2026-01/PRXVT_exp.sol -vvv --block-gas-limit 60000000 # use gas limit control iterations
Contract
Link reference
https://x.com/CertiKAlert/status/2006685174587605315
View Gas Reports
Foundry also has the ability to report the gas used per function call which mimics the behavior of hardhat-gas-reporter. Generally speaking if gas costs per function call is very high, then the likelihood of its success is reduced. Gas optimization is an important activity done by smart contract developers.
Every poc in this repository can produce a gas report like this:
forge test --gas-report --contracts <contract> -vvv
For Example: Let us find out the gas used in the Audius poc
Execution
forge test --gas-report --contracts ./src/test/Audius.exp.sol -vvv
Demo
Bug Reproduce
Moved to DeFiVulnLabs
FlashLoan Testing
Moved to DeFiLabs
