Skip to content
Business logic Write-up Advanced

Fei Protocol Flashloan Vulnerability Bug Fix Review

Anyone could call the allocate function, which deposited protocol-controlled ETH into the Uniswap ETH/FEI pool at the prevailing market rate with 100% slippage tolerance, and the nonContract guard could be bypassed by calling from a contract constructor. An attacker could use a flash loan to distort the pool, buy FEI cheaply on the bonding curve, trigger allocate, and swap back to drain up to 60,000 ETH of protocol funds.

immunefi.com

Published on immunefi.com

Whitehat Alexander Schlindwein, known for receiving the largest ever bug bounty payout after finding a critical bug in ArmorFi, discovered a critical vulnerability in Fei Protocol. Concurrently and independently, Fei Protocol’s expert security team, led by Joey Santoro, also discovered this bug and immediately paused…

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

Likely the allocate function deposited protocol ETH into the Uniswap pool at the manipulated market rate with 100% slippage tolerance, and its nonContract guard was bypassable from a constructor.

Impact

If exploited, the attack could have drained up to 60,000 ETH, limited by the roughly 1m ETH available for flash loans across the ecosystem; it was not exploited and no funds were lost.

What the attacker needed

Flash loan of WETH available; ability to deploy a contract; allocate callable (not paused)

The fix

The protocol was fixed by no longer supplying bonding-curve ETH to the Uniswap pool and by setting a configurable slippage relative to the ETH/USD oracle on addLiquidityETH, so distorted deposits revert.

How it was found

  1. Take a flash loan in WETH.
  2. Dump the borrowed ETH into the Uniswap ETH/FEI pool to distort the price.
  3. Buy FEI on the bonding curve at the protocol price.
  4. Deploy a dummy contract that calls allocate from its constructor to bypass the nonContract check.
  5. Swap the bought FEI back into the pool to recover the ETH plus profit.
  6. Repay the flash loan.

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.

A flash loan is a loan that must be borrowed and repaid within one transaction, so no collateral is needed. The protocol let anyone move its own ETH into a trading pool at whatever price the pool currently showed, and a guard meant to stop contracts from doing this could be dodged by calling from inside a contract's setup code. By first pushing the pool price far off, an attacker made the protocol deposit too much ETH, then traded back to keep the difference.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.