Submitted by Trust, also found by Lambda
purchase() in GroupBuy faciilitates the purchasing of an NFT after enough contributions were gathered. Another report titled Attacker can steal the amount collected so far in the GroupBuy for NFT purchase describes a high impact bug in purchase. It is advised to read that first for context.
Additionally, purchase() is vulnerable to a re-entrancy exploit which can be chained or not chained to the \_market issue to steal the entire ETH stored in GroupBuy, rather than being capped to minReservePrices[_poolId] * filledQuantities[_poolId].
Attacker may take control of execution using this call:
It could occur either by exploiting the unvalidated \_market vulnerability , or by abusing an existing market that uses a user address in \_purchaseOrder.
There is no re-entrancy protection in purchase() call:
\_verifyUnsuccessfulState() needs to not revert for purchase call. It checks the pool.success flag:
if (pool.success || block.timestamp > pool.terminationPeriod) revert InvalidState();
However, success is only set as the last thing in purchase():
Therefore, attacker can re-enter purchase() function multiple times, each time extracting the maximum allowed price. If attacker uses the controlled \_market exploit, the function will return the current NFT owner, so when all the functions unwind they will keep setting success to true and exit nicely.
GroupBuy can be drained of all ETH.
Add a re-entrancy guard to purchase() function. Also, change success variable before performing external contract calls.
mehtaculous (Tessera) confirmed and commented:
stevennevins (Tessera) mitigated:
