Mystery Box

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

Lack of access control in `changeOwner` function

Summary

Any actor is able to call function changeOwner and obtain owner role.

Vulnerability Details

Relevant Code

MysteryBox::changeOwner

The vulnerability exists in the changeOwner function, as it is a public function without the required protection. Any malicious actor can call the function and obtain the owner role.

Impact

The owner role is able to call access controled functions as setBoxPrice and withdrawFunds. As any user is able to obtain owner role, it can ultimately drain the contract's funds.

Tools Used

Manual Review

Recommendations

Add a require statement to only let the owner update the owner.

function changeOwner(address _newOwner) public {
+ require(msg.sender == owner, "Only owner can update owner");
owner = _newOwner;
}
Updates

Appeal created

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