Mystery Box

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

The 'changeOwner' function should only owner can execute

Summary

The 'changeOwner' function every one can execute,should only contract owner can execute.

Vulnerability Details

The function changeOwner not jugde msg.sender authority, the msg.sender should be contract owner.

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

Impact

The contract may be control by new malice owner. example,modify boxPrice by execute setBoxPrice, and will lost fund in contract.

Tools Used

Manual

Recommendations

Add verify msg.sender condition.

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

}

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.