Mystery Box

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

Low contract balance can block players from claming their rewards

Summary

If the owner only sends 0.1 ether to the contract during the constructor and the first player wins a reward larger than 0.1 ether, the player won’t be able to claim their reward due to insufficient contract balance. Additionally, the owner can't easily add more funds to the contract because there’s no payable function for funding it directly (the owner could repeatedly call buyBox, but that’s not the intended purpose of this function).

Impact

Players may be unable to claim their rewards.

Recommendations

Prevent users from buying a box if there’s a risk that the contract won’t have enough funds to pay the rewards and add funding function. The new condition should be added to the MysteryBox::buyBox function: require((numberOfBoxesInCirculation + 1) * maxReward <= address(this).balance + boxPrice)

Updates

Lead Judging Commences

inallhonesty Lead Judge
11 months ago

Appeal created

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Protocol should have a higher initial balance to prevent prize withdrawing problems

Support

FAQs

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