Summary
In donate function we mint an NFT, but it doesn't check minting to a zero address.
Vulnerability Details
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;
}
Impact
NFTs can be minted to an zero address resulting permanenty NFTs loss.
Tools Used
Manua Review
Recommendations
Add a check fo zero address.
require(charity != address(0), "Invalid charity address");
function donate(address charity) public payable {
require(charity != address(0), "Invalid charity address");
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;
}