Summary
The prediction deadline is not calculated correctly.
Vulnerability Details
According to the documentation, "Every day from 20:00:00 UTC one match is played. Until 19:00:00 UTC on the day of the match, predictions can be made by any approved Player." Hence the prediction deadline is an hour before the match starts.
The calculation for the prediction deadline:
if (block.timestamp > START_TIME + matchNumber * 68400 - 68400) {
Proof of Concept:
Add code to test file
function test_makePredictionAfterDeadline2() public {
vm.startPrank(stranger);
vm.warp(1);
vm.deal(stranger, 1 ether);
thePredicter.register{value: 0.04 ether}();
vm.stopPrank();
vm.startPrank(organizer);
vm.warp(2);
thePredicter.approvePlayer(stranger);
vm.stopPrank();
vm.warp(1723752000 - 18000);
vm.expectRevert(
abi.encodeWithSelector(ThePredicter__PredictionsAreClosed.selector)
);
vm.startPrank(stranger);
thePredicter.makePrediction{value: 0.0001 ether}(
0,
ScoreBoard.Result.Draw
);
vm.stopPrank();
}
function test_makePredictionAfterDeadline3() public {
vm.startPrank(stranger);
vm.warp(1);
vm.deal(stranger, 1 ether);
thePredicter.register{value: 0.04 ether}();
vm.stopPrank();
vm.startPrank(organizer);
vm.warp(2);
thePredicter.approvePlayer(stranger);
vm.stopPrank();
vm.warp(1723752000 + 18000);
vm.expectRevert(
abi.encodeWithSelector(ThePredicter__PredictionsAreClosed.selector)
);
vm.startPrank(stranger);
thePredicter.makePrediction{value: 0.0001 ether}(
1,
ScoreBoard.Result.Draw
);
vm.stopPrank();
}
Impact
The calculation for the prediction deadline results in the deadline being 19 hours(68400) for the first match and increasing by 5 hours for each subsequent matches.
Tools Used
Manual Analysis
Recommendations
Change the calculation for the prediction deadline.
- if (block.timestamp <= START_TIME + matchNumber * 68400 - 68400)
+ if (block.timestamp <= (START_TIME * (matchNumber + 1)) - 3600)