The mintEgg() function in EggstravaganzaNFT.sol uses the low-level _mint() function, which does not verify whether the recipient can handle ERC721 tokens. This may lead to NFTs being irreversibly locked in contracts that do not support or reject them.
ERC721::_mint() does not check if the recipient is a contract or whether it implements the IERC721Receiver interface. As a result, tokens can be minted to non-compliant contracts and become permanently inaccessible.
The ERC721.sol file in the OpenZeppelin library, has the following warning in the function natspec:
“WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible.”
The ERC721::_safeMint() function includes an additional step to call onERC721Received() on the recipient if it’s a contract, ensuring compatibility and preventing token loss.
In the current implementation, if the mintEgg() function is called with an unsafe address (e.g., a contract without onERC721Received()), the mint will succeed and totalSupply will be incremented, even though the token may be permanently stuck.
Token Loss: NFTs can be sent to contracts that cannot manage or return them, resulting in permanent loss.
Silent Failure: totalSupply is incremented, misleading off-chain or on-chain tracking.
Manual Code Review
Foundry Test Suite
Replace the use of _mint() in mintEgg() with _safeMint():
Protocol doesn't check if recipient contracts can handle ERC721 tokens
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.