Mystery Box

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

Anyone is able to withdraw all funds from protocol

Summary

Given that MysteryBox::changeOwner() has no access control, anyone can make themselves the owner of the protocol and call MysteryBox::withdrawFunds() for themselves

Vulnerability Details

No access control on MysteryBox::changeOwner(), means that a malicious actor can call MysteryBox::withdrawFunds() in order to steal all funds from the protocol

Impact

All funds can be stolen from the protocol

Proof of Concept

Add to bottom of TestMysteryBox.t.sol

function testAnyoneCanWithdrawAllFundsFromProtocol() public {
address attacker = makeAddr("attacker");
hoax(user1, 1 ether);
mysteryBox.buyBox{value: 0.1 ether}();
vm.startPrank(attacker);
mysteryBox.changeOwner(attacker);
mysteryBox.withdrawFunds();
vm.stopPrank();
}

Tools Used

Manual Review

Recommendations

  • Add access control to MysteryBox::changeOwner()

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!