Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Invalid

Using `ERC721::_mint()` can be dangerous

Summary

Using ERC721::_mint() can mint ERC721 tokens to addresses which don't support ERC721 tokens. Use _safeMint() instead of _mint() for ERC721.

Vulnerability Details

The use of ERC721::_mint() poses a risk because it can inadvertently mint ERC721 tokens to addresses that cannot handle them, potentially leading to lost tokens. To mitigate this risk, it's recommended to use _safeMint() instead. This function includes a check to ensure the recipient address can handle ERC721 tokens, preventing tokens from being locked in unsuitable contracts or addresses. This safeguard ensures that tokens are only minted to capable recipients, avoiding the loss of assets and ensuring the intended functionality of the smart contract.

Impact

Using ERC721::_mint() can lead to a significant impact on the usability and functionality of a smart contract, especially if tokens are minted to addresses that do not support ERC721 tokens. This issue arises because the _mint() function does not perform any checks to ensure that the recipient address can handle ERC721 tokens. Consequently, tokens can be locked in contracts that do not implement the necessary logic to manage ERC721 tokens, making them inaccessible and potentially lost. This situation can lead to a loss of assets for users, disrupting the intended functionality of the smart contract, and potentially affecting the contract's reputation and trust among its users.

Tools Used

Aderyn was used.

Recommendations

Prefer _safeMint() Over _mint(): For all scenarios where tokens are minted to addresses that might not be capable of handling ERC721 tokens, use the _safeMint() function. This ensures that tokens are only minted to addresses that can handle them, preventing tokens from being locked in incompatible contracts.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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