The constructor of the GivingThanks.sol contract initializes the registry variable, intended to reference an external CharityRegistry contract, to msg.sender instead of the _registry parameter. This creates a critical flaw in which GivingThanks.sol contract cannot access the actual CharityRegistry instance for operations such as verifying donations. Instead, the contract mistakenly sets the registry to the deployer of the GivingThanks contract, leading to erroneous interactions.
In the above constructor of GivingThanks.sol, the line registry = CharityRegistry(msg.sender); assigns msg.sender (the address deploying GivingThanks) to the registry variable rather than the intended _registry parameter, which is supposed to be the address of a valid CharityRegistry contract instance.
The GivingThanks contract will treat the deployer's address as the CharityRegistry instance, causing functions such as donate to fail, as the deployer’s address cannot validate charity addresses or provide any registry functionality.
It breaks the purpose of the GivingThanks contract, which relies on CharityRegistry contract to ensure only registered and verified charities receive donations.
Donations will fail because the contract cannot verify charity addresses without a proper CharityRegistry instance, leading to failed transactions in the donate function.
Manual Code Review
Update the constructor to use the _registry parameter:
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.