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

`COMMON_RARITY` & `RARE_RARITY` selections will overlap due to logic error in `if else` block.

Summary

COMMON_RARITY & RARE_RARITY selections will overlap due to logic error in if else block.

Vulnerability Details

You can see below on the else if line that the rarity range is determined by combining the range for COMMON_RARITY with range for RARE_RARITY, which is logically incorrect.

Current implementation:

if (rarity <= COMMON_RARITY) {
tokenIdToRarity[tokenId] = COMMON_RARITY;
} else if (rarity <= COMMON_RARITY + RARE_RARITY) { << this line is logically incorrect in terms of entire if block
tokenIdToRarity[tokenId] = RARE_RARITY;

Impact

Common rarity NFTs could be allocated to winners when rare rarity NFTs should be allocated.

Tools Used

VSC.

Recommendations

if (rarity <= COMMON_RARITY) {
tokenIdToRarity[tokenId] = COMMON_RARITY;
-- } else if (rarity <= COMMON_RARITY + RARE_RARITY) {
++ } else if (COMMON_RARITY < rarity <= COMMON_RARITY + RARE_RARITY) {
tokenIdToRarity[tokenId] = RARE_RARITY;
Updates

Lead Judging Commences

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

wrong nft rarity

71% 25% 4%

Support

FAQs

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