Mystery Box

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

Anyone Can Change the Contract Owner

Summary

The changeOwner function lacks proper access control, allowing any user to transfer ownership of the contract to themselves or another address. This could result in unauthorized control of the contract.

Vulnerability Details

The changeOwner function is missing a permission check, meaning any user can call this function and change the contract's ownership. Without access control, anyone interacting with the contract can replace the current owner with any address, leading to a potential takeover of the contract's operations.

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

Impact

A malicious user could take control of the contract, enabling them to:

  • Withdraw all funds from the contract.

  • Manipulate rewards and other sensitive functionality.

  • Significantly harm the protocol, resulting in loss of user trust and funds.

Tools Used

Manual Code Review

Recommendations

Add an access control check to the changeOwner function, such as require(msg.sender == owner), to ensure only the current owner can change the ownership of the contract. This will safeguard against unauthorized transfers of ownership.

Updates

Appeal created

inallhonesty Lead Judge 11 months 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.