Banana Swap Hack
What happened
Banana Swap, a small DEX built for trading the DDC token on BNB Smart Chain, lost about $104,600-$110,105 in stablecoins on August 28, 2022. Security trackers call it the DDC exploit.
The DDC token contract exposed a handleDeductFee function that any caller could use. It did not validate the fee amount or the addresses involved, so an attacker could deduct almost the whole DDC balance of the Banana Swap liquidity pair. After a sync, the pool's DDC reserve was nearly zero and DDC became extremely expensive, so the attacker swapped about 23 DDC for the pool's stablecoin reserve.
**Block data**
- Attacker:
0x5b69f9c6cbb4958008eae46072886e6b9524fdef - Attack contract:
0x8aec5edbf6dae51da47b12c596effb9076fd7abb - Affected pair:
0x4efdcaba42cc31cf5198ec99bdc025aff1e32bb0 - Exploit tx:
0xd08cfb22d14bc4f2808970b5ce2557124ae3d7dc9fda756647a3427b8275f054
How it happened
- The attacker bought a small amount of DDC through the Banana Swap router (0.1 BNB routed via USDT in the public reproduction).
- It read the pair's DDC balance and called
handleDeductFeewith a fee amount equal to almost that balance, with the pair as thefromaddress and its own address as theuserargument. - Because
handleDeductFeechecked neither the amount nor the addresses, almost all of the pair's DDC was deducted from its balance. - The attacker called
syncon the pair so the reserves matched the drained DDC balance, pushing the DDC price up by orders of magnitude. - It sold about 23 DDC back to the pair for almost all of its stablecoin reserve.
Protocol details
Evidence
- report Report archive.is
- transaction bscscan.com transaction 0xd08c…f054 bscscan.com
- address bscscan.com address 0x2f09…ce2f bscscan.com
- address bscscan.com address 0x4efd…2bb0 bscscan.com
- address bscscan.com address 0x5b69…fdef bscscan.com
- address bscscan.com address 0x7aa5…65a4 bscscan.com
- address bscscan.com address 0x8672…c93c bscscan.com
- address bscscan.com address 0x8aec…7abb bscscan.com
- address bscscan.com address 0xe1a5…5d4d bscscan.com
- address bscscan.com address 0xe932…9b53 bscscan.com
- address bscscan.com address 0xf303…4c47 bscscan.com
- analysis DeFiHackLabs DDC_exp.sol (2022-08 PoC) raw.githubusercontent.com
- analysis DeFiHackLabs 2022 incident list (20220828 DDC - Unchecked External Calls) raw.githubusercontent.com
- analysis DDC Token Hack (ImmuneBytes) immunebytes.com
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.