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

RamNFT::getCharacteristics can return characteristics of inexisting NFTs

Summary

RamNFT::getCharacteristics returns characteristics of NFT that is not yet created when passing tokenId argument that does not match any Ram NFT.

Vulnerability Details

When calling RamNFT::getCharacteristics with value for tokenId that is greater than RamNFT::tokenCounter, it returns characteristics of NFT that doesn't exist (all of it's properties have default value - false).

Impact

It may confuse the user that there exists Ram NFT with such tokenId.

Tools Used

Manual review

Proof of Concept:

  1. Add the following test case to: Dussehra.t.sol:

function test_getCharacteristicsForInexsitingNFT() public {
vm.startPrank(player1);
assertEq(ramNFT.tokenCounter(), 0);
assertEq(ramNFT.getCharacteristics(104).isAatmavan, false);
}
  1. Run the following command: forge test --mt test_getCharacteristicsForInexsitingNFT

Recommendations

Revert if tokenId matches existing Ram NFT:

error RamNFT__NotOrganiser();
error RamNFT__NotChoosingRamContract();
+ error RamNFT__TokenIdDoesNotMatchNFT(uint256 tokenId);
function getCharacteristics(uint256 tokenId) public view returns (CharacteristicsOfRam memory) {
+ if (tokenId > getNextTokenId()) {
+ revert RamNFT__TokenIdDoesNotMatchNFT(tokenId);
+ }
return Characteristics[tokenId];
}
Updates

Lead Judging Commences

bube Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Info/Gas/Invalid according to docs

Support

FAQs

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