The selectWinner
function in the smart contract uses the modulo operation with the size of the players
array to calculate the winnerIndex
. However, if there are zero addresses present in the players
array, it is possible for an empty address to be selected as the winner. This can lead to unfair outcomes for active players.
The issue lies in the selectWinner
function, the winner select calculation does not consider the presence of empty addresses within the array. Consequently, an empty address can be chosen as the winner, causing active players to be unfairly excluded from winning. To resolve this, the function should create a separate array that only includes non-empty addresses for selecting the winner.
Unfair Results: The presence of empty addresses allows the selection of an empty address as the winner, which is unjust for active participants.
Loss of Trust: Unfair outcomes undermine trust in the smart contract and the integrity of the raffle system.
Manipulation: Malicious actors may exploit this vulnerability by intentionally adding empty addresses to increase their chances of winning or disrupt the fairness of the raffle.
Manual Review
To address this vulnerability, the selectWinner
function should be modified as follows:
Create a new array, named activePlayers
, to store the non-empty addresses from the players
array.
Iterate over the players
array and populate the activePlayers
array with the non-empty addresses.
Calculate the winnerIndex
using the size of the activePlayers
array instead of the players
array.
Select the winner from the activePlayers
array using the calculated winnerIndex
.
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.