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.
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.
A player aware of this vulnerability can call PuppyRaffle::selectWinner
, so that he would always win.
VSCode
Foundry
Implement Chainlink VRF2
Root cause: bad RNG Impact: manipulate winner
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.