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

Winner is selecting by pseudo-random on-chain data

Summary

As on-chain data is never truly random, but only pseudo-random, the caller of PuppyRaffle::selectWinner could call this function maliciously call this function when the data is right to let him win.

Vulnerability Details

The expression uint256(keccak256(abi.encodePacked(msg.sender, block.timestamp, block.difficulty))) is deterministic and can be calculated in advance (for example in a seperate contract) by the PuppyRaffle::selectWinner caller. This will lead to the winner being known before calling the function.

Impact

A player aware of this vulnerability can call PuppyRaffle::selectWinner, so that he would always win.

Tools Used

  • VSCode

  • Foundry

Recommendations

Implement Chainlink VRF2

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.