The setWinner() function iterates through all users in usersAddress[] array to calculate totalWinnerShares. With sufficient participants, this loop will exceed the block gas limit, permanently preventing the winner from being set.
Normal behavior expects that critical admin functions like setWinner() should be executable regardless of the number of participants. The function should use constant-time operations or batched processing.
The current implementation uses an unbounded loop in _getWinnerShares() that iterates over every address in usersAddress[]. As this array grows, gas consumption increases linearly until it exceeds the block gas limit.
Likelihood:
Popular tournaments with hundreds or thousands of participants will hit this issue
Bug #1 (multiple joinEvent calls) exacerbates this by adding duplicate entries
No limit on the number of participants enforced in the contract
Attack vector where malicious user creates hundreds of small deposits to DOS the system
Impact:
Winner can never be set once participant count exceeds gas limit threshold (~2000-5000 users depending on gas costs)
All participant funds permanently locked in contract
No winners can withdraw, no resolution possible
Contract becomes completely non-functional
Entire tournament pool lost with no recovery mechanism
Owner cannot salvage the situation even with admin privileges
Reputational damage and potential legal liability
Attackers can intentionally DOS the system by creating many small deposits
Track winner shares incrementally during joinEvent
Best Practice: as it provides O(1) complexity and eliminates the DOS vector entirely.
The _getWinnerShares() function is intended to iterate through all users and sum their shares for the winning country, returning the total.
The _getWinnerShares() function is intended to iterate through all users and sum their shares for the winning country, returning the total.
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.