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

`RamNFT::getCharacteristics` return invalid information for non-existent tokens

Description

RamNFT::getCharacteristics accepts any token in parameters. Since there is no check to assess the token exists, any user can ask the caracteristics of an non-minted token and will get an answer.
It will lead to confusion or unexpected behavior if this function is used in an other contract.

function getCharacteristics(uint256 tokenId) public view returns (CharacteristicsOfRam memory) {
@> return Characteristics[tokenId];
}

Especially in this contract it is called by ChoosingRam::increaseValuesOfParticipants and is one of the two root cause allowing a big impact:
People can fight against a non-existant player.

function increaseValuesOfParticipants(uint256 tokenIdOfChallenger, uint256 tokenIdOfAnyPerticipent)
public
RamIsNotSelected
{
...
} else {
@> if (ramNFT.getCharacteristics(tokenIdOfAnyPerticipent).isJitaKrodhah == false){
ramNFT.updateCharacteristics(tokenIdOfAnyPerticipent, true, false, false, false, false);
}
...
}
}

Risk

Likelyhood: High

  • Anyone can call getCharacteristics and increaseValuesOfParticipants with a non-existing tokenIdOfAnyPerticipent.

Impact: High

  • Low: return incorrect data for non-existing tokens.

  • High, combined with the bug in if (tokenIdOfAnyPerticipent > ramNFT.tokenCounter()) because it permits to fight a non-existing token and increase its values.

Recommended Mitigation

getCharacteristics must check if the token is valid or exists before returning any data, and revert instead.
Since the Characteristics mapping is public, the same will happen reading it directly: make the mapping private.

Updates

Lead Judging Commences

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

Info/Gas/Invalid according to docs

n0kto Submitter
over 1 year ago
n0kto Submitter
over 1 year ago
bube Lead Judge
over 1 year ago
bube Lead Judge over 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.

Give us feedback!