The contract has multiple related issues with user tracking and team selection:
Users can select multiple teams after a single deposit by repeatedly calling joinEvent()
The usersAddress array unconditionally adds the user's address without checking for duplicates
The contract emits duplicate joinedEvent events for the same user, creating inconsistent and misleading event logs
These issues stem from the same root cause: lack of state tracking for user participation. This results in corrupted contract state with duplicated user entries, inflated participant counts, inconsistent team selection records, and misleading blockchain events.
Likelihood:
Users naturally attempt to change their team selection before event start, triggering duplicate entries
Impact:
Contract emits misleading joinedEvent logs, potentially breaking off-chain monitoring systems
Gas costs for winner selection scale with duplicate entries, risking transaction failure
Total Share accounting becomes corrupted, potentially leading to problems
User address count becomes inflated, providing inaccurate participation metrics
User deposits once, then calls joinEvent() multiple times with different country selections. Each call overwrites their team choice in userToCountry but adds a duplicate entry to usersAddress. This corrupts the internal accounting, inflates participant counts, and produces multiple identical blockchain events for the same user.
Implement user participation tracking using OpenZeppelin's EnumerableSet library. Add a userSet to track unique addresses with O(1) lookup time while preserving iteration capability. When users join, first check membership in the set before adding. When they cancel, remove them from the set. This provides efficient deduplication without sacrificing the ability to iterate through users during winner selection. EnumerableSet eliminates the need to separately track numberOfParticipants since the library already maintains the collection's length.
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.