GivingThanks

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

Use of `_mint` instead of `_safeMint`.

Summary

The contract GivingThanks uses the _mint function in function donateto create new ERC721 tokens, which does not check if the recipient is capable of receiving ERC721 tokens.

Vulnerability Details

function donate(address charity) public payable {
require(registry.isVerified(charity), "Charity not verified"); // @audit-issue can donate to unverified charity
(bool sent, ) = charity.call{value: msg.value}("");
require(sent, "Failed to send Ether");
- _mint(msg.sender, tokenCounter);

Impact

If tokens are minted to a contract that does not implement the onERC721Received function, they could become permanently locked, leading to loss of tokens.

Tools Used

Manual code review.

Recommendations

Use _safeMint Function:

function donate(address charity) public payable {
require(registry.isVerified(charity), "Charity not verified"); // @audit-issue can donate to unverified charity
(bool sent, ) = charity.call{value: msg.value}("");
require(sent, "Failed to send Ether");
+ _safeMint(msg.sender, tokenCounter);
Updates

Lead Judging Commences

n0kto Lead Judge 8 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.