The joinEvent and _getWinnerShares functions allow users to join multiple times and accumulate duplicate entries in usersAddress, while totalWinnerShares is never reset before aggregation.
This leads to double counting of participants, inflated total shares, and a possible division-by-zero when calculating payouts (e.g., in withdrawal or distribution logic).
Likelihood:
Every time a user calls joinEvent more than once, their address is pushed again, and their shares are added multiple times.
When _getWinnerShares runs, it sums over this inflated list.
Impact:
Winner calculations become incorrect (inflated or unfair payouts).
In cases with no winners, totalWinnerShares == 0, causing division-by-zero and possible contract reverts or denial of withdrawals.
Explanation:
This test shows that calling joinEvent() twice causes the same user’s shares to be counted twice. When _getWinnerShares() runs, it sums over both entries, producing inflated totals and corrupting the reward logic.
Explanation:
This fix introduces a hasJoined mapping to prevent duplicate event joins, ensuring each participant is counted only once.
It also resets totalWinnerShares before summation, preventing accumulated values from previous rounds.
Both changes ensure correct total share calculations and eliminate division-by-zero risk.
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.