The selectWinner
function in the provided code uses the block.timestamp
to determine whether the raffle is over. However, this approach is vulnerable to manipulation by validators, as they can control the timestamp included in the block. This vulnerability opens up the possibility of validators manipulating the winner selection time.
The vulnerability lies in the line require(block.timestamp >= raffleStartTime + raffleDuration, "PuppyRaffle: Raffle not over");
. By relying solely on block.timestamp
, the function assumes that the timestamp included in the block is accurate and cannot be manipulated. However, validators have the ability to set the timestamp within certain limits, allowing them to potentially influence the outcome of the raffle.
The impact of this vulnerability is that validators can manipulate the winner selection time, leading to various consequences, including:
Unfair advantage for certain participants if validators intentionally delay the winner selection.
End the Raffle before expected time.
Undermining the transparency and integrity of the raffle process.
Manual review.
To mitigate the vulnerability and ensure the fairness of the raffle, the following recommendations are suggested:
Implement a more secure and tamper-proof method of determining the end time of the raffle. Consider using an external time oracle (like Chainlink).
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.