Fei Protocol Vulnerability Bug Fix Review
A flaw in Fei Protocol's incentive mechanism allowed an attacker to buy FEI above the peg, receive a buy reward, then transfer FEI back to the Uniswap pool without triggering the sell penalty because the pool's reserves were not updated, and finally swap back to WETH for a riskless profit. This could have repeatedly drained about 1410 ETH from the WETH/FEI pool.
immunefi.com
Published on immunefi.com
On April 6, 0xRevert submitted a critical vulnerability as part of Fei Protocol’s bug bounty on Immunefi, which if exploited by a malicious user could have repeatedly drained ~1410 ETH from the WETH/FEI pool on Uniswap. Following the bug submission, Fei introduced a temporary mitigation that pauses minting of rewards…
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 sell penalty was calculated using the Uniswap pair's reserves, which are not updated on direct token transfers, so transfers that pushed the price below the peg were not penalised.
Impact
An attacker could make a riskless profit at the expense of Uniswap liquidity providers by collecting buy rewards and bypassing sell penalties, potentially draining ~1410 ETH repeatedly.
What the attacker needed
A large amount of WETH; FEI price below the peg
The fix
Fei Labs temporarily shut down all buy rewards and sell penalties and is working on a permanent fix.
How it was found
- Use UniswapV2Pair.swap to trade WETH for FEI, pushing the price above the peg and receiving a buy reward.
- Transfer FEI directly to the Uniswap pair (not via swap) to drip it back without triggering the burn penalty.
- Call UniswapV2Pair.swap again to convert FEI back to WETH, updating reserves and cashing out more WETH than initially spent.
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.
Fei Protocol is a stablecoin that tries to keep its price at 1 USD by giving rewards when people buy it below the peg and charging penalties when they sell below the peg. The bug was that the penalty check used outdated information about the pool's reserves, so an attacker could avoid the penalty and still collect the reward, making free money from the pool.
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.