Mystery Box

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

Lack of Access Control due to be drained all funds

Summary

There are so administering function require that msg.sender is MysteryBox::owner such as setBoxPrice, addReward,withdrawFunds. However, the function MysteryBox::changeOwner which is used to move to new owner is lack of an access control. Because of it, malicious user can drain all funds.

Vulnerability Details

Proof of Concept

  1. Malicious user calls changeOwner function to change owner to your appreciation.

  2. They calls withdrawFunds function to withdraw all contract balance.

Impact

The contract's balance will be drained.

Tools Used

Manual Review

Recommendations

Adding an access control to the changeOwner function.

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