Snowman Merkle Airdrop

First Flight #42
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

# Unbounded Loop in `mintSnowman` Enables Denial of Service (Improper Input Validation + Gas Limit Exhaustion)

Unbounded Loop in mintSnowman Enables Denial of Service (Improper Input Validation + Gas Limit Exhaustion)

Description

  • The mintSnowman(address receiver, uint256 amount) function contains a for loop that iterates amount times, calling _safeMint() on each iteration.

  • Since amount is user-controlled and unbounded, malicious users can call this function with excessively high values, causing the transaction to exceed the block gas limit and revert.


@>function mintSnowman(address receiver, uint256 amount) external {
// there is no upper cap on amount
for (uint256 i = 0; i < amount; i++) {
_safeMint(receiver, s_TokenCounter);
emit SnowmanMinted(receiver, s_TokenCounter);
s_TokenCounter++;
}
}

Risk

Likelihood:

  • A user consistently transmits transactions with extremely high amount values, exceeding the block gas limit.

  • Multiple such transactions congest the network, consuming all usable gas and preventing legitimate minting.

Impact:

  • Complete service disruption of the minting feature, preventing all users from creating NFTs.

  • Wasted gas costs for users that attempt to mint high amounts and fail.

Proof of Concept

This simple test demonstrates the potential attack:

NOTE: forge should be installed

@>function test_MintSnowmanDos() public {
vm.expectRevert();
nft.mintSnowman(dos1, 100000); // Should revert due to gas limit
}

Then run:
forge test

The test should pass. Which means it'll revert.

Recommended Mitigation

  • Define a maximum cap, e.g., MAX_MINT_PER_TX = 20, and assert amount falls within a safe range.

  • Use:

+ require(amount > 0 && amount <= MAX_MINT_PER_TX, "Invalid mint amount");
Updates

Lead Judging Commences

yeahchibyke Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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