The donate function of the GivingThanks contract is vulnerable to a reentrancy attack due to making an external call to a charity address using call before updating its internal state tokenCounter. This allows a malicious contract to re-enter the donate function multiple times, minting multiple NFTs with the same token ID, violating the ERC721 standard for unique tokens.
GivingThanks.sol(#21-33):
The external call to charity address executes before updating the tokenCounter.
Attacker creates a malicious contract with fallback() function. Takes the contract's address and pass into the charity. Require statement checks if the charity is verified.
The call interacts with the charity address which could be a malicious contract address with a fallback function.
The fallback function will re-enter the donate function, allowing the charity contract to call donate multiple times before the state tokenCounter is updated.
The _mint function is called multiple times with the same tokenCounter value, creating multiple NFTs with the same/duplicated token ID.
Multiple NFTs being minted with the same tokenCounter, violating the uniqueness property of ERC721 tokens.
Drain funds due to the fallback() function repeatedly executes the donation process.
Slither + Manual Code Review
Update the state before the external call.
Utilize OpenZeppelin's ReentrancyGuard library to prevent Reentrancty attack.
Impact: High, one charity can reenter the donate function with the same ETH provided and mint several NFT. Likelyhood: Low, any malicious charity can do it but Admin is trusted and should verify the charity contract before "verifying" it.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.