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

Validators can select the Ram they want, due to `block.timestamp`.

Description

block.timestamp is manipulable by validators when they are creating a block.
Any malicious validator can therefore select an interesting number to manipulate the randmness and choose a winner.

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

Moreover, block.prevrandao is always equal to 2500000000000000 on zkSync, which permit to predict the winner.

Risk

Likelyhood: Low

  • A malicious validator has to be chosen for the block and know the bug.

Impact: High

  • Miner can choose the winner (him/her if he/she is malicious).

Recommended Mitigation

Use an oracle like Chainlink to prevent any randomness manipulation.

Updates

Lead Judging Commences

bube Lead Judge over 1 year 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.

n0kto Submitter
over 1 year ago
bube Lead Judge
over 1 year ago
bube Lead Judge over 1 year 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.

Give us feedback!