Mystery Box

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

[H-3]: The `MysteryBox::withdrawFunds` function lacks check for funds that have been won but not yet withdrawn

Summary

The function MysteryBox::withdrawFunds allows the owner of the contract to withdraw the whole balance of the protocol regardless of whether there are still wins to be claimed.

Vulnerability Details

The function does not check if there are any distributed, unopened boxes nor if all the winnings have already been claimed. The owner can therefore withdraw all funds from the protocol despite there may still be some winnings to be claimed.

Proof-of-Concept

  1. User enters the MysteryBox competition and purchases 5 boxes for 0.1 ETH each.

  2. The user starts opening the boxex to find winnings totalling at 1.5 ETH.

  3. Before the user claims the prize, the owner calls the MysteryBox::withdrawFunds function that will send the whole contract balance (0.5 ETH) to the owner's address

  4. Since the contract's balance is zero, the user is unable to claim its winnings making the protocol a fraud

Tools Used

Static analysis

Recommendations

Add checks to ensure all winnings were paid before the funds were withdrawn by the owner. There is also a check needed for the unopened boxes.

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.