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

`HorseStore.huff::tokenURI()` works for unminted NFTs

Summary

While the Solidity version of the HorseStore NFT collection only returns a token URI if the NFT has been minted, this is not true for the Huff version.

Impact

Even though the token URI doesn't seem to be important for this NFT collection, the Huff logic when an NFT is not minted is different between the Solidity and the Huff versions.

Tools Used

Foundry and manual analysis.

Proof of Concept

Add the following test function to the Base_Test.t.sol file:

function testMetadata() public {
assertEq(keccak256(abi.encode(horseStore.name())), keccak256(abi.encode("HorseStore")));
assertEq(keccak256(abi.encode(horseStore.symbol())), keccak256(abi.encode("HS")));
assertEq(keccak256(abi.encode(horseStore.tokenURI(1))), keccak256(abi.encode("")));
// @audit On Huff, tokenURI() can be called with NFTs that are not minted yet. The solidity version requires the NFT to have an owner.
}

Then run: forge test --mt testMetadata -vvvv

It is possible to observe that the Solidity version reverts with an error ERC721NonexistentToken while the Huff version returns "" as if the token existed.

Recommendations

Before returning any token URI, it is recommended to check whether the NFT has been minted or not like in the Solidity version.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice
EloiManuel Submitter
over 1 year ago
inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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