Summary
Every user can set the owner of `MysteryBox` contract. There aren't any restrictions wheter msg.sender == currentOwner
Impact
Every user can make himself as owner and withdraw contract funds.
Tools Used
Foundry and solidity. Add the following code inside TestMysteryBox.t.sol:
<details>
<summary>Code</summary>
```javascript
function testchangeOwner_NotOwnerCanSetTheNewOwner() public {
vm.prank(user1);
mysteryBox.changeOwner(user1);
assertEq(mysteryBox.owner(), user1);
}
```
</details>
Recommendations
Add check wheter msg.sender == currentOwner or add modifier to execute the check.
```diff
function changeOwner(address _newOwner) public {
+ require(msg.sender == owner);
owner = _newOwner;
}
```