GivingThanks

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

[H-1] Unauthorized Registry Update Vulnerability in Smart Contract Enabling Potential Fund Redirection

Summary

A vulnerability was identified in the GivingThanks::updateRegistry function of the smart contract. This function, which allows changing the address of the CharityRegistry, lacks an access control mechanism, allowing anyone to update the registry. This could enable a malicious actor to redirect funds to an arbitrary contract instead of the intended verified charities.

Vulnerability Details

The GivingThanks::updateRegistry function lacks an access control check to ensure that only authorized personnel (e.g., an admin or owner) can modify the registry address. Without this restriction, any user can call GivingThanks::updateRegistry to set a malicious address for CharityRegistry, enabling redirection of funds to an unauthorized account.

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

Missing Check

The function should include a check to ensure that only the contract owner can modify the registry.

Impact

If exploited, this vulnerability could result in the redirection of funds intended for verified charities to an attacker-controlled address, resulting in significant financial loss.

Tools Used

  • Manual review of the smart contract code.

Recommendations

To mitigate this vulnerability, add an access control mechanism to the GivingThanks::updateRegistry function. This can be done by requiring that the caller is the contract owner, as demonstrated in the solution below:

Solution

function updateRegistry(address _registry) public {
require(msg.sender == owner, "Only owner can change registry");
registry = CharityRegistry(_registry);
}
Updates

Lead Judging Commences

n0kto Lead Judge 12 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.