The MysteryBox contract has a potential issue where funds could become locked, preventing users from claiming their rewards. This situation arises when the contract's balance is insufficient to cover the rewards owed to users.
The issue arises in the reward claiming functions (claimAllRewards and claimSingleReward) when users attempt to withdraw rewards, but the contract lacks sufficient funds to fulfill the claim.
Here’s how the issue can occur:
The contract allows users to win rewards that may add up to significant amounts (e.g., 1 ether). However, there is no guarantee that the contract has enough balance to pay out those rewards when the user attempts to claim them.
If the contract owner only deposited a small amount (e.g., 0.1 ether), but a user is entitled to a much larger reward (e.g., 1 ether), the following line in the reward claim function will fail:
The transaction will fail because there are insufficient funds in the contract to complete the transfer.
Users may not be able to claim their rewards if the contract’s balance is insufficient. This leads to locked rewards that cannot be accessed, even though users are entitled to them.
Manual Review
Before allowing users to claim their rewards, the contract should check if the balance is sufficient to cover the reward amount. If not, an error message should be returned, and the reward should remain unclaimed until the balance is replenished.
claimAllRewards function
claimSingleReward function
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.