isVerified
function in CharityRegistry.sol
mistakenly checks the registeredCharities
mapping instead of the verifiedCharities
mapping. As a result, the GivingThanks
contract allows donations to any registered charity regardless of whether it has been verified, bypassing the intended verification requirement.isVerified
in CharityRegistry.sol
is designed to validate if a charity is verified before allowing a donation. However, instead of checking the verifiedCharities
mapping, which stores verification status, it incorrectly references registeredCharities
, a separate mapping for registration status. This oversight breaks the workflow, permitting donations to any registered charity, verified or not.The error is found in the isVerified
function within CharityRegistry.sol
:
This should reference verifiedCharities
instead:
Manual code inspection
forge test
output and trace analysis
isVerified
function to check the correct mapping (verifiedCharities
). This fix aligns the logic with the intended functionality, ensuring donations are only permitted for verified charities.In CharityRegistry.sol
, modify the isVerified
function as follows:
This change enforces the intended verification check, preventing donations to unverified charities and restoring the expected workflow of the contract.
During testing, the function testCannotDonateToUnverifiedCharity
failed as it allowed donations to an unverified charity, indicating that verification was not enforced as intended. Below is the command run and the detailed output:
Initial command run:
Output:
to gain more detail, the following was run:
Output:
From this output, it's clear that CharityRegistry::isVerified
returned true
for an unverified charity, allowing the donation. This confirmed that the test failed due to the incorrect mapping reference.
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.