Mystery Box

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

anybody can take over the ownership of the protocol

Summary

Since MysteryBox::changeOwner doesn't have any form of verification, any malicious user can hijack the protocol

Vulnerability Details

A random user can take over the protocol and have access to all the exclusive functions in the protocol. She can then call MysterBoxy::WithdrawFunds, MysteryBox::SetPrice, MysteryBox::addReward and all the exclusive and delegate functions thereby causing all havok to the protocol and the users

PoC

function testChangeOwner_AccessControl() public {
vm.startPrank(user1);
mysteryBox.changeOwner(user1);
// change the price of box
mysteryBox.setBoxPrice(0 ether);
assertEq(mysteryBox.owner(), user1);
stopPrank();
}

Impact

  • loss of funds for protocol

  • loss of funds for users

Tools Used

  • manual review

  • foundry test

Recommendations

function changeOwner(address _newOwner) public {
+ require(msg.sender == owner, "Unauthorized user");
owner = _newOwner;
}
Updates

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.