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

`winnerIndex` and `rarity` in `selectWinner` not calculated in a secure way allow raffle manipulation

Summary

The vulnerability lies in the generation of a random number in the Solidity smart contract.

The current implementation uses the keccak256 hash of the sender's address, the current timestamp, and the block difficulty to generate a pseudo-random number.

This approach is vulnerable as it can be manipulated by miners or attackers.

Vulnerability Details

The keccak256 hash function is used to generate a pseudo-random number by hashing the concatenation of the sender's address, the current timestamp (block.timestamp), and the block difficulty (block.difficulty).

However, this approach is not truly random and can be manipulated.

Miners have some influence over the block timestamp and block difficulty, which means they could potentially manipulate these values to influence the outcome of the random number generation. This is known as the Miner's Influence vulnerability.

Impact

The impact of this vulnerability is potentially high.

If an attacker or miner can predict or manipulate the outcome of the random number generation, they could unfairly influence the winner of the game. This could lead to a loss of funds for other players and could undermine the integrity and fairness of the game.

Tools Used

  • foundry

Recommendations

Implement a solution like Chainlink VRF to get secure random data to use for the calculation of the raffle winner and the rarity of the token to mint.

Updates

Lead Judging Commences

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