The duplicate check in enterRaffle() loops over the entire players array (all previously entered players, not just the new ones) with a nested loop — O(n²) comparisons. Gas grows quadratically with the raffle size.
Likelihood: High — the cost grows deterministically with every entry; no attacker is needed.
Impact: Medium — entering a single player costs 128k gas with 10 players in the raffle, 1.2M with 50, 4.5M with 100, and 17.3M with 200 (over half the ~30M block gas limit). Past ~300 players a single entry exceeds the block limit entirely and nobody can enter anymore. The raffle also becomes unfair: later players pay far more gas than early ones for the same ticket.
The test measures the gas of entering one additional player at increasing raffle sizes and asserts the cost explodes (gas at 200 players is more than 10x the gas at 10 players).
Track duplicates with a mapping(address => bool) (O(1) lookup) instead of a nested loop over the whole array.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.