GivingThanks

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

function `donate()` in `GivingThanks.sol` reads the wrong mapping allowing non-verified charities to receive donations

Summary

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.

Vulnerability Details

Issue

In GivingThanks.sol, the donate function has the following code:

require(registry.isVerified(charity), "Charity not verified");

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.

Root Cause

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].

Impact

  • Unverified charities can bypass the verification process and receive donations directly.

Tools Used

  • Manual code review.

Recommendations

  1. Update the isVerified function in CharityRegistry to check the verifiedCharities mapping directly, ensuring only verified charities receive donations:

    function isVerified(address charity) public view returns (bool) {
    return verifiedCharities[charity];
    }
Updates

Lead Judging Commences

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

finding-isVerified-return-registered-charities

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.

Support

FAQs

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