Blank spaces in the players array after refunds are not accounted for in the selectWinner function. The result of this is one of two things:
address(0) is selected as a winner and the prizePool/NFT is burned.
a remaining player is selected as a winner, but the prizePool is not representative of the entrants of the raffle any longer. The transfer of the prizePool will either fail, if funds are not available on the contract, or succeed, if funds are available, but because of player refunds, this will be taking the prizePool from other aspects of the protocol - effectively stealing funds.
The above test shows that, despite the refunds in the raffle, the winner is paid entranceFee * 4 - fees
. The additional prizePool is being pulled from balances that remained on the contract.
Similarly the below test shows that selectWinner will attempt to transfer/mint to address(0), resulting in failure.
Burned or lost protocol funds. Any balance remaining on the contract is at risk to being paid out to raffles which do not account for refunds when selecting a winner.
Foundry
Manual Review
Assure that refunded users are properly removed from the active players array. Since totalAmountCollected
and prizePool
are derivative of players.length
, this should resolve these potential errors.
Funds are locked to no one. If someone gets the refund issue, they also got this issue. IMPACT: High Likelihood: High
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.