Summary
'GivingThanks' contract constructor has a parameter for 'CharityRegistry' contract address. However, when 'GivingThanks' is deployed, the 'CharityRegistry' store variable is initialized with 'msg.sender' and will cause future donations to fail, as indicated by the failure of the tests 'GivingThanksTest::testDonate()' and 'GivingThanksTest::testFuzzDonate()'.
Vulnerability Details
It is not a vulnerability as such, it is a bad initialization in the deployment that affects tests
Impact
Deploying the 'Giving Thanks' contract without a 'Charity Registry' contract could cause problems with donations to registered and verified addresses until the registry is updated using the 'GivingThanks::updateRegistry' function. The tests 'GivingThanksTest::testDonate()', 'GivingThanksTest::testFuzzDonate()' and 'GivingThanksTest::testCannotDonateToUnverifiedCharity()' give a false positive/negative because of this incomplete initialization.
Tools Used
Foundry , manual code review
Recommendations
The CharityRegistry variable must be initialized with the address of the previously created CharityRegistry contract.
``` diff
constructor(address _registry) ERC721("DonationReceipt", "DRC") {
- registry = CharityRegistry(msg.sender);
+ registry = CharityRegistry(_registry);
owner = msg.sender;
tokenCounter = 0;
}
```