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

NFTs of different rarity have the same chance of getting minted

Summary

NFTs of different rarity have the same chance of getting minted due to a bad logic implementation:
rarity: uint256 = random_words[0] % 3

Vulnerability Details

from this line of code: rarity: uint256 = random_words[0] % 3
We can deduce that the chances of getting each of the 3 types of NFTs are equal (33.333...% each), unlike what the documentation stated:
70% of chance of getting a common NFT
25% of chance of getting a rare NFT
5% of chance of getting a legendary NFT
The winner will have equal chances of getting these NFTs

Impact

The protocol will have to mint more rare and ledengary NFTs than they expected, and less common NFTs.

Tools Used

Manual Analysis

Recommendations

Make the following changes:

  • rarity: uint256 = random_words[0] % 3

  • percentage: uint256 = random_words[0] % 100

  • rarity: uint256 = 0

  • if percentage < LEGEND_RARITY:

  • rarity = 2
    
  • elif percentage < RARE_RARITY:

  • rarity = 1
    
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Rarity is 1/3 instead of what the docs say

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.