The ScoreBoard::setPrediction
allows a user to change their prediction after it has been set without repaying the prediction fee. However, lack of access control allows anyone to change the prediction of any user.
Relevant link - https://github.com/Cyfrin/2024-07-the-predicter/blob/839bfa56fe0066e7f5610197a6b670c26a4c0879/src/ScoreBoard.sol#L61
In the function above, we can see that it has a player parameter which is supposed to be used by the ThePredicter
contract to set a prediction for a user. However, since it does not have any access control, it allows anyone to set the prediction for any user.
A malicious user can change a user's prediction. This breaks the desired logic. It can be demonstrated with the following POC.
The impact is demonstrated with the following test, which can be executed with forge test --mt testAnyoneCanChangePrediction
.
The test above proves that anyone can set a prediction for a user.
Manual Review, Foundry
Add a security check which ensures only the thePredicter contract can set anyone's prediction, while a player can only change their own prediction.
After this code is added, it can be confirmed that a player can only change their prediction and everything else is working as expected. Add the following test and run forge test
.
setPrediction has no access control and allows manipulation to Players' predictions.
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.