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

'enterRaffle' could spend lots of gas and not allow new senders to enter the raffle

Summary

Gas inefficient order of loops 'enterRaffle'

Vulnerability Details

Function 'enterRaffle' first stores the input in a state variables (which incurs considerable cost) and after that checks for duplicates which would revert the costly storage but the gas would have already been spent.

Impact

Having in minds that there is a mechanism in the contract to leave duplicates (address(0)) in the 'players' array this logic is guaranteed to spend senders gas and never allow them to actually enter the raffle.

Tools Used

Manual review

Recommendations

I would suggest to reconsider the type of structure that is used for storing the players and/or remove the possibility to refund users (which enters duplicate address(0) in the 'players' structure).

Updates

Lead Judging Commences

Hamiltonite Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

denial-of-service-in-enter-raffle

Support

FAQs

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