Mystery Box

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

Lack of Access Control Allows Anyone to Change the Owner

[H-02] Lack of Access Control Allows Anyone to Change the Owner

Summary

The changeOwner function does not implement proper access control, allowing anyone to change the contract owner.

Vulnerability Details

The current implementation of the changeOwner function lacks restrictions, meaning any user can call the function to reassign ownership. This introduces a critical vulnerability, as shown in the code snippet below:

function changeOwner(address _newOwner) public {
owner = _newOwner;
}

Without proper access control, any user, not just the current owner, can take over the contract by calling this function.

Impact

The legitimate owner can lose ownership of the contract, potentially leading to loss of control over critical functions.

Tools Used

Manual Review

Recommendations

Implement appropriate access control to ensure that only the current owner can change ownership. For example, using the onlyOwner modifier would restrict this function to the contract owner:

function changeOwner(address _newOwner) public onlyOwner {
owner = _newOwner;
}
Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Anyone can change owner

Support

FAQs

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

Give us feedback!