DOS in withdraw function if maxScore
and totalPositivePoints
is zero leads to stuck funds.
ThePredicter::withdraw
function lets players withdraw their funds after all the matches have been played and allocates rewards to the players depending on the prediction of the players. it uses maxScore
to keep track of the maximum number of points by any player and totalPositivePoints
to keep track of the total number of positive points of all players. If the maxScore
is less than zero the totalPositivePoints
will be zero and all the players will be given back their entrance fee.
If the maxScore
is greater than zero the totalPositivePoints
will be greater than zero and the player who is withdrawing has points greater than zero their reward is calculated and sent to them.
Proof of Concept:
Add code to test file
If the maxScore
is zero the totalPositivePoints
will be zero and the reward calculation will result in a calculation by zero hence reverting which will mean none player will be able to withdraw and the funds will be stuck in the contract.
Manual Analysis
Add logic for when the `maxScore` and `totalPositivePoints` are zero.
The checks related to maxScore do not account possible maxScore of zero leading to stuck funds or a division by zero error.
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.