Skip to content
Business logic Audit finding Intermediate

AuctionParticipant.sol: purchaseArbitrageTokens should not push duplicate auctions

The purchaseArbitrageTokens function appends the current auction ID to an array every time it is called, so calling it multiple times for the same auction creates duplicate entries. This can cause the claim function to mishandle the replenishingIndex, potentially preventing participants from claiming rewards without manual intervention.

harleythedog Follow

Originally disclosed on Code4rena

Submitted by harleythedog

In AuctionParticpant.sol, every time purchaseArbitrageTokens is called, the current auction is pushed to auctionIds. If this function were to be called on the same auction multiple times, then the same auction id would be pushed multiple times into this array, and the claim function would have issues with replenishingIndex.

Specifically, even if replenishingIndex was incremented once in claim, it is still possible that the auction at the next index will never reward any more tokens to the participant, so the contract would need manual intervention to set replenishingIndex (due to the if statement on lines 79-82 that does nothing if there is no claimable yield).

It is likely that purchaseArbitrageTokens would be called multiple times on the same auction. In fact, the commented out code for handleDeficit (in ImpliedCollateralService.sol) even suggests that the purchases might happen within the same transaction. So this issue will likely be an issue on most auctions and would require manual setting of replenishingIndex.

NOTE: This is a separate issue from the one I just submitted previously relating to replenishingIndex. The previous issue was related to an edge case where replenishingIndex might need to be incremented by one if there are never going to be more claims, while this issue is due to duplicate auction ids.

Proof of Concept

See code for purchaseArbitrageTokens here: https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/AuctionParticipant.sol#L40

Notice that currentAuction is always appended to auctionIds.

Recommended Mitigation Steps

Add a check to the function to purchaseArbitrageTokens to ensure that duplicate ids are not added. For example, this can be achieved by changing auctionIds to a mapping instead of an array.

0xScotch (sponsor) confirmed

Alex the Entreprenerd (judge) commented:

I agree with the finding, adding the same auctionId can lead to undefined behaviour. This can break claiming of incentives. Because of that, I think medium severity to be appropriate

The original report as published on Code4rena, by harleythedog. 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

The function unconditionally appends the current auction ID to an array without checking for duplicates, so repeated calls for the same auction create multiple entries.

Impact

Duplicate auction IDs can cause the claim function to mishandle the replenishingIndex, potentially blocking reward claims and requiring manual intervention to fix.

What the attacker needed

PurchaseArbitrageTokens called multiple times for same…

The fix

The function should be modified to prevent duplicate auction IDs, for example by using a mapping instead of an array.

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 smart contract keeps a list of auctions a user has joined. Each time the user buys tokens for an auction, the contract adds that auction's ID to the list again, even if it is already there. Later, when the user tries to claim rewards, the contract gets confused by the repeated entries and may stop giving out rewards correctly.

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 harleythedog

View all

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