The GivingThanks contract's constructor incorrectly initializes the registry address using msg.sender instead of the provided _registry parameter. This causes the contract to fail to interact with the intended registry unless manually fixed post-deployment.
The vulnerability exists in the constructor:
Key issues:
Registry parameter is ignored
msg.sender is used instead of _registry
Forces reliance on updateRegistry() to fix post-deployment
Could break core functionality if msg.sender isn't a valid registry
This causes:
Contract deploys with incorrect registry address
Initial donations will fail unless fixed
Additional transaction required to set correct registry
Proof of Concept:
Severity: Medium
Likelihood: High (affects every deployment)
Effects:
Contract deploys in broken state
Donations fail until registry is fixed
Additional gas costs for fixing registry
Potential for permanent failure if updateRegistry() is restricted
Foundry Test Framework
Manual code review
Fix the constructor to use the provided registry parameter:
Additionally, consider:
Adding events for registry changes
Adding validation that the provided address is a valid registry
Protecting updateRegistry() with access control
Adding ability to recover from invalid registry state
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.