Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: medium
Valid

Use of _mint Instead of _safeMint in mintEgg May Lead to Token Loss

Summary

The mintEgg function in EggstravaganzaNFT uses _mint instead of _safeMint, which may result in NFTs being irretrievably sent to contracts that are not capable of handling ERC721 tokens.

Vulnerability Details

function mintEgg(address to, uint256 tokenId) external returns (bool) {
require(msg.sender == gameContract, "Unauthorized minter");
_mint(to, tokenId);
totalSupply += 1;
return true;
}

_mint does not check whether to is a contract that can handle NFTs. If to is a contract that does not implement onERC721Received, the NFT will be stuck and cannot be retrieved, resulting in a loss of ownership.
Using _safeMint adds a safety check This ensures that if to is a contract, it must correctly implement the IERC721Receiver interface, otherwise the mint will fail and prevent accidental loss.

Impact

NFTs can be minted to incompatible contracts and get permanently stuck.

Tools Used

Manual code review.

Recommendations

Replace _mint with _safeMint in mintEgg function.

Updates

Lead Judging Commences

m3dython Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Unsafe ERC721 Minting

Protocol doesn't check if recipient contracts can handle ERC721 tokens

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.