The buyBox() function in the MysteryBox contract does not check the availability of rewards in the pool, allowing users to buy boxes even when there may not be enough rewards left. This can lead to a situation where users purchase boxes that cannot be opened, leading to potential frustration and financial loss for users.
The buyBox() function currently allows users to purchase boxes without verifying whether there are any rewards available in the rewardPool. Since the reward pool could run out of rewards, users might continue to purchase boxes that they cannot open due to the lack of available rewards. This oversight could lead to user dissatisfaction and potential misuse of the system, where users are charged for boxes but are unable to receive rewards.
Initial Setup:
The rewardPool contains a finite number of rewards.
Execution:
Users continue calling buyBox() even after all the rewards have been claimed from the rewardPool.
Outcome:
Users purchase boxes without receiving rewards, as the reward pool is empty. This leads to a situation where users pay for boxes that cannot be opened due to the lack of available rewards.
Over-purchasing: Users can purchase more boxes than there are rewards in the pool, leading to a situation where boxes cannot be opened because the rewards are exhausted.
User Dissatisfaction: Users who purchase boxes and are unable to open them due to the lack of rewards could become frustrated, potentially resulting in financial loss for the users.
Unintended System Behavior: Without checks on the availability of rewards, the system does not properly limit the number of boxes sold based on the remaining rewards, leading to uncontrolled box purchases.
Step 1: The rewardPool contains a limited number of rewards (e.g., 10 rewards).
Step 2: Users continue to call buyBox() even after all rewards have been claimed.
Expected Outcome: The transaction should revert when there are no more rewards available.
Actual Outcome: The transaction succeeds, users purchase boxes, but there are no rewards left to claim, leading to an unfulfilled purchase.
Manual review
Add a dynamic check to ensure the availability of rewards before allowing users to purchase boxes:
Additionally, when a box is opened, the corresponding reward should be removed from the reward pool to ensure that the number of rewards matches the number of boxes sold.
Reward Removal Logic:
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.