GivingThanks
contract's constructor arises because it initializes the registry
variable with CharityRegistry(msg.sender)
instead of using the _registry
parameter passed to the constructor. This mistake sets the registry
to the address of the contract deployer (msg.sender
) rather than the actual CharityRegistry
contract. As a result, any subsequent calls to registry.isVerified
fail, since the isVerified
function will attempt to access mappings on an invalid addressIn the GivingThanks
contract constructor, the registry
variable is incorrectly initialized with:
registry
to msg.sender
, the contract treats the deployer's address as the CharityRegistry
contract, which is incorrect. Any calls to registry
will now reference the deployer's address instead of the intended CharityRegistry
contract.registry.isVerified
is referencing the isVerified
function on an address that is not the CharityRegistry
contract. This causes the donation function to revert, making it impossible to donate to any charity, even if it has been properly registered and verified.Inability to donate: Since registry.isVerified(charity)
will always fail, the donate
function will revert for any charity. As a result, users will be unable to donate using this contract.
Recommendation
_registry
instead of msg.sender
to initialize the registry
variable.registry
address can be changed with the updateRegistry(address _registry)
function in the GivingThanks.sol
contract.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.