It is possible for the organizer to be denied withdrawing the prediction fees.
The method ThePredicter::withdrawPredictionFees
is responsible for sending the prediction fees of participants to the organizer.
However, It is possible for the organizer to not be able to withdraw funds if enough players have withdrawn their prize pool depending on the set amount of fees for participation and registration.
The issue is that the following calculation uint256 fees = address(this).balance - players.length * entranceFee;
can return negative value if address(this).balance
is already very low due to players withdrawing their prize pools. This causes revert due to underflow.
The organizer cannot withdraw funds and they remain inaccessible in the contract.
Although the impact is high the likelyhood is low or medium at best.
Manual Review, Foundry
Add the following test case to ThePredicter.test.sol
Execute the command forge test --mt test_organizerIsNotAbleToWithdrawFundsIfTooManyPlayersAlreadyDid -vvvvvvv
From the logs of the command verify that ThePredicter::withdrawPredictionFee
reverted and the reason for that is underflow - [Revert] panic: arithmetic underflow or overflow (0x11)
There are multiple mitigations for this issue:
Allow players to withdraw prize pool funds only after organizer has invoked the method ThePredicter::withdrawPredictionFee
Change the used formula in a way that it uses prediction fees to calculate the amount for transfering. Something like totalPredictionsCount * predictionFee
.
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.