Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Invalid

For loops can cause Denial of Service

Summary

Nested for loop can cause DoS and prevent users from entering the raffle.

Vulnerability Details

In the function enterRaffle there is a nested for loop. If the players array is too big, this will cause denial of service.

Impact

Not allow users to enter the raffle.

Tools Used

Manual Review

Recommendations

More optimized approach can be used. Something like this:

  1. Create mapping(address => bool) hasUserEntered;

  2. Remove the second and third for loops.

  3. Add the following to the first loop:

require(!hasUserEntered[newPlayers[i]], "PuppyRaffle: Duplicate player");
hasUserEntered[newPlayers[i]] = true;
Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!