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

The RapBattle Winner can be Predicted due to Random Weakness in selecting the winner of the RapBattle in the `RapBattle.sol::_battle` function

Summary

Weak Randomness in the RapBattle.sol::_battle can result in a predictable winner or be influenced by users.

Vulnerability Details

Because hashing block.timstamp, msg.sender, block.prevando does not create a random number.

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

Instead, it creates a predictable number, Malicious contracts can manipulate this function and predict the winner of the rapBattle. This can break the system eventually

Impact

A Malicious attacker can attack this function and be able to predict the winner of the rapBattle. This will break the system and reward the wrong users in the rapBattle.

Tools Used

Manual Review

Recommendations

Weak Randomness is a popular attack vector, so it is always advised to use Oracles like Chainlink VRF to generate random numbers for on-chain purposes.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Weak Randomness

Support

FAQs

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