Skip to content
Business logic Audit finding Intermediate

AuctionEschapeHatch.sol#exitEarly updates state of the auction wrongly

The exitEarly function in AuctionEscapeHatch.sol incorrectly updates auction state by subtracting the full amount from userCommitment but only a reduced maltQuantity from userMaltPurchased, causing the ratio of userMaltPurchased to userCommitment to increase after each profit-taking exit. This allows a user to claim more malt than entitled and to reduce profit penalties by splitting exits into multiple calls.

0x0x0x Follow

Originally disclosed on Code4rena

Submitted by 0x0x0x

AuctionEschapeHatch.sol#exitEarly takes as input amount to represent how much of the

When the user exits an auction with profit, to apply the profit penalty less maltQuantity is liquidated compared to how much malt token the liquidated amount corresponds to. The problem is auction.amendAccountParticipation() simply subtracts the malt quantity with penalty and full amount from users auction stats. This causes a major problem, since in _calculateMaltRequiredForExit those values are used for calculation by calculating maltQuantity as follow:

uint256 maltQuantity = userMaltPurchased.mul(amount).div(userCommitment);

The ratio of userMaltPurchased / userCommitment gets higher after each profit taking (since penalty is applied to substracted maltQuantity from userMaltPurchased), by doing so a user can earn more than it should. Since after each profit taking users commitment corresponds to proportionally more malt, the user can even reduce profit penalties by dividing exitEarly calls in several calls.

In other words, the ratio of userMaltPurchased / userCommitment gets higher after each profit taking and user can claim more malt with less commitment. Furthermore after all userMaltPurchased is claimed the user can have userCommitment left over, which can be used to claimArbitrage, when possible.

Mitigation Step

Make sure which values are used for what and update values which doesn’t create problems like this. Rethink about how to track values of an auction correctly.

0xScotch (sponsor) confirmed

Alex the Entreprenerd (judge) commented:

The warden has identified an exploit that allows early withdrawers to gain more rewards than expected. Anytime “points” and rewards need to be earned over time, it’s ideal to accrue points in order to distribute them (see how Compound or AAVE tokens work) Because the warden showed a flow in the accounting logic for the protocol, I agree with high severity.

The original report as published on Code4rena, by 0x0x0x. 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 exitEarly function updates userMaltPurchased and userCommitment inconsistently: it subtracts the full amount from userCommitment but only a reduced maltQuantity (after penalty) from userMaltPurchased, inflating the ratio used in later calculations.

Impact

A user could claim more malt than entitled and reduce profit penalties by splitting exits, potentially draining more rewards than intended.

What the attacker needed

Participate in an auction; exit early with profit

The fix

The accounting logic should be revised so that the values subtracted from userMaltPurchased and userCommitment are consistent and do not inflate the ratio used in exit calculations.

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.

When you join an auction, the system tracks how much you put in and how much malt you can get back. The bug is that when you exit early with a profit, the system reduces your malt balance by less than it should, but still reduces your commitment by the full amount. This makes it look like you have a better ratio of malt to commitment, so you can get more malt than you deserve, and you can repeat this to gain even more.

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.

More by 0x0x0x

View all

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

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.