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

Bad PRNG for rarity

Summary

The PRNG used to calculate rarity is not strong enough.

Vulnerability Details

rarity is calculated as such:
uint256 rarity = uint256(keccak256(abi.encodePacked(msg.sender, block.difficulty))) % 100;

  • msg.sender, and block.difficulty are all public information.

  • This is similar to my other submission on winnerIndex PRNG. But this uses a different PRNG as mentioned in the comments, so I put it as a separate submission.

  • On top of getting the raffle prize pool, an attacker can predict when the best time is to call the selecterWinner() and mint the rarest NFT, which he can sell for more profit on a secondary market.

Impact

Attacker can predict the next values for the PRNG and place himself so that he can mint the rarest NFT.

Tools Used

Manual Review.

Recommendations

Use Chainlink's PRNG which is unpredictable.

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!