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

Refund does not change the players.length

Summary

SelectWinner function checks the length of the players array to calculate the prizePool and the fees.
Refund function refunds the amount user paid when entering and sets user index to address(0) but this does not change the length of the players array.

Therefore even though the contract paid back the amount, still delivers that amount in the prize pool.

When the selectWinner is called, if the prizePool is larger than the contract balance, the contract is stuck.

Impact

Malicious users can enter and refund multiple times to break the system.

Recommendations

Remove refunded user from the players array instead of setting it to address(0)

    players[index] = players[payees.length - 1];
    players.pop();
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.