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

Unable to mint NFT for the second time in huff version

Summary

The contract can only mint the NFT once, and was unable to mint other NFT due to bad implementation of MINT function in huff.

Vulnerability Details

The following fuzzing test will fail in huff version:

function testMintHorseMultipleTimes(uint256 n) public {
vm.assume(n<=5);
vm.startPrank(user);
for(uint256 i=0;i < n;i++)
horseStore.mintHorse();
vm.stopPrank();
assertEq(horseStore.balanceOf(user), n);
}

The huff version can not mint more than one NFT due to logic flaw in MINT function.

The MINT function wants to validate the to variable to ensure it is not zero address, but the order of stack value is incorrect, and it turns out the validation only allows token id to be zero.

dup1 iszero invalid_recipient jumpi // [to, tokenId]

It first duplicates the top of stack value, it will be token id. It is the token id that is validated not the to variable.

Impact

Only the first NFT can be minted, and other user can not execute the mint operation

Tools Used

Update the validation of the following

dup1 iszero invalid_recipient jumpi // [to, tokenId]

Recommendations

Updates

Lead Judging Commences

inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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