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

The player can make prediction without pay prediction fee on `ScoreBoard::setPrediction`

Description

The player can make prediction without pay prediction fee on ScoreBoard::setPrediction.

Impact

The protocol will miss the prediction fee from player.

Proof Of Concept

Add the following code to the test/ThePredicter.test.sol:

function test_PlayerCanNotEditPredictionWithoutPayPredictionFee() public {
// setup stranger
vm.deal(stranger, 1 ether);
// register stranger
vm.startPrank(stranger);
thePredicter.register{value: 0.04 ether}();
vm.stopPrank();
// stranger is approved
vm.startPrank(organizer);
thePredicter.approvePlayer(stranger);
vm.stopPrank();
// stranger set prediction without pay prediction fee
vm.startPrank(stranger);
vm.expectRevert();
scoreBoard.setPrediction(msg.sender, 0, ScoreBoard.Result.Second);
vm.stopPrank();
}

Run with: forge test --match-test test_PlayerCanEditPredictionWithoutPayFeeIfAlreadyPaid -vvv

Recommended Mitigation

In the src/ScoreBoard.sol:

  • Create a new error:

error ScoreBoard__UnauthorizedAccess();
+ error ScoreBoard__PredictionFeeShouldBePaid();
  • Add the check in ScoreBoard::setPrediction:

function setPrediction(
address player,
uint256 matchNumber,
Result result
) public {
+ if(playersPredictions[player].isPaid[matchNumber] == false) {
+ revert ScoreBoard__PredictionFeeShouldBePaid();
+ }
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 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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