Mystery Box

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

No access control for function MysteryBox::changeOwner allows anyone to withdraw all funds from the contract

Summary

Anyone can change owner of the contract and then withdraw all funds from the contract.

Vulnerability Details

Function MysteryBox::changeOwner does not have any access control in place. Therefore anyone can call the function and change the contract owner. After that the attacker can call function MysteryBox::withdrawFunds and withdraw all funds from the contract.

Impact

Anyone can withdraw all funds from the contract.

Tools Used

Manual review

Recommendations

Add permissions check to the function MysteryBox::changeOwner as show below:

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