Snowman Merkle Airdrop

AI First Flight #10
Beginner FriendlyFoundrySolidityNFT
EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Missing Input Validation


Description

  • Gas waste and confusing behavior

function buySnow(uint256 amount) external payable canFarmSnow {
// No check for amount == 0
@> if (msg.value == (s_buyFee * amount)) {
@> _mint(msg.sender, amount); // Can mint 0 tokens
} else {
i_weth.safeTransferFrom(msg.sender, address(this), (s_buyFee * amount));
_mint(msg.sender, amount); // Can mint 0 tokens
}
}

Risk

Likelihood:

  • When tring to buy snow with 0 amount

Impact:

  • Wastes of gas

Proof of Concept

This function proof that tring to buy snow with 0 amount can waste gas

function test_Snow_NoInputValidation_ZeroAmount() public {
uint256 initialBalance = snow.balanceOf(alice);
vm.prank(alice);
snow.buySnow{value: 0}(0);
assertEq(snow.balanceOf(alice), initialBalance);
}

Recommended Mitigation

Should revert with InvalidAmount err, when try to buy with 0 amount

function buySnow(uint256 amount) external payable {
if (amount == 0) revert InvalidAmount();
if (msg.sender == address(0)) revert InvalidAddress();
// ... rest of function
}
Updates

Lead Judging Commences

ai-first-flight-judge Lead Judge about 6 hours ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!