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

Making a prediction through `ThePredicter::makePrediction` within the intended by the protocol time won`t pass the check

Summary

The protocol intends predictions to be made by any approved Player until 19:00:00 UTC on the day of each match.

When user makes a prediction using ThePredicter::makePrediction function an if-statement is put in place to check whether the prediction is made before this hour both in ThePredicter::makePrediction and ScoreBoard::setPrediction

The calculation made for the timestamp check won`t return the correct time window for making predictions, reverting the operation.

Vulnerability Details

By calling the ThePredicter::makePrediction function for the n-th match, the if-statement checks current time > Thu Aug 15 2024 20:00:00 GMT+0000 + n-th match* 19hrs - 19hrs.
For example - the calculation for the third match will result in the check current time > Sat Aug 17 2024 10:00:00 GMT+0000 , thus making predictions impossible between 10:00h and 19:00h.

Paste the following code in the test suite as an example for the 1st and 3rd match.

function test_makePredictionInIntendedTimelineFails() public {
uint256 startTime = 1723752000; //// Thu Aug 15 2024 20:00:00 GMT+0000
// Expected revert for the 1st match
vm.expectRevert(
abi.encodeWithSelector(ThePredicter__PredictionsAreClosed.selector));
vm.startPrank(stranger); // initializing player
vm.warp(startTime-3660); // setting the timestamp to be in the intended window for making predictions Thu Aug 15 2024 18:59:00 GMT+0000
vm.deal(stranger, 1 ether); //dealing funds
thePredicter.makePrediction{value: 0.0001 ether}( //making a prediction by paying the predictionFee and passing vars
0,
ScoreBoard.Result.Draw
);
vm.stopPrank();
// Expected revert for the 3rd match
vm.expectRevert(
abi.encodeWithSelector(ThePredicter__PredictionsAreClosed.selector));
vm.startPrank(stranger);
vm.warp(startTime+313200); // Wed Jul 17 2024 15:00:00 GMT+0000
vm.deal(stranger, 1 ether);
thePredicter.makePrediction{value: 0.0001 ether}(
3,
ScoreBoard.Result.Draw
);
vm.stopPrank();
}

It should be taken into consideration that there is another timestamp check in the external call to ScoreBoard::setPrediction and there is a possibility for conflict.

Impact

Implemented as such, the timestamp check renders making predictions impossible in the intended by the protocol time window.

Tools Used

Foundry, Manual review

Recommendations

Change the calculation of the timestamp to check if current time > Thu Aug 15 2024 00:00:00 GMT+0000 + matchNumber * 24hrs - 5 hrs in the if-statement in l.93::ThePredicter.sol and delete the l.66:ScoreBoard.sol if-statement, or vice versa.

Updates

Lead Judging Commences

NightHawK Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Match timestamps are incorrect

In both contracts there is a similar error in the computation of the timestamps of the matches.

Support

FAQs

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