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

`PuppyRaffle:: selectWinner` On Chain randomness is predictable, can be manipulated by miners to win the pot

Summary

In selectWinner function, on chain approach is used to select winner, which is highly risky as the used variables to calculate randomness can be manipulated by miners leads to predictable result and one person winning again and again.

Vulnerability Details

The smart contract selects raffle winners using keccak256(abi.encodePacked(...)) , with input data that includes block.timestamp and block.difficulty. These values are not suitable for generating secure random numbers because:

  • block.timestamp can be influenced by miners, leading to predictable results.

  • block.difficulty changes slowly over time, reducing randomness.

Impact

If rewards are decent enough, Miner will manipulate the values to his favour to win the pot.

Tools Used

Manual Review

Recommendations

Using an external Oracle like Chainlink VRF is recommended to generate randomness. This will ensure that lottery works in transaparent way without being the risk of manipulation.

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 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.

Give us feedback!