Mystery Box

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

`MysteryBox.sol::changeOwner` missing the control access and validation check on the new owner

Relevant GitHub Links

https://github.com/Cyfrin/2024-09-mystery-box/blob/main/src/MysteryBox.sol#L111

Summary

The `MysteryBox.sol::changeOwner` function is set to public giving the possibility to anyone to change the `owner` with any new address (included `address(0)`)

Vulnerability Details

The `MysteryBox.sol::changeOwner` function is set to public without any modifier to limit the access and there is no validation check of the input provided by the caller

Impact

All the privileges of the owner can be assigned by anyone to `address(0)` making the protocol unusable.

Tools Used

Manual review, Foundry

Recommendations

- function changeOwner(address _newOwner) public {
- owner = _newOwner;
- }
+ function changeOwner(address _newOwner) public {
+ require (msg.sender == owner, "You are not the owner")
+ require (_newOwner!= address(0), " new owner is address(0)"
+ }
Updates

Lead Judging Commences

inallhonesty Lead Judge
8 months ago

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.