Inside the 'selectWinner' function we have a logic bug when we are categorizing the different levels of rarity.
'uint256 rarity = uint256(keccak256(abi.encodePacked(msg.sender, block.difficulty))) % 100;
if (rarity <= COMMON_RARITY) {
tokenIdToRarity[tokenId] = COMMON_RARITY;
} else if (rarity <= COMMON_RARITY + RARE_RARITY) { // @audit-issue This should be 'rarity > COMMON_RARITY + <= RARE_RARITY'
tokenIdToRarity[tokenId] = RARE_RARITY;
} else {
tokenIdToRarity[tokenId] = LEGENDARY_RARITY;
}'
Here you can see the logic flaw being found when we are categorizing the rarity levels.
It should be 'else if (rarity > COMMON_RARITY + <= RARE_RARITY)' instead of 'else if (rarity <= COMMON_RARITY + RARE_RARITY)'
Medium as this could lead to a COMMON_RARITY being classified as a RARE_RARITY nft.
Vs Code
Use 'else if (rarity > COMMON_RARITY + <= RARE_RARITY)' instead of 'else if (rarity <= COMMON_RARITY + RARE_RARITY)'
71% 25% 4%
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.