Mystery Box

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

Unauthorized access to changeOwner function

Summary

The changeOwner function allows any external caller to change the ownership of the contract. This exposes the contract to malicious actors, who can call this function to take over ownership without authorization. This creates a significant security vulnerability, potentially leading to complete loss of control over the contract.

Vulnerability Details

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

Impact

Any address is able to change ownership, regardless of whether it is the current owner.

Tools Used

Manule review

Recommendations
Add a require statement to ensure that only the current owner can call this function:

function changeOwner(address _newOwner) public {
require(msg.sender == owner, "Only the owner can change ownership");
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!