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

Incorrect verification of deadline to set prediction in the `ScoreBoard::setPrediction`

Description

The function ScoreBoard::setPrediction has a incorret verification of deadline to set prediction

Impact

The players may not be able to set predictions and the platform will not receive the predictions

Proof Of Concept

// simulate with the match number 1
let time = 1723752000 + 0 * 68400 - 68400
// time: 1723683600
let date = new Date(time * 1000);
// date: Wed Aug 15 2024 01:00:00
// but the output needs to be: Wed Aug 15 2024 19:00:00
// simulate with the match number 2
let time = 1723752000 + 1 * 68400 - 68400
// time: 1723752000
let date = new Date(time * 1000);
// date: Thu Aug 15 2024 20:00:00
// but the output needs to be: Wed Aug 16 2024 19:00:00

Recommended Mitigation

Fix the check in the ScoreBoard::setPrediction:

function setPrediction(
address player,
uint256 matchNumber,
Result result
) public {
+ if (block.timestamp <= START_TIME + matchNumber * 86400 - 3600)
+ playersPredictions[player].predictions[matchNumber] = result;
- 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;
}
}
Updates

Lead Judging Commences

NightHawK Lead Judge about 1 year 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.