A malicious user can make use of the functions ThePredicter.withdraw and ScoreBoard.setPrediction to withdraw rewards multiple times and drain most / all of the contract funds.
The function ThePredicter.withdraw uses the function ScoreBoard.isElegibleForReward to determine if a player can claim rewards. ScoreBoard.isElegibleForReward checks that the value of ScoreBoard.playersPrediction[player].predictionsCount is greater than one to allow a user to claim rewards, and the function ThePredicter.withdraw sets that value to 0 to prevent a player from claiming the rewards twice. However, the function ScoreBoard.setPrediction can be used by the player to set ScoreBoard.playersPrediction[player].predictionsCount to a value greater than 0, allowing the player to claim the rewards again.
This mechanism can be used multiple times to drain potentially all the funds in ThePredicter
The following PoC based on existing tests in the repository shows how a user can drain the contract by exploiting this vulnerability
Complete loss of funds
Foundry
Keep track explicitly of which users have already withdraw the rewards in ThePredicter using a mapping(address => bool) or similar, and revert in case a player wants to withdraw multiple times.
Optionally
Add events when withdrawals are made to have more visibility of player actions.
`ThePredicter.withdraw` combined with `ScoreBoard.setPrediction` allows a player to withdraw rewards multiple times leading to a drain of funds in the contract.
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.