Skip to content
DoS Write-up Advanced

Balancer Dos Bug Fix Review

A flaw in Balancer's flash loan logic allowed an attacker to drain a double entry-point token from the Vault by treating the repayment as excess fees, causing a denial of service for swaps and pool exits. No user funds were at risk because the fees were sent to a governance-controlled contract.

immunefi.com

Published on immunefi.com

On May 14th, ChainSecurity employee @kbesic reported a vulnerability classified as “Medium” in Balancer protocol. The vulnerability consisted of a potentially exploitable Denial of Service (DoS) scenario by emptying double entry-point ERC-20 tokens through Balancer’s flash loans.

The author, on immunefi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The flash loan function did not account for double entry-point tokens, so when the same token was borrowed via both its proxy and target contracts, the repayment was misinterpreted as excess balance and taken as a fee.

Impact

The Vault could be drained of a double entry-point token, causing swaps and pool exits to fail (denial of service), but no user funds were at risk because the tokens went to a governance-controlled contract.

What the attacker needed

A double entry-point token in a Balancer pool; ability to deploy and call a smart contract; no special privileges required

How it was found

  1. Define the two entry points (target and proxy contracts) for a double entry-point token such as sBTC.
  2. Deploy an exploit contract that implements the flash loan interface and the receiveFlashLoan callback.
  3. Call the flash loan with the first entry point for the full Vault balance and the second entry point with zero balance.
  4. The first loop records the full balance for the first entry point and zero for the second.
  5. The second loop sees the second entry point's balance jump from zero to full, treating the difference as a fee.
  6. The fee is sent to ProtocolFeesCollector, draining the Vault and causing a denial of service.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Balancer is a decentralised exchange where people pool tokens for others to trade. A flash loan lets someone borrow tokens for a single transaction, as long as they return them in the same transaction. The bug let an attacker make the system think a loan repayment was extra fees, so the tokens were moved out of the trading pool, breaking trades.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.