GivingThanks

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

[M-03] Improper 'registry' initialization in ERC721 constructor leads to broken contract functionality

Summary

The GivingThanks contract DonationReceipt constructor incorrectly initializes the registry variable using msg.sender instead of the provided _registry parameter in its constructor. This results in the registry being set to the deployer's address rather than a valid CharityRegistry contract instance, leading to broken functionality.

Vulnerability Details

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

The line registry = CharityRegistry(msg.sender); assigns the registry to the deployer’s address (msg.sender) instead of the _registry parameter with the actual CharityRegistry contract address.

Impact

Transactions with the registry will fail since the deployer's address does not have the CharityRegistry contract functions supplied. This leads to reverted transactions and non-functional features dependent on the registry.

Recommendations

Fix the initialization logic to use the actual CharityRegistry contract address from the _registry parameter.

Updates

Lead Judging Commences

n0kto Lead Judge about 1 year 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.