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

NFT rarity is not the same for all NFT

Summary

The documentation states:
You'll see the tokenURI function returns one of 4 random Mondrian art paintings. Each should have equal distribution and be random.

The tokenURI function is actually not distributing the NFT with 25% chance for each.

Vulnerability Details

Impact

Instead of having all the NFT with the same rarity, some will be more rare than others.

Tools Used

Manual review

Recommendations

Change the modulo to match the number of NFT.

function tokenURI(uint256 tokenId) public view override returns (string memory) {
if (ownerOf(tokenId) == address(0)) {
revert MondrainWallet__InvalidTokenId();
}
- uint256 modNumber = tokenId % 10;
+ uint256 modNumber = tokenId % 4;
if (modNumber == 0) {
return ART_ONE;
} else if (modNumber == 1) {
return ART_TWO;
} else if (modNumber == 2) {
return ART_THREE;
} else {
return ART_FOUR;
}
}
Updates

Lead Judging Commences

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

NFT's should have equal distribution

Support

FAQs

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