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

Users Can Predict Without Registration

Summary

The makePrediction function allows users to make predictions without registering. This bypasses the intended flow and compromises the integrity of the system, allowing unauthorized users to participate without paying the entrance fee and undergoing the necessary registration checks.

Relevant GitHub Link

https://github.com/Cyfrin/2024-07-the-predicter/blob/839bfa56fe0066e7f5610197a6b670c26a4c0879/src/ThePredicter.sol#L85

Impact

Because users do not pay the entrance fee, the contract cannot reward them for correct predictions as intended.

PoC

function test_makePredictionWithoutRegistering() public {
vm.startPrank(stranger);
vm.deal(stranger, 0.0003 ether);
thePredicter.makePrediction{value: 0.0001 ether}(
0,
ScoreBoard.Result.First
);
vm.stopPrank();
}

Tools Used

Manual reading, Foundry

Recommendations

Check if the user is registered with Status.Pending in the makePrediction function.

function makePrediction(
uint256 matchNumber,
ScoreBoard.Result prediction
) public payable {
+ if(playersStatus[msg.sender] != Status.Pending) {
+ revert ThePredicter__NotRegistered();
+ }
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);
}
Updates

Lead Judging Commences

NightHawK Lead Judge 11 months 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.