All vulnerabilities
CRITICALWeb3exploited in the wild

WEB3-PANCAKEBUNNY-2021

Web3 · BNB Chain · PancakeBunny

Summary

On 20 May 2021 PancakeBunny, a yield aggregator on BNB Chain, was drained of roughly $45 million (about 114,000 WBNB plus around 3.8M USDT) in a flash-loan mint-manipulation attack that crashed the BUNNY token by over 95%. The protocol's reward minting valued assets through a price calculator that read the spot reserves (getReserves) of the BUNNY/WBNB and USDT/WBNB PancakeSwap pairs, and computed LP amounts with raw balanceOf() that could be inflated by direct transfers. The attacker took recursive flash loans of millions of WBNB, swapped WBNB for USDT to cheapen WBNB and skew both pools, then triggered the deposit/reward path so the manipulated price fed the BUNNY mint formula (amplified by a multiplier) and minted roughly 6.9 million BUNNY from nothing, which they immediately dumped into the inflated pool for WBNB and USDT. The root cause was computing mint amounts from manipulable on-chain spot reserves and unguarded balanceOf() rather than an external price.

How to avoid it in your code

  • Never derive mint or reward amounts from a pool's getReserves()/balanceOf() spot price; use an external oracle
  • Adopt Chainlink or a long-window TWAP for asset valuation in minting math
  • Do not trust balanceOf() deltas for LP accounting; track amounts internally so direct transfers cannot inflate them
  • Cap or rate-limit mint output per transaction and reject when computed value diverges from a reference price
  • Assume flash loans can skew any single-pool price within the call; block atomic deposit-then-mint-then-dump flows

References

Related vulnerabilities

All Web3 →