Mystery Box

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

Unrestricted Owner Change

Summary

The changeOwner function allows anyone to change the contract owner, leading to a complete loss of control over the contract.

Vulnerability Details

The changeOwner function has no access control, allowing any address to call it and change the owner:

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

Impact

High. An attacker can take control of the contract, potentially draining all funds and manipulating the reward system.

Tools Used

Manual code review

Recommendations

Add access control to the changeOwner function:

function changeOwner(address _newOwner) public {
require(msg.sender == owner, "Only current owner can change ownership");
owner = _newOwner;
}

Use OpenZeppelin's Ownable contract to handle ownership management securely.

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!