Mystery Box

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

MysteryBox::withdrawFunds() Function Withdraws All ETH Including User Rewards

Summary

The MysteryBox::withdrawFunds() function allows the owner to withdraw all ETH from the contract, including funds meant for user rewards.

Vulnerability Details

Affected Code

(bool success,) = payable(owner).call{value: address(this).balance}("");

Impact

Users may not be able to claim their rewards if the owner withdraws all ETH, leaving the contract balance at zero.

Tools Used

  • Visual Studio Code

  • Solidity

  • Foundry

Recommended Mitigation

Track profits separately from funds meant for rewards, and only allow the owner to withdraw the profits.

uint256 ownerBalance = address(this).balance - totalRewards;
(bool success,) = payable(owner).call{value: ownerBalance}("");
Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.