GivingThanks

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

Incorrect Initialization of registry Variable in GivingThanks Constructor Causes Functions to Fail

Summary

The GivingThanks contract constructor incorrectly initializes the registry variable by casting msg.sender (the deploying address) as a CharityRegistry contract. This results in an incorrect reference to the intended CharityRegistry contract and causes the donate function to fail when it attempts to call registry.isVerified(charity), as the cast address does not implement the required CharityRegistry functions.

Vulnerability Details

Line 16 in the GivingThanks.sol contract

16: registry = CharityRegistry(msg.sender);

Impact

This bug prevents the donate function from working, effectively breaking the primary functionality of the contract. Without this fix, users cannot make verified donations through the contract.

Tools Used

Manual code review

Recommendations

replace msg.sender with the constructor param _registry

registry = CharityRegistry(_registry);
Updates

Lead Judging Commences

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

finding-bad-registry-set-at-construction

Likelyhood: High, the parameter is not well used and won't be set. Impact: Low, can be changed with the setter and no one will be able to donate to malicious charity.

Support

FAQs

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