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

Weak Randomness in `Dussehra::increaseValuesOfParticipants` and `Dussehra::selectRamIfNotSelected` allow users to Manipulate Outcomes and Undermine Protocol Integrity

Summary

The generation of a random number in the code is achieved by hashing msg.sender, block.timestamp, and block.prevrandao together. However, this approach results in a random number that is predictable, which is not ideal for randomness. The predictability stems from the fact that malicious users can either manipulate these values or anticipate them in advance, thereby gaining an unfair advantage in becoming the chosen ram.

Here's the specific segment of the code responsible for the random number generation:

uint256 random = uint256(keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender))) % 2;

This portion of the code is crucial as it directly influences the selection of the ram, making it a potential target for exploitation.

Vulnerability Details

  1. Users can anticipate the block.timestamp and block.prevrandao values, which allows them to strategize their participation. For more information, you can refer to this article on prevrandao.

  2. Users have the ability to adjust their msg.sender value, which could lead to their address being selected as the Ram.

  3. Outcome Prediction:
    If a user can foresee the random number, they can sway the result of the increaseValuesOfParticipants function. In particular, they can control the update of the challenger or participant's traits.

It's important to note that using on-chain values for generating randomness is a known security risk in blockchain technology.

Impact

Any user can influence becoming the chosen ram. Making the entire protocol worthless if it becomes a gas war as to who is the chosen ram

Tools Used

Foundry

Recommendations

Consider using Chainlink VRF or a similar verifiable random function to provide truly random numbers that cannot be predicted.

Updates

Lead Judging Commences

bube Lead Judge
about 1 year ago
bube Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Weak randomness in `ChoosingRam::increaseValuesOfParticipants`

Support

FAQs

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