GivingThanks

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

Not getting CharityRegistry in GivingThanks.sol constructor

Summary

The constructor of GivingThanks receives _address of the registery but it's not used.
What's used now is the msg.sender and it's resulting in not getting the contract of the registry causing a false positive result for testCannotDonateToUnverifiedCharitytest result.

Line: https://github.com/Cyfrin/2024-11-giving-thanks/blob/main/src/GivingThanks.sol#L16

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

Impact

The CharityRegistry contract will not be used and the donations will always fail.

Recommendations

Correct it so we use the right CharityRegistry

constructor(address _registry) ERC721("DonationReceipt", "DRC") {
registry = CharityRegistry(_registry);
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.