GivingThanks

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

`GivingThanks::updateRegistry` Function Lacks Access Control

Summary

The updateRegistry function in the GivingThanks contract allows any caller to update the registry address. Without access control, unauthorized users can change the registry to a malicious address, potentially compromising the contract’s integrity.

Vulnerability Details

The updateRegistry function currently lacks any restriction on who can call it, allowing any address to modify the registry variable:

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

This can lead to unauthorized changes in the registry, permitting unverified addresses to act as the registry, bypassing proper verification processes. This creates a significant security risk, especially for a function with control over core contract dependencies.

Impact

  • Loss of Contract Integrity: An attacker can set registry to a malicious address, bypassing charity verification and enabling unauthorized or fraudulent transactions.

  • Potential Loss of Funds: By updating the registry, attackers may redirect funds intended for verified charities to unverified or malicious addresses.

Tools Used

Manual Review

Recommendations

Add an onlyOwner or equivalent check to restrict the updateRegistry function to the contract owner:

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

This simple access control measure will ensure only the designated owner can update the registry address, safeguarding the integrity of the contract’s operations.

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.