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

Weak source of randomness in `ChoosingRam::selectRamIfNotSelected` function can lead to unfair selection of Ram.

Summary

The ChoosingRam::selectRamIfNotSelected function uses a weak source of randomness derived from block.timestamp and block.prevrandao to select the Ram. This method is susceptible to miner manipulation, allowing potentially unfair advantages in selecting the Ram.

Vulnerability Details

function selectRamIfNotSelected() public RamIsNotSelected OnlyOrganiser {
if (block.timestamp < 1728691200) {
revert ChoosingRam__TimeToBeLikeRamIsNotFinish();
}
if (block.timestamp > 1728777600) {
revert ChoosingRam__EventIsFinished();
}
// @audit - weak randomness
@> uint256 random = uint256(keccak256(abi.encodePacked(block.timestamp, block.prevrandao))) % ramNFT.tokenCounter();
selectedRam = ramNFT.getCharacteristics(random).ram;
isRamSelected = true;
}

ChoosingRam::selectRamIfNotSelected function allows to select Ram. Winner is being determined by random number which represent token id of selected Ram.

Problem arises because random number is being generated by values that could be manipulated by miner: block.timestamp, block.prevrandao. It means that selected Ram can be manipulated which is unfair advantage. Only organiser can call this function but still it opens the way for miners to manipulate selected Ram they want.

Impact

Randomness is weak, malicious miner (or organiser) can potentially select specific Ram for winner, gaining strong advantage over other participants.

Tools Used

Manual review

Recommendations

Recommendation is to use Chainlink VRF to generate random numbers.

Updates

Lead Judging Commences

bube Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Weak randomness in `ChoosingRam::selectRamIfNotSelected`

The organizer is trusted, but the function `ChoosingRam::selectRamIfNotSelected` uses a way to generate a random number that is not completely random.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.