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

ScoreBoard::setPrediction has No Access Control

Summary
The ScoreBoard contract contains a critical vulnerability due to the lack of access control in the setPrediction function. This function allows any external entity to set predictions for any player, which can be exploited to manipulate predictions and potentially disrupt the intended functionality of the contract.

Vulnerability Details


The setPrediction function in the ScoreBoard contract allows anyone to call it and set predictions for any player without any restrictions. This lack of access control means that malicious actors can manipulate predictions, leading to incorrect scores and potential financial losses

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

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;}

Function Accessibility: The setPrediction function is declared as public, which means it can be called by any external address.

Lack of Modifier: There is no access control modifier (like onlyOwner or onlyThePredicter) to restrict who can call this function.

Impact
Prediction Manipulation: Malicious actors can alter predictions for any player, leading to incorrect scores and potential financial losses.

Player Trust: Players may lose trust in the platform if predictions can be tampered with by anyone

Tools Used

Manual Code Review

Recommendations

Add an access control modifier to the setPrediction function to ensure only authorized entities can call it. For example, using the onlyThePredicter modifier to restrict access to the ThePredicter contract.

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.