Eggstravaganza

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

Use of `_mint()` instead of `_safeMint()` can lead to tokens being locked in contracts

Description: Using ERC721::_mint() allows minting tokens to any address, including contracts that do not implement the IERC721Receiver interface. If a token is minted to a smart contract that does not properly handle ERC721 tokens, the token may become permanently inaccessible or locked. The _safeMint() function performs additional checks to ensure the recipient is capable of receiving ERC721 tokens.

Impact: Tokens might get locked in contracts that are not designed to handle ERC721 tokens, resulting in permanent loss of assets. This could also cause unexpected behavior and poor user experience.

Proof of Concept:

_mint(address(0xdead), tokenId); // 0xdead might be a contract not implementing ERC721Receiver

This call will succeed even if the recipient is not a valid ERC721 receiver contract!

Recommended Mitigation: Use _safeMint() instead of _mint() in EggstravaganzaNFT::mintEgg function when minting ERC721 tokens to ensure the receiving contract is able to handle the tokens correctly:

_safeMint(to, tokenId);

This ensures that if msg.sender is a contract, it must implement the onERC721Received interface, otherwise the mint will revert.

Updates

Lead Judging Commences

m3dython Lead Judge 2 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.