GivingThanks

First Flight #28
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Valid

Anyone can call function `donate()` in `GivingThanks.sol` and Mint NFT with zero donations.

Summary

The donate function in GivingThanks.sol lacks a minimum donation check. Anyone can call donate() and mint NFT by donating 0 ETH. This could lead to a situation where a donor mint NFT without making any contributions to a charity.

Vulnerability Details

Issue

In the donate function, there is no requirement for a minimum amount of ETH to be sent along with the transaction. This allows any caller to donate 0 ETH and still successfully mint an NFT, as shown in the code snippet:

function donate(address charity) public payable {
require(registry.isVerified(charity), "Charity not verified");
(bool sent, ) = charity.call{value: msg.value}("");
require(sent, "Failed to send Ether");
_mint(msg.sender, tokenCounter);
string memory uri = _createTokenURI(
msg.sender,
block.timestamp,
msg.value
);
_setTokenURI(tokenCounter, uri);
tokenCounter += 1;
}

The function successfully completes without any check to enforce that msg.value is greater than zero. As a result, users can call donate() with msg.value = 0 and still receive an NFT.

The absence of a minimum ETH amount check allows the function to be executed with 0 ETH, minting an NFT.

Impact

  • Users can mint unlimited NFTs without making any actual donations to verified charities.

Tools Used

  • Manual code review.

Recommendations

Add a Minimum Donation Check:
Modify the donate function to enforce a minimum ETH donation amount by adding a requirement statement:

require(msg.value > 0 ether, "Donation should be greater than 0 ETH");
Updates

Lead Judging Commences

n0kto Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-0-donation-mint-an-NFT

Likelyhood: Low, anyone can mint an NFT with 0 amount. No reason to do it. Impact: Informational/Very Low, NFT are minted to a false donator. An NFT with 0 in the amount section would be useless. Since that's a bad design and not expected, I'll consider it Low but in a real contest, it could be informational because there is no real impact.

Support

FAQs

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