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

Check `players.length >= 4` is not correct

Summary

Check players.length >= 4 is not correct

Vulnerability Details

require(players.length >= 4, "PuppyRaffle: Need at least 4 players");

This statement requires at least 4 players to participate but what if they were refunded before?
That makes players.length is not changed but the player in that array is not active.
So the logic of the raffle will be wrong.

Impact

Ex: If the player in index 3 has refunded, but with this logic they are the winner so the winning prize will be sent to
address(0) so the prize will lost forever

Tools Used

Manual
Foundry

Recommendations

- require(players.length >= 4, "PuppyRaffle: Need at least 4 players");
+ uint256 numberActivePlayer;
+ for (uint256 i = 0; i < players.length; i++) {
+ if (players[i] != address(0)) {
+ numberActivePlayer++;
+ }
+ }
+ require(numberActivePlayer >= 4, "PuppyRaffle: Need at least 4 active players");
Updates

Lead Judging Commences

Hamiltonite Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

refund-doesnt-reduce-players-array-size-causing-protocol-to-freeze

zero address can win the raffle

Funds are locked to no one. If someone gets the refund issue, they also got this issue. IMPACT: High Likelihood: High

Support

FAQs

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