Once all matches have had their results set, players with a positive score can claim their rewards through the ThePredicter::withdraw
function. If players withdraw over 50% of the contract's funds before the organizer can call withdrawPredictionFee
, the organizer is unable to claim the required fees due to an arithmetic underflow or overflow revert. This scenario has a higher probability because players are eager to get their rewards, while the organizer might be relaxed, thinking the funds are secure and cannot be taken from them.
Please use and refer to the PoC below that is to be used in ThePredicter.test.sol
file.
We have 2 players called player1 and player2, they both register, have their address approved and submit predictions by calling ThePredictor::makePrediction
function and the organizer then setResult
.
player 1 gets a total points of 11 and player 2 get 10 points in total, player1 gains a majority of 52.4% of the winnings.
player1 claims their rewards by calling ThePredicter::withdraw
, player2 does not claim their rewards.
The organizer attempts to claim the required fees by calling withdrawPredictionFee
but encounters a revert error due to arithmetic underflow or overflow.
This PoC demonstrates how the vulnerability occurs when players withdraw a significant portion of the contract's funds, preventing the organizer from claiming their fees.
causing potential financial losses and disrupting the intended fee collection process. This scenario is likely because players are motivated to withdraw their rewards promptly, potentially leaving the organizer with no access to the funds needed for operational expenses. This causes a high potential financial losses and disrupting the intended fee collection process. This scenario is likely because players are motivated to withdraw their rewards promptly, potentially leaving the organizer with no access to the funds needed for operational expenses.
Manual Review
Recommendations to prevent this bug would be to store a boolean value of if the organizer has claimed the fee's or not, then have a check at ThePredicter::withdraw
before any player can withdraw their rewards.
Add a new storage with a bool
value, pass it through the constructor function and set it to false.
ThePredicter::withdrawPredictionFees
have the boolean value changed to true once the organizer has withdrawn their fees at the bottom to follow CEI
lastly to have a check on the ThePredicter::withdraw
function.
withdrawPredictionFees incorrectly computes the value to be transferred to the organizer, which leads to pending players not being able to cancel their registration, approved players not being able to claim their rewards and other errors.
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.