GivingThanks

First Flight #28
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

Use of _mint Instead of _safeMint in GivingThanks contract, creating risks of locked tokens

Summary

Using ERC721::_mint() can mint ERC721 tokens to addresses which don't support ERC721 tokens.

Vulnerability Details

The ERC721 _mint function directly assigns tokens without verifying whether the recipient address is a contract or if it supports ERC721 tokens. If tokens are minted to a contract address that does not implement the ERC721Receiver interface, these tokens may be effectively “locked,” as the recipient contract will not be able to interact with them. Using _safeMint provides an additional check to ensure compatibility with the ERC721 standard, verifying that the recipient is capable of receiving ERC721 tokens.

Impact

Minting tokens with _mint instead of _safeMint may lead to tokens being permanently locked in addresses that cannot handle ERC721 tokens. This can result in token loss for users, reducing the contract's reliability and the usability of its tokens.

Tools Used

  • Manual Code Review

  • Aderyn

Recommendations

Use _safeMint() instead of _mint() for ERC721.

Replace _mint with _safeMint: Update the minting function to use _safeMint, which verifies that the recipient can handle ERC721 tokens:

+ _safeMint(msg.sender, tokenCounter);
- _mint(msg.sender, tokenCounter);
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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