Escrowed NFT can be stolen by anyone if no active buyPrice or auction exists for it
An NFT held in escrow by the market contract without an active buy price or auction could be taken by anyone using a tiny offer and accepting it, because the transfer logic did not verify that the seller was authorised by an escrow manager. An attacker could obtain such NFTs for only gas costs and a minimal offer price.
Submitted by hyh, also found by wuwe1
If a NFT happens to be in escrow with neither buyPrice, nor auction being initialised for it, there is a way to obtain it for free by any actor via makeOffer, acceptOffer combination.
I.e. a malicious user can track the FNDNFTMarket contract and obtain any NFT from it for which there are no buyPrice or auction structures initialised. For example, if a NFT is mistakenly sent to the contract, an attacker can immediately steal it.
This will happen as NFT is being guarded by buyPrice and auction structures only. The severity here is medium as normal usage of the system imply that either one of them is initialised (NFT was sent to escrow as a part of setBuyPrice or createReserveAuction, and so one of the structures is present), so this seems to leave only mistakenly sent assets exposed.
Proof of Concept
An attacker can make a tiny offer with makeOffer:
https://github.com/code-423n4/2022-02-foundation/blob/main/contracts/mixins/NFTMarketOffer.sol#L189
Then call acceptOffer, which will lead to _acceptOffer.
Direct NFT transfer will fail in _acceptOffer as the NFT is being held by the contract and _transferFromEscrow will be called instead:
_transferFromEscrow calls will proceed according to the FNDNFTMarket defined order:
function _transferFromEscrow(
...
) internal override(NFTMarketCore, NFTMarketReserveAuction, NFTMarketBuyPrice, NFTMarketOffer) {
super._transferFromEscrow(nftContract, tokenId, recipient, seller);
}
If there are no corresponding structures, the NFTMarketOffer, NFTMarketBuyPrice and NFTMarketReserveAuction versions of _transferFromEscrow will pass through the call to NFTMarketCore’s plain transfer implementation:
This will effectively transfer the NFT to the attacker, which will pay gas costs and an arbitrary small offer price for it.
Recommended Mitigation Steps
Consider adding additional checks to control who can obtain unallocated NFTs from the contract.
Protocol controlled entity can handle such cases manually by initial sender’s request.
NickCuso (Foundation) confirmed and commented:
Yes, this is an interesting scenario to raise! We do have more than one NFT in the market contract which was transferred directly (vs tracked as part of escrow). So there is some exposure already.
We feel this is a
2 (Med Risk):
- It only impacts NFTs which were thought to be effectively burned as they were transferred to the Market contract with no way to get them back.
- Presumably the NFTs which get stuck in the Market contract like that were due to user error. So in theory this could have been thought of a sort of a feature - it allows those NFTs to be recovered, which is great for the original creator which will see royalties from future sales again.
We have fixed this. We took a slightly different approach than what was recommended, but it should accomplish the same goal.
_transferFromEscrowchanged thesellerparam toauthorizeSeller. As the call travels through each mixin, we changeauthorizeSellertoaddress(0)once an escrow manager is able to confirm ownership. Finally when the call reachesNFTMarketCoreit requires thatauthorizeSellerisaddress(0)before executing the transfer — this confirms that one or more escrow managers (buy now or auctions) have positively confirmed the seller. So NFTs in the Market without being escrowed now reverts on this line.
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
The escrow transfer function did not check that the seller was authorised by an active buy price or auction, so it fell through to a plain transfer for unallocated NFTs.
Impact
Any NFT mistakenly sent to the market contract without an active buy price or auction could be stolen by anyone for only gas costs and a minimal offer price; the protocol confirmed some NFTs were already exposed.
What the attacker needed
NFT sent to market contract without buyPrice or auction; Attacker can call makeOffer and acceptOffer
The fix
The fix changed _transferFromEscrow to require that an escrow manager (buy now or auction) has confirmed the seller before allowing the transfer, so unallocated NFTs now revert.
How it was found
- Attacker calls makeOffer with a tiny offer for the NFT.
- Attacker calls acceptOffer, which leads to _acceptOffer.
- Direct transfer fails because the NFT is held by the contract, so _transferFromEscrow is called.
- With no buyPrice or auction structures, the call passes through to NFTMarketCore's plain transfer.
- The NFT is transferred to the attacker for gas costs and the small offer price.
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.
An NFT is a digital token proving ownership. The market contract can hold NFTs in escrow, meaning it keeps them until a sale or auction is set up. If an NFT was sent there by mistake without any sale or auction, the contract still allowed anyone to make a tiny offer and then accept it, transferring the NFT to themselves. The fix ensures the contract only releases an escrowed NFT when a legitimate sale or auction confirms the seller.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.