totalWinnerShares by looping over the full usersAddress array during finalization, rather than maintaining aggregated share totals as users join. Because this array can grow indefinitely and may contain duplicate entries, the loop becomes gas-heavy and inaccurate. As a result, setWinner() can fail due to gas exhaustion, preventing the event from being finalized. This blocks all user withdrawals and can also inflate or distort winner share calculations, leading to incorrect payout distribution.The contract should determine totalWinnerShares efficiently at finalization, using an accurate, constant-time calculation so the owner can always call setWinner() and winners can withdraw their correct share safely.
_getWinnerShares() loops over an ever-growing usersAddress array and accumulates values without resetting, causing gas-based DoS when setWinner() is called and incorrect share totals due to duplicate entries—leading to failed finalization and unfair or blocked withdrawals.
Likelihood:
The issue occurs once many users join the event, causing the usersAddress array to grow large enough that _getWinnerShares() consumes excessive gas during setWinner().
Even if user's call cancelParticipation the function doesn't clear the array and on top of that one user can use joinEvent and can vote again and again.
Impact:
setWinner() fails due to gas exhaustion, preventing the event from finalizing and leaving all user funds locked in the contract.
Although The test coudn't prove this but it is possible. For reference you can check Ethernaut Level 9: King
This test proves that EVM Gas error is a real thing
The recommended mitigation can be that instead of use mapping to check which county get how much votes and fund
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.