GivingThanks

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

Incorrect `msg.sender` Assignment in `GivingThanks::constructor` Results in Registry Misconfiguration

Summary

In the GivingThanks contract constructor, the registry variable is mistakenly assigned to msg.sender rather than _registry. This causes the donate function to fail, as msg.sender does not implement the necessary isVerified function expected from the CharityRegistry.

Vulnerability Details

The constructor sets the registry variable to msg.sender, instead of the provided _registry address, as shown below:

constructor(address _registry) ERC721("DonationReceipt", "DRC") {
registry = CharityRegistry(msg.sender);
owner = msg.sender;
tokenCounter = 0; //e unnecessary
}

Since the registry address is incorrectly set to msg.sender, any call to registry.isVerified() in the donate function will fail, as the contract instance at msg.sender does not contain the required isVerified function. This effectively breaks donation functionality and prevents interactions with registered charities.

Impact

  • Failure of the donate function: Without the correct registry address, the donate function cannot verify charities, leading to donation process failures.

  • Contract Misconfiguration: Using msg.sender instead of _registry results in improper initialization, making the contract unable to perform as designed.

Tools Used

Manual Review

Recommendations

Assign the registry variable to _registry to ensure proper configuration:

constructor(address _registry) ERC721("DonationReceipt", "DRC") {
- registry = CharityRegistry(msg.sender);
+ registry = CharityRegistry(_registry);
owner = msg.sender;
tokenCounter = 0; //e unnecessary
}

This change ensures the GivingThanks contract is correctly initialized with the intended CharityRegistry address, restoring donation functionality and allowing proper charity verification.

Updates

Lead Judging Commences

n0kto Lead Judge 12 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.