Funds remain stucked in the contract ThePredicter
due to division by 0 when the max score
The method ThePredicter::withdraw
allows players to withdraw their part of the pool if eligable.
However, it does not handle well the case in which the max score of all players is 0. That's because the formula it uses when max score is 0 or larger, relies on the denominator (the max score) to not be 0. This causes division by zero and the method does not transfer any amount to the participants leaving the contract funds to remain stucked.
Funds remain stucked in the contract ThePredicter
and players are not allowed to withdraw their prize pool.
Manual review, Foundry
Follow these steps:
Add the following test case to ThePredicter.test.sol
:
Run the following command to execute the test case: forge test --mt test_zeroMaxScore -vvvvvvvv
Verify that the test executed successfully (meaning that no funds were withdrawn) and that the culprit behind is division by 0 (contained in the logs as - [Revert] panic: division or modulo by zero (0x12))
Handle the max score equal to zero case the same way as it's done for negative numbers:
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.