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

Potential for Double Registration Due to Insufficient Status Check in ` register` Function

Summary

In the current implementation, once a user's status changes from Pending to Approved, they could technically call the register function again because the status check only prevents users with a Pending status from registering again.

Vulnerability Details

The register function only checks if a user’s status is Pending to prevent re-registration. Once a user’s status is changed from Pending to Approved, they can call the register function again, which is unintended behavior and can lead to double registration.

The issue is in this function:
https://github.com/Cyfrin/2024-07-the-predicter/blob/main/src/ThePredicter.sol#L46-L60

function register() public payable {
if (msg.value != entranceFee) {
revert ThePredicter__IncorrectEntranceFee();
}
if (block.timestamp > START_TIME - 14400) {
revert ThePredicter__RegistrationIsOver();
}
if (playersStatus[msg.sender] == Status.Pending) {
revert ThePredicter__CannotParticipateTwice();
}
playersStatus[msg.sender] = Status.Pending;
}

Proof of Concept (PoC)

  1. User calls register and their status is set to Pending.

  2. The organizer approves the user, changing their status to Approved.

  3. The user calls register again and successfully registers, because their status is no longer Pending.

Impact

Users can register multiple times by getting their status approved and then registering again. This can lead to misuse of registration slots and potentially disrupt the intended gameplay mechanics.

Tools Used

Manual Review

Recommendations

Update the register function to check for both Pending and Approved statuses (or any other relevant statuses) to prevent re-registration:

function register() public payable {
if (msg.value != entranceFee) {
revert ThePredicter__IncorrectEntranceFee();
}
if (block.timestamp > START_TIME - 14400) {
revert ThePredicter__RegistrationIsOver();
}
// Prevent re-registration if the status is either Pending or Approved
if (playersStatus[msg.sender] == Status.Pending || playersStatus[msg.sender] == Status.Approved) {
revert ThePredicter__CannotParticipateTwice();
}
playersStatus[msg.sender] = Status.Pending;
}
Updates

Lead Judging Commences

NightHawK Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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