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

Insecure way of random number generation using keccak256 can lead to predication of the winner

Summary

Insecure way of random number generation using keccak256 in a Solidity smart contract leads to predictable guessing, potentially compromising fairness and security.

Vulnerability Details

uint256 winnerIndex =
uint256(keccak256(abi.encodePacked(msg.sender, block.timestamp, block.difficulty))) % players.length;
address winner = players[winnerIndex];

The use of keccak256(abi.encodePacked(msg.sender, block.timestamp, block.difficulty)) for random number generation in a Solidity smart contract can result in a significant security vulnerability. Miners can manipulate block.timestamp, enabling them to influence generated numbers and allowing for predictable guessing. This flaw threatens the contract's fairness and exposes it to potential exploitation.

Impact

This vulnerability can lead to unfair outcomes in the smart contract's operations,as malicious users may predict and exploit the generated random numbers. It undermines the contract's integrity and may result in financial losses for participants. Migrating to a more secure random number generation method is crucial to mitigate this impact.

Tools Used

Vs code

Recommendations

Use chainlinks vrf to generate random number.

Updates

Lead Judging Commences

Hamiltonite Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

weak-randomness

Root cause: bad RNG Impact: manipulate winner

Support

FAQs

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