GroupBuys that are completely filled still don’t raise stated target amount
The minimum bid price for a GroupBuy pool is calculated by dividing the initial price by the total supply, which rounds down. When all Raes are minted at this minimum price, the total collected can be less than the initial price, so the purchase reverts and the NFT cannot be bought.
Submitted by Trust, also found by gzeon
createPool() in GroupBuy.sol creates a new contribution pool around an NFT. It specifies a target \_initialPrice as minimum amount of ETH the NFT will cost, and \_totalSupply which is the number of Raes to be minted on purchase success.
minBidPrices is calculated from the two numbers. All future bids must be at least minBidPrices. It is assumed that if the totalSupply of Raes is filled up, the group will collect the initialPrice.
// Calculates minimum bid price based on initial price of NFT and desired total supply
minBidPrices[currentId] = _initialPrice / _totalSupply;
The issue is that division rounding error will make minBidPrices too low. Therefore, when all Raes are minted using minBidPrices price: minBidPrices[currentId] * _totalSupply != _initialPrice
Therefore, not enough money has been collected to fund the purchase.
It can be assumed that most people will use minBidPrices to drive the price they will choose. Therefore, even after discovering that the Group has not raised enough after filling the supply pool, it will be very hard to get everyone to top up the contribution by a bit. This is because the settled price which is collected from all contributions is minReservePrices, which is always the minimum price deposited.
Code in contribute that updates minReservePrices:
// Updates minimum reserve price if filled quantity amount is greater than 0
if (filledQuantity > 0) minReservePrices[_poolId] = getMinPrice(_poolId);
The check in purchase() that we don’t charge more than minReservePrices from each contribution:
if (_price > minReservePrices[_poolId] * filledQuantities[_poolId])
revert InvalidPurchase();
We can see an important contract functionality is not working as expected which will impair NFT purchases.
Impact
GroupBuys that are completely filled still don’t raise stated target amount.
Recommended Mitigation Steps
Round the minBidPrices up, rather than down. It will ensure enough funds are collected.
Agree that the division rounding down will be a problem. Reasonable for a RAE holder to create a new pool where the
_initialPriceisn’t exactly divisible by_totalSupply:Eg.
_initialPrice = 100, _totalSupply = 8. Then purchase will always revert withInvalidPurchase()` because:
minBidPrices[currentId] = 100 / 8and_price (100) > minReservePrices[_poolId] * filledQuantities[_poolId]) = 12 * 8 = 96is true.
stevennevins (Tessera) confirmed and mitigated:
https://github.com/fractional-company/modular-fractional/pull/213
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 integer division truncation when calculating the minimum bid price, causing the product of minimum price and total supply to be less than the initial price.
What the attacker needed
A RAE holder creates a pool; initial price not divisible by supply
The fix
The minimum bid price should be rounded up instead of down to ensure enough funds are collected; the text states this was mitigated.
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 group of people pool money to buy an NFT. The contract sets a minimum contribution per share by dividing the NFT price by the number of shares, but this division rounds down. If everyone pays only the minimum, the total falls short of the NFT price, so the purchase fails.
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.