GivingThanks

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

Incorrect initialization of registry in `GivingThanks` constructor causes charity verification failure

Summary

In the GivingThanks contract, the registry variable is improperly initialized in constructor. Instead of using _registry parameter passed to the constructor to set the registry variable, it incorrectly uses msg.sender.

Vulnerability Details

By setting registry = CharityRegistry(msg.sender);, the registry variable is assigned to the deployer of the contract instead of the intended CharityRegistrycontract. This breaks the intended functionality of the protocol making the protocol unusable.

Tools Used

Manual code review

Recommendations

Assign the _registry parameter passed in the constructor to the instance of the CharityRegistry contract.

constructor(address _registry) ERC721("DonationReceipt", "DRC") {
+ registry = CharityRegistry(_registry);
- registry = CharityRegistry(msg.sender);
owner = msg.sender;
tokenCounter = 0;
}
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.