GivingThanks

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

attacker can mint free NFT by passing his own charity address to `donate` function

Summary

any user just after verifying their charity address can mint unlimited nfts

Vulnerability Details

once user verified its charity by admin then user can send ether to its own charity can mint unlimited nfts

Impact

Tools Used

Manual

##POC

  1. attacker register his own charity on charityRegistery

function registerCharity(address charity) public {
registeredCharities[charity] = true;
}
  1. admin verify his charity contract

function verifyCharity(address charity) public {
require(msg.sender == admin, "Only admin can verify");
require(registeredCharities[charity], "Charity not registered");
verifiedCharities[charity] = true;
}
  1. call donate function using own charity address

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);
// Create metadata for the tokenURI
string memory uri = _createTokenURI(msg.sender, block.timestamp, msg.value);
_setTokenURI(tokenCounter, uri);
tokenCounter += 1;
}

Recommendations

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

Lead Judging Commences

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

finding-charities-can-get-big-amount-NFT-for-free

Likelyhood: Informational/Very low, admin will verified the contract. Impact: High, NFT with real value for free. I accept this one has a Low due to its High Impact.

Support

FAQs

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