The protocol makes the assumption that players will either have a positive or negative score when performing calculations in ThePredicter::withdraw
. Specifically, this if check assigns a value to withdraw::reward
:
The check assumes that maxScore
will either be less than or greater than 0. In a situation where all players end up with a score of 0, withdraw will return a [FAIL. Reason: panic: division or modulo by zero (0x12)]
error due to totalShares == 0
.
Considering users should have their entranceFee
returned if maxScore < 0
, we can assume the intentions would be the same if maxScrore == 0
. Not accounting for maxScore == 0
will result in funds being stuck in the contract.
In order for a player to be eligible for withdraw, they must pass this check:
ScoreBoard::isEligibleForReward
requires that a player make at least 1 prediction:
In Predicter::withdraw
, a user's payout is determined by uint256 totalShares = uint256(totalPositivePoints);
. The calculation is made in a for loop checking each players score
ScoreBoard::getPlayerScore
will either return 2
or -1
:
This allows for withdraw::totalPositivePoints
to equal 0. In those situations, withdraw
will return a panic error.
A max number of participants enter the protocol
Each participant predicts one match correctly and two incorrectly leading to a score of 0 for all players
test_NormalWithdraw
will attempt to withdraw but result in a panic error
This is a high impact vulnerability. It can occur if no one gets any predictions correct or if the sum of predictions scores equals zero. The odds of this occurring will depend on how many players enter the protocol, how frequently the players will make predictions (as they are not obligated to predict every match), and the precision of their predictions. The vulnerability will lead to a loss of all funds except for the prediction fees.
Manual Review
Foundry
We need to adjust the logic in Predicter::withdraw
One fix would be to include 0 for maxScore
:
Or account for totalShares
being 0:
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.