Balancer Hack

TOTAL LOST $524K
Low Flash Loan Attacks ethereum

What happened

On June 28, 2020, an attacker used a dYdX flash loan to exploit Balancer V1 pools containing STA and STONK, ERC-20 tokens that charge a transfer fee. Balancer credited nominal input amounts in its internal reserve accounting even when the pool received less after the fee, allowing a reserve and price mismatch that drained the pools.

Case & protocol details

Classification Exchange (DEX) / Token & Share Accounting
Protocol Type DEX
Affected asset / contract BAL
Smart Contract Language Solidity
Official Website balancer.fi/
Protocol Twitter/X @BalancerLabs

Attack Timeline

The attacker flash-borrowed WETH and repeatedly swapped it for STA, progressively reducing the pool's actual STA balance. Balancer's internal accounting credited the nominal STA input before the token transfer completed, but STA's fee meant the pool received less than recorded. After calling gulp() to synchronize the internal record to the depleted on-chain balance, the attacker made the remaining STA appear extremely valuable and swapped it for other pool assets.

The flash loan made the sequence atomic, but the root cause was the accounting incompatibility with fee-on-transfer tokens.

Security review history

  • Trail of Bits 2020-03-05 No public report
  • ConsenSys Diligence 2020-05-15 No public report

Practice this exploit pattern safely

Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.