Skip to content
Smart contracts Audit finding Intermediate

getAuctionCore function returns wrong values out of order

The getAuctionCore function returns ten values, but two functions in AuctionEscapeHatch.sol unpack them with a missing comma, so the 'active' flag is read from the wrong position. This causes early exit functions to use incorrect values, potentially leading to loss of user funds.

jayjonah8 Follow

Originally disclosed on Code4rena

Submitted by jayjonah8

Impact

In the AuctionEscapeHatch.sol file both earlyExitReturn() and \_calculateMaltRequiredForExit call the getAuctionCore() function which has 10 possible return values most of which are not used. It gets the wrong value back for the “active” variable since it’s the 10th argument but both functions have it as the 9th return value where “preAuctionReserveRatio” should be because of one missing comma. This is serious because these both are functions which deal with allowing a user to exit their arbitrage token position early. This can result in a loss of user funds.

Proof of Concept

Tools Used

Manual code review

Recommended Mitigation Steps

In AuctionEscapeHatch.sol change the following in \_calculateMaltRequiredForExit() and earlyExitReturn() functions:

From:

(,,,,, uint256 pegPrice, , uint256 auctionEndTime, bool active ) = auction.getAuctionCore(_auctionId);

To:

(,,,,, uint256 pegPrice, , uint256 auctionEndTime, , bool active ) = auction.getAuctionCore(_auctionId);

0xScotch (sponsor) confirmed

Alex the Entreprenerd (judge) commented:

The warden identified a mistake in programming where the code would use the wrong returned value. Because of this, the entire protocol functionality can be compromised. As such I agree with High Severity

The original report as published on Code4rena, by jayjonah8. 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 a missing comma in the tuple assignment when calling getAuctionCore, causing the 'active' boolean to be assigned from the wrong return position.

Impact

This could result in a loss of user funds because the early exit functions may behave incorrectly.

What the attacker needed

None

The fix

The fix is to add the missing comma in the tuple assignment so that 'active' is read from the correct position.

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.

Smart contracts often return multiple values at once. If you list the variables you want to receive them in the wrong order, you get the wrong data. Here, a missing comma meant the code thought it was reading one value but actually read another, so a safety check could be wrong.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by jayjonah8

View all

18 more disclosed reports, best first.

More from Malt Protocol - Versus contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.