Skip to content
Business logic Audit finding Intermediate

Fees Are Incorrectly Charged on Unfinalized NFT Sales

An unfinalized auction allowed the highest bidder to accept an offer and trigger a sale before the original auction sale was finalised, causing the first-sale flag to be set incorrectly. This meant the creator avoided the primary foundation fee on the original auction sale.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

NFTMarketOffer.sol#L255-L271 NFTMarketReserveAuction.sol#L557 NFTMarketReserveAuction.sol#L510-L515 NFTMarketFees.sol#L188-L189

Once an auction has ended, the highest bidder now has sole rights to the underlying NFT. By finalizing the auction, fees are charged on the sale and the NFT is transferred to auction.bidder. However, if auction.bidder accepts an offer before finalization, fees will be charged on the auction.bidder sale before the original sale. As a result, it is possible to avoid paying the primary foundation fee as a creator if the NFT is sold by auction.bidder before finalization.

Proof of Concept

Consider the following scenario:

  • Alice creates an auction and is the NFT creator.
  • Bob bids on the auction and is the highest bidder.
  • The auction ends but Alice leaves it in an unfinalized state.
  • Carol makes an offer on the NFT which Bob accepts.
  • _acceptOffer() will distribute funds on the sale between Bob and Carol before distributing funds on the sale between Alice and Bob.
  • The first call to _distributeFunds() will set the _nftContractToTokenIdToFirstSaleCompleted to true, meaning that future sales will only be charged the secondary foundation fee.

Recommended Mitigation Steps

Ensure the _nftContractToTokenIdToFirstSaleCompleted is correctly tracked. It might be useful to ensure the distribution of funds are in the order of when the trades occurred. For example, an unfinalized auction should always have its fees paid before other sales.

NickCuso (Foundation) confirmed and commented:

Yes! This is a good find.

The core of the problem is we were calling _distributeFunds before calling _transferFromEscrow where the auction finalization would be processed. We have flipped those calls so now the auction will be fully settled before we calculate fees for the offer sale.


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

Root cause

Likely the contract distributes funds for a new offer sale before finalising the earlier auction sale, so the first-sale flag is set by the wrong transaction.

Impact

The creator could avoid paying the primary foundation fee on the original auction sale.

What the attacker needed

NFT creator starts an auction; auction ends but is not finalised; highest bidder accepts an offer

The fix

The contract was fixed by settling the auction before calculating fees for the offer sale.

How it was found

  1. Alice creates an auction and is the NFT creator.
  2. Bob bids on the auction and is the highest bidder.
  3. The auction ends but Alice leaves it in an unfinalized state.
  4. Carol makes an offer on the NFT which Bob accepts.
  5. The offer sale is processed before the auction sale, setting the first-sale flag.

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.

When an NFT is sold for the first time, the platform charges a higher fee to the creator. The code marks an NFT as 'sold before' too early if a second sale happens while the first auction is still waiting to be completed. This lets the creator skip the higher fee.

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.