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.
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_nftContractToTokenIdToFirstSaleCompletedto 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
_distributeFundsbefore calling_transferFromEscrowwhere 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.
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
- 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.
- 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.