GivingThanks

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

[H-2] Fixing Unverified Charity Donations in GivingThanks.sol: Resolving a Verification Bypass Bug in CharityRegistry.sol

Summary

A bug was found in the CharityRegistry.sol contract, which impacted the GivingThanks.sol contract. In GivingThanks.sol, there’s a function called GivingThanks::donate that should only allow donations to charities that have been verified. Due to an issue in the CharityRegistry.sol contract, GivingThanks::donate allowed donations to any charity that was registered, which might not been verified.

Vulnerability Details

  • Problem Location: CharityRegistry.sol

  • Function Affected in GivingThanks.sol: donate(address charity)

In CharityRegistry.sol, the CharityRegistry::isVerified function was supposed to check if a charity was verified. Instead, it was checking if the charity was simply registered. This allowed donations to go to unverified charities, which could be exploited by anyone who registered a charity and hasn't got verification from the admin.

Impact

Because of this bug, donations could be sent to unverified charities, potentially allowing funds to go to charities that hadn’t been verified. This could lead to donations being misused by untrustworthy parties.

Tools Used

  • Manual code review

  • Testing with various charity statuses (registered, verified) to find the issue

Recommendations

  1. Fix the CharityRegistry::isVerified Function: Update the isVerified function in CharityRegistry.sol to check for verified charities, not the registered ones.

Original Code:

function isVerified(address charity) public view returns (bool) {
return registeredCharities[charity]; // Incorrectly checks registration, not verification
}

Fixed Code:

function isVerified(address charity) public view returns (bool) {
return verifiedCharities[charity]; // Correctly checks for verification
}
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.