Balancer Hack

TOTAL LOST $524K
Low Flash Loan Attack ethereum

Summarize with AI

Affected Chain ethereum Incident surface
Recovered - No recovery reported
All-Time Rank #988 By amount stolen
Auditors 4 Prior security audits

Incident Overview

The transaction behind the attack:

https://etherscan.io/tx/0x013be977…c78106

The attacker's address:

https://etherscan.io/address/0xbf675c80…e7469a

The attacker:

- borrowed a flash loan (104,331 WETH) from dYdX

- performed multiple swapExactAmountIn() calls within the same transaction to drain the STA balance in the attacked Balancer pool. swapExactAmountIn() sets the limit on the swap amount, i.e., inRecord.balance * MAX_IN_RATIO. The attacker calculated the limit and swapped the maximum allowed amount of WETH for STA via a flurry of operations. The result of performing the above swaps is to intentionally left 1e-18 in the Balancer pool

- by sending in 1e-18 STA into BPool via swapExactAmountIn(), the attacker swapped out 30,347 WETH in the first run. In internal records for book-keeping, _records[STA] is increased by tokenAmountIn (i.e., 1) before the BPool contract actually collects the corresponding STA tokens from the msg.sender

- the _pullUnderlying() function collected the STA tokens. Note: STA is a deflationary token that charges shown 1% on every token transfer. Because of the transfer fee cut, the Balancer pool actually got zero STA tokens. Therefore, there’s a mismatch between the actual STA balance of BPool and its internal records (i.e., _records[STA])

- The gulp() is exploited to reset the _records[STA], which helps the attacker to maintain the state that BPool has only 1e-18 STA

- repaid the flash loan back to dYdX.

Incident Report

Protocol / Project Balancer
Date of Incident
Affected Chain(s) ethereum
Attack Technique Flash Loan Attack
Classification Exchange (DEX)

Protocol Information

Protocol Type Dexs
Affected Token BAL
Official Website balancer.fi/
Protocol Twitter/X @BalancerLabs
Team Anonymous
Source Code Unverified

Market Context at Time of Hack

Token Categories
Decentralized Exchange (DEX) Token DeFi DAO Ethereum Ecosystem Yield Farming AMM Three Arrows Capital Portfolio Governance

What the Attacker Needed to Succeed

Understanding the prerequisites for this type of attack helps auditors identify protocols that are most at risk and helps developers build better defenses.

Technical Knowledge Deep understanding of flash loan attack and Solidity and EVM internals
Capital Required Flash loan capital (borrowed atomically, zero upfront cost)
On-Chain Access Ability to interact with ethereum smart contracts and deploy a custom exploit contract
Protocol Analysis Identification of the exploitable vulnerability in Balancer's contract logic - root cause: exchange (dex)
Execution Speed Precise transaction ordering and timing to exploit the vulnerability within a single atomic block
Obfuscation Plan A strategy to launder and move stolen funds - typically through mixers, cross-chain bridges, or decentralized DEX swaps to resist tracing

What Auditors Should Check

Could this have been caught in audit? Yes — skilled auditors routinely flag Flash Loan Attack vulnerabilities in code review
Audited by OpenZeppelin, ConsenSys Diligence, Trail of Bits, DeFi Safety — still lost $524K. Prior audits don't guarantee safety, especially after post-audit code changes.

If you're auditing a protocol with similar architecture to Balancer, these are the critical security checks that could have prevented this incident (June 2020).

  • Verify all logic paths related to Flash Loan Attack are guarded by proper access controls and input validation - see the Flash Loans Attacks attack class for patterns
  • Review privileged functions (owner, admin, governance) for potential abuse vectors - centralization risks should be documented and bounded with timelocks or multi-sigs

Master these auditing techniques with hands-on labs and real exploit scenarios in the Smart Contract Hacking course.

Free Trial

Security Audit History

Related Attack Classes

The technique used in this hack maps to these vulnerability classes in our security curriculum:

See all Flash Loans Attacks examples →

Sources & References

Learn to Prevent the Next Balancer

The Balancer hack is one of many attacks that skilled auditors are trained to detect before deployment. Master real exploit patterns and defense techniques with hands-on Web3 security training.

Recreate exploit patterns safely Free Trial