The intended behavior is that a user deposits funds and then calls joinEvent() once to lock in their prediction for the tournament winner.
The problem is that the joinEvent() function has no mechanism to check if a user (msg.sender) has already joined. This oversight allows a single user to call the function multiple times before the event starts. Each subsequent call overwrites their previous team selection and, more critically, adds their address as a duplicate entry to the usersAddress array and incorrectly increments the numberOfParticipants counter.
Likelihood:
The function is public and unprotected. Any user who has deposited can call it multiple times.
Impact:
Unfair Team Switching: Users can change their bet at any time before the event starts, potentially reacting to new information in a way that should be disallowed.
State Corruption: The numberOfParticipants becomes an inaccurate count of total joins rather than unique participants. The usersAddress array contains duplicate data.
Exacerbates a Critical Vulnerability: Each repeated call adds to the usersAddress array, making the unbounded loop in _getWinnerShares() more expensive and bringing the contract closer to the gas limit that triggers the permanent Denial of Service.
The test first establishes a baseline by having a user legitimately deposit funds and join the event, betting on "Brazil." It then demonstrates the exploit by having the same user call joinEvent a second time to switch their bet to "Japan." The test concludes by confirming the negative impacts: the user unfairly changed their team, and the contract's internal accounting is now corrupt, showing two participants instead of one, which worsens a more critical Denial of Service vulnerability.
To prevent this, add a state-tracking mechanism, such as a mapping, to record whether a user has already joined and enforce a one-time participation rule.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.