_calculateMaltRequiredForExit Uses Spot Price To Calculate Malt Quantity In exitEarly
The exit-early function in the AuctionEscapeHatch contract calculates how much Malt to return to a user using the token's spot price from a Uniswap pool. Because that spot price follows pool reserves, an attacker could manipulate it with a flash loan to extract funds from the protocol.
Submitted by leastwood
_calculateMaltRequiredForExit in AuctionEscapeHatch currently uses Malt’s spot price to calculate the quantity to return to the exiting user. This spot price simply tracks the Uniswap pool’s reserves which can easily be manipulated via a flash loan attack to extract funds from the protocol.
Proof of Concept
- https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/AuctionEscapeHatch.sol#L65-L92
- https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/AuctionEscapeHatch.sol#L193
- https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/DexHandlers/UniswapHandler.sol#L80-L109
- https://shouldiusespotpriceasmyoracle.com/
Recommended Mitigation Steps
Consider implementing/integrating a TWAP oracle to track the price of Malt.
Alex the Entreprenerd (judge) commented:
I feel like this issue highlights the design challenge that the sponsor will have to solve, on one hand the protocol is meant to stabilize the price of malt in specific pools (impossible to block / control every pool due to permissionless nature). At the same time in order to determine which direction to move the price to, they need to refer to the pricing of the underlying pools (in this case a UniV2Pool, most likely from QuickSwap)
Personally I understand the finding and think it’s valid, however I don’t believe there’s easy answers as to how the sponsor should address this.
Whenever there’s excess value there will be entities trying to seize it and perhaps through such a harsh environment this protocol can truly find a way to be sustainable.
That said, I’ll mark the finding as valid, but believe this specific issue underlines the challenges that await the sponsor in making the protocol succesful
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the contract derives the amount owed on exit from a manipulable Uniswap spot price rather than a time-weighted average price.
Impact
An attacker could manipulate the pool price via a flash loan to extract funds from the protocol, though the judge notes there are no easy answers for the sponsor.
What the attacker needed
Ability to flash loan a large amount; exit-early function reachable
The fix
A time-weighted average price oracle should be implemented or integrated to track the price of Malt.
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 report has not been written yet. The Original tab links to the source.
A spot price is just the current ratio of two tokens in a trading pool, and it can be pushed around within a single transaction by borrowing a large amount of money temporarily (a flash loan). If a contract trusts that price when deciding how much to pay out, someone can nudge the price and take more than they should.