The donate function in GivingThanks.sol fails to properly check the charity’s verification status before allowing a donation. Instead of ensuring that the charity is verified, it mistakenly checks only if the charity is registered in the CharityRegistry.sol contract. As a result, unverified charities can receive donations when they shouldn't.
In GivingThanks.sol, the donate function has the following code:
However, the isVerified function in the CharityRegistry contract returns the status of registeredCharities[charity], not verifiedCharities[charity]. This allows any registered charity to receive donations, regardless of verification status. The intended functionality was for isVerified to check the verifiedCharities mapping, which actually confirms a charity's verification.
The isVerified function currently only checks if a charity is registered by returning registeredCharities[charity]. It does not verify whether the charity is also verified by checking verifiedCharities[charity].
Unverified charities can bypass the verification process and receive donations directly.
Manual code review.
Update the isVerified function in CharityRegistry to check the verifiedCharities mapping directly, ensuring only verified charities receive donations:
Likelyhood: High, the function returns registered charities instead of verified ones. Impact: High, Any charities can be registered by anyone and will be declared as verified by this function bypassing verification.
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.