Skip to content
Audit finding Advanced

_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.

leastwood Follow

Originally disclosed on Code4rena

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

Recommended Mitigation Steps

Consider implementing/integrating a TWAP oracle to track the price of Malt.

0xScotch (sponsor) confirmed

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

The original report as published on Code4rena, by leastwood. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by leastwood

View all

70 more disclosed reports, best first.

More from Malt Protocol - Versus contest

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.