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.
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
- https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/AuctionEscapeHatch.sol#L100
- https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/AuctionEscapeHatch.sol#L174
- https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/Auction.sol#L527
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);
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
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.