GivingThanks

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

Unrestricted Registry Update Allows Unauthorized Users to Modify the Trusted Charity Registry.

Summary

The updateRegistry function in the GivingThanks contract allows any user to modify the charity registry address without restriction. This vulnerability will allow unauthorized users to change the trusted registry, thereby redirecting donations to unverified addresses.

Vulnerability Details

The updateRegistry function currently lacks an access control mechanism to limit who can call it. As a result, any user can change the registry variable to another address. By updating the registry address, a malicious user could redirect donations intended for verified charities to an attacker-controlled address, hence compromising the integrity of the donation system.

https://github.com/Cyfrin/2024-11-giving-thanks/blob/304812abfc16df934249ecd4cd8dea38568a625d/src/GivingThanks.sol#L56

function updateRegistry(address _registry) public {
registry = CharityRegistry(_registry);
}

Impact

As the updateRegistry function is currently without restrictions, it creates a critical security risk because unauthorized users are allowed to set the registry address. If exploited, attackers could divert funds to unverified or malicious addresses, and in doing so, break the trust in the platform and potentially cause significant financial losses for donors and charities.

Tools Used

Manual Code Review

Recommendations

Restrict access to the updateRegistry function, allowing only the contract’s owner or admin to call it by using OpenZeppelin's Ownable modifier (onlyOwner). This will ensure that only authorized addresses can change the registry address.

function updateRegistry(address _registry) public onlyOwner {
registry = CharityRegistry(_registry);
}
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-anyone-can-change-registry

Likelyhood: High, anyone can change it at anytime Impact: High, can bypass the verification process

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.