GroupBuy: Lost ETH when the NFT is bought for less than the minimum reserve price
The purchase function allows an NFT to be bought for less than the minimum reserve price, but the claim function still deducts the full reserve price from each contributor's contribution, causing excess funds to be lost. An attacker could exploit this to make contributors lose their ETH when the NFT is bought at a discount.
Submitted by Lambda, also found by gzeon
The purchase function does not require that an NFT is bought for exactly minReservePrices[_poolId] * filledQuantities[_poolId], the price is only not allowed to be greater:
if (_price > minReservePrices[_poolId] * filledQuantities[_poolId])
revert InvalidPurchase();
This makes sense because it is not sensible to pay more when the purchase also succeeds with a smaller amount. However, the logic within claim does assume that the NFT was bought for minReservePrices[_poolId]. It decreases from contribution the quantity times the reserve price for all bids:
contribution -= quantity * reservePrice;
Only the remaining amount is reimbursed to the user, which can lead to a loss of funds.
Proof Of Concept
Let’s say that filledQuantities[_poolId] = 100 and minReservePrices[_poolId] (i.e., the lowest bid) was 1 ETH. However, it was possible to buy the NFT for only 50 ETH. When a user has contributed 20 * 1 ETH, he does not get anything back when calling claim, although only 10 ETH (0.5 ETH * 20) of his contributions were used to buy the NFT. The overall loss of funds for all contributors is 50 ETH.
Recommended Mitigation Steps
Set minReservePrices[_poolId] to _price / filledQuantities[_poolId] after a purchase.
stevennevins (Tessera) disagreed with severity and commented:
Not sure I agree with the severity. The mechanism is essentially users pre-state their X interest at Y quantity and so a user can never “pay” at a price greater than they essentially agreed to. We will look into ways to better handle the change and as it related to #19. I would mark this as Medium.
mehtaculous (Tessera) confirmed
Funds are considered lost if the NFT was bought at a discounted price, and cannot be recovered, right? Would keep at High severity if it’s the case.
stevennevins (Tessera) commented:
Yeah correct, confirmed.
stevennevins (Tessera) mitigated:
https://github.com/fractional-company/modular-fractional/pull/207
Status: Mitigation not confirmed. Full details in reports from gzeon and IllIllI. Also included in Mitigation Review section below.
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 claim function uses the original minimum reserve price instead of the actual purchase price when calculating each contributor's share.
Impact
Contributors could lose funds when the NFT is bought for less than the minimum reserve price, and the loss cannot be recovered.
What the attacker needed
A pool with filled quantities; NFT bought below reserve price
The fix
The minReservePrices should be updated to the actual price divided by filledQuantities after a purchase, as mitigated in a pull request.
How it was found
- Set filledQuantities and minReservePrices for a pool.
- Purchase the NFT for a price lower than minReservePrices * filledQuantities.
- Call claim as a contributor who contributed at the reserve price.
- Observe that the contributor receives no refund despite the lower purchase price.
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.
In a group buying system, people pool money to buy an NFT. The code lets the NFT be bought for less than the agreed minimum price, but when refunding, it still subtracts the full minimum price from each person's contribution, so they get less back than they should. This means some of their money is lost.
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.