Skip to content
Business logic Audit finding Intermediate

buyFromPrivateSaleFor() Will Fail if The Buyer Has Insufficient Balance Due to an Open Offer on The Same NFT

The buyFromPrivateSaleFor() function fails when a buyer has an open offer on the same NFT because the offer locks their funds, preventing the purchase. An attacker could not exploit this; it is a usability bug that blocks legitimate buyers.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

NFTMarketPrivateSale.sol#L143-L150

The buyFromPrivateSaleFor() function allows sellers to make private sales to users. If insufficient ETH is provided to the function call, the protocol will attempt to withdraw the amount difference from the user’s unlocked balance. However, if the same user has an open offer on the same NFT, then these funds will remain locked until expiration. As a result, the user cannot make use of these locked funds even though they may be needed for a successful sale.

Recommended Mitigation Steps

Consider adding a _cancelBuyersOffer() call to the buyFromPrivateSaleFor() function. This should be added only to the case where insufficient ETH was provided to the trade. By cancelling the buyer’s offer on the same NFT, we can guarantee that the user has access to the correct amount of funds.

NickCuso (Foundation) confirmed and commented:

Yes - completely agree. This was an oversight on our end - and as a result it created an inconsistent experience for users. Since we leveraged an outstanding offer balance for a buy purchase, the same behavior should occur when using Private Sales so that user’s are not in a state where they cannot make the purchase due to incorrectly having their funds locked up.

As you point out without this change, it’s possible that the buyer using private sales continues to have their funds locked up for an Offer that can now only be accepted by themselves. It’s an awkward state that should be avoided.

We have made the recommended change.


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

Impact

The buyer cannot complete a private sale purchase because their funds are locked by their own offer, creating an inconsistent user experience.

What the attacker needed

Buyer has an open offer on the same NFT; buyer attempts a private sale purchase with insufficient ETH

The fix

The recommended change was to add a call to cancel the buyer's offer on the same NFT when insufficient ETH is provided, and this was implemented.

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.

This is a smart contract bug where a buyer cannot complete a purchase because their own money is temporarily locked by an offer they made on the same item. The function tries to take extra funds from their balance, but those funds are reserved for the offer, 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.

More by leastwood

View all

70 more disclosed reports, best first.

More from Foundation Exhibition, Scheduling & Early Access Solo Audit by Lambda

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.