The function ChoosingRam::increaseValuesOfParticipants
depends on a random value to select the participant to whom to increase the characteristics. This function generates the random number by using block.timestamp
, block.prevrandao
and the msg.sender
values. Those values are considered a bad source of randomness. The users can predict the outcome and execute the function only if they will be the winners of the challenge. This will help them to become Ram.
Using block.timestamp
as a source of randomness is commonly advised against, as the outcome can be manipulated by calling contracts. Also, for some chains like zkSync block.prevrandao
is a constant value. This will allow the users to predict the result of the calculated number in Line 52 of ChoosingRam.sol
: uint256(keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender))) % 2
. This will give them the chance to execute a challenge only if they are the winners.
The following code demonstrates how an attack can be executed.
The bad source of randomness gives a malicious user the opportunity to become Ram and to get the reward.
Manual review
Consider using a decentralized oracle for the generation of random numbers, such as Chainlinks VRF. The Chainlink VRF gives two methods to request randomness: subscription and direct funding method. They will have their added cost, but will solve the randomness issues of the Dussehra
contract.
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.