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

User can't mint more than one horse in huff

Summary

The MINT_HORSE macro in HuffStore.huff contract has a vulnerability that restricts users from minting more than one horse. The macro or associated _MINT function contains logic preventing unlimited minting, contrary to the intended behavior.

Vulnerability Details

The MINT_HORSE macro in HuffStore.huff contains logic that restricts users to minting only one horse. This limitation is not aligned with the project requirements, where users should be allowed to mint an unlimited number of horses.

Code snippet:

#define macro MINT_HORSE() = takes (0) returns (0) {
[TOTAL_SUPPLY] // [TOTAL_SUPPLY]
caller // [msg.sender, TOTAL_SUPPLY]
_MINT() // []
stop // []
}

Impact

The impact of this issue is significant as it directly contradicts the project requirements. Users are unable to mint more than one horse, leading to a deviation from the expected behavior. This limitation may affect user experience and hinder the project's functionality.

POC

  • Copy the below test

  • Run it via forge test --match-test testUserCannotMintUnlimitedInHuff -vvv and you will see the below result

function testUserCannotMintUnlimitedInHuff() public {
vm.prank(user);
horseStore.mintHorse();
vm.expectRevert();
horseStore.mintHorse();
}

Result:

Running 1 test for test/HorseStoreHuff.t.sol:HorseStoreHuff
[PASS] testUserCannotMintUnlimitedInHuff() (gas: 60319)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.93s
Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)

Also, digging more into this. It seems like the total supply is NOT increasing. Run the below test for proof;

function testTotalSupplyIsNotIncreasing() public {
uint256 beforeTotalSupply = horseStore.totalSupply();
vm.prank(user);
horseStore.mintHorse();
assertNotEq(horseStore.totalSupply(), beforeTotalSupply + 1);
}

Tools Used

Manual review.

Recommendations

  1. Update Minting Logic:

    • Revise the logic within the _MINT function or the MINT_HORSE macro to allow users to mint an unlimited number of horses.

  2. Verify TOTAL_SUPPLY Handling:

    • Ensure that the handling of TOTAL_SUPPLY is appropriately implemented and does not unintentionally restrict minting.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Failure to increment total supply on mint

Support

FAQs

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