It's a common practice from developers to hash validator-defined values like block.difficulty and block.timestamp for the purpose to use them as Random Number Generators, but this source is not actual randomness and can be exploited if there is enough incentive.
A malicious strategist can generate accounts to figure out in advance which ones will generate a winner with the rarest Puppy. Then he can wait for the raffle to end to execute two transactions:
For the attack to be successful the hacker needs to know he length of the array that he needs to create to make sure the RNGs will select one of this addresses.
Assume a hacker created a bot with a script that will wait for the raffle to end to perform the following tasks:
Paste and execute the following code snippet in PuppyRaffleTest.t.sol to attack the raffle.
Game broken, hackers can become the winners as many times as they want and get the rarest NFT.
VS Code and Foundry.
There are a few things that can be done to mitigate, reduce the attack surface:
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.