Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

Lack of Access Control in `setPrediction` function allows any user to update predictions of any other player

Summary

The setPrediction function in the ScoreBoard contract lacks access control, allowing any user to modify the predictions of any player. This security vulnerability can lead to unfair gameplay and manipulation of scores.

Vulnerability Details

The setPrediction function does not restrict who can update player predictions, which poses a significant risk. Unauthorized users could exploit this to alter predictions for any player, potentially impacting their scores and overall gameplay fairness.

The issue is in this function:

https://github.com/Cyfrin/2024-07-the-predicter/blob/main/src/ScoreBoard.sol#L61-L75

function setPrediction(
address player,
uint256 matchNumber,
Result result
) public {
if (block.timestamp <= START_TIME + matchNumber * 68400 - 68400)
playersPredictions[player].predictions[matchNumber] = result;
playersPredictions[player].predictionsCount = 0;
for (uint256 i = 0; i < NUM_MATCHES; ++i) {
if (
playersPredictions[player].predictions[i] != Result.Pending &&
playersPredictions[player].isPaid[i]
) ++playersPredictions[player].predictionsCount;
}
}

Any user can call the setPrediction function with any player's address and modify their predictions.
This can be exploited to change the predictions of other players, which can impact their scores and eligibility for rewards.

Impact

Allows unauthorized users to manipulate predictions of other players, which can lead to unfair advantage or loss of integrity in the prediction process.

Tools Used

Manual Review

Recommendations

Add an appropriate access modifier to this function.

Updates

Lead Judging Commences

NightHawK Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

setPrediction lacks access control

setPrediction has no access control and allows manipulation to Players' predictions.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.