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

Non-Players Can Make Predictions and Invalid Predictions Are Accepted in The `makePrediction` Function

Summary

The makePrediction function in the ThePredicter contract allows any user to make a prediction, even if they are not approved as a player by the organizer. Additionally, it does not prevent users from setting their prediction to the default Pending value, which could be problematic.

Vulnerability Details

  1. Unauthorized Prediction Submission: The function does not check if the caller is an approved player. As a result, users who have not been approved by the organizer can make predictions, violating the expected participation criteria.

  2. Invalid Prediction Values: The function does not enforce that the prediction must be different from the default Pending value. This allows users to submit a prediction with the default value, which should be avoided since predictions should be actively set by players.

Code Snippet

ThePredicter.sol contract

function makePrediction(
uint256 matchNumber,
ScoreBoard.Result prediction
) public payable {
if (msg.value != predictionFee) {
revert ThePredicter__IncorrectPredictionFee();
}
if (block.timestamp > START_TIME + matchNumber * 68400 - 68400) {
revert ThePredicter__PredictionsAreClosed();
}
scoreBoard.confirmPredictionPayment(msg.sender, matchNumber);
scoreBoard.setPrediction(msg.sender, matchNumber, prediction);
}

Tool used

Manual Review

Impact

The issues in this function lead to:

  • Unauthorized Predictions: Non-approved users can submit predictions, which could lead to unfair gameplay and manipulation.

  • Incorrect Prediction Handling: Users can set their prediction to Pending, which should not be allowed if a prediction is being actively made. This can affect the accuracy of the prediction records and rewards distribution.

Recommendations

  • Check Player Approval: Ensure that the user making the prediction is an approved player. This check should verify if the user has been approved by the organizer before allowing them to make a prediction. This can be done by using the playersStatus mapping playersStatus[msg.sender] = Status.Approved

  • Validate Prediction Values: Prevent users from setting their prediction to the default Pending value prediction != ScoreBoard.Result.Pending

Updates

Lead Judging Commences

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

makePrediction lacks access control

makePrediction has no access controls and any unapproved user can make predictions causing an incorrect calculation and distribution of rewards.

Support

FAQs

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