MartenitsaMarketplace::makePresent
allows users to transfer their NFTs to another user, but it fails to ensure that either
listed NFTs cannot be given away as a present, or
if a listed NFT is given away as a present, the listing is cleared.
MartenitsaMarketplace::makePresent
allows users to give away their NFTs to another user for free, as a present. Importantly, however, listed NFTs are not supposed to be able to be transferred between users unless bought. MartenitsaMarketplace::makePresent
does not check whether an NFT is listed and, accordingly, a user can give away its listed NFT as a present to another user.
Consider the following test that demonstrates this vulnerability:
If a listed NFT is given away to another user via MartenitsaMarketplace::makePresent
, the NFT will remian incorrectly listed even after the ownership change. As a consequence:
mapping(uint256 => Listing) public tokenIdToListing;
will be incorrect for the affected NFT,
MartenitsaMarketplace::getListing
will return the incorrect listing data for the affected NFT,
although the affected NFT will continue to appear to be listed, it cannot be bought (as safeTransferFrom
in MartenitsaMarketplace::buyMartenitsa
will fail since it will try to move the NFT from the previous owner who made the present). Unsuspecting buyers will waste gas trying to buy the NFT.
(Note that all these issues will become void if the new owner properly lists the NFT it got as a present, since previous listing details will be overriden and reflect reality and true ownership status once again.)
Manual review, Foundry.
Consider the following options and select whichever matches your current and future requirements more appropriately:
Implement a check in MartenitsaMarketplace::makePresent
to ensure that listed tokens cannot be given away:
Note that additionally, you should overwrite the standard ERC721
method transferFrom
in the MartenitsaToken
contract and include a similar check therein.
Implement a logic that automatically cancels the listing when someone tries to give away thier listed NFTs as present:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.