The function CharityRegistry::isVerified returning a boolean that indicates whether a charity is verified or not always returns true for any registred charity.
Due to mix up of the state variables (mappings) CharityRegistry::registeredCharities andCharityRegistry::verifiedCharitiesany registered charity returns truewhen CharityRegistry::isVerified is called. The test GivingThanks.t:testCannotDonateToUnverifiedCharity passes because the donate function reverts when called. However, it reverts due to a bug in the constructor, not because the charity is not verified.
User registers a charity
User donates before charity is verified
Charity is considered as verified and donation is accepted
Code:
Use explicit revert check for GivingThanks.t:testCannotDonateToUnverifiedCharity:
Test will fail with:
The check if a charity is verified in GivingThanks::donatewill always return true for a registered charity. This breaks the verification mechanism by the admin.
Foundry, manual review
Fix the mixed up state variables:
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.