GivingThanks

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

Reentrancy vulnerability in `GivingThanks::donate` function, enabling malicious users to mint multiple NFTs in one donation

Summary

In the implementation, the GivingThanks::donate function doesn't follow CEI(Check - Effect - Interact) pattern, allowing reentrancy attacks. Although the second charity.call will fail due to balance is not enough, it's still a good practice to follow CEI pattern.

Impact

Users are enable to donote 0 eth and mint multiple NFTs by an reentrancy attack.

Recommendation

Follow CEI pattern

function donate(address charity) public payable {
require(registry.isVerified(charity), "Charity not verified");
_mint(msg.sender, tokenCounter);
// Create metadata for the tokenURI
string memory uri = _createTokenURI(msg.sender, block.timestamp, msg.value);
_setTokenURI(tokenCounter, uri);
tokenCounter += 1;
(bool sent,) = charity.call{value: msg.value}("");
require(sent, "Failed to send Ether");
}
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.