Snowman Merkle Airdrop

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

msg.value != (s_buyFee * amount) && User has approve the amount weth will cause user user lose the msg.value.

Root + Impact

Description

  • Before user call buySnow function ,user has approve the amount of weth and call buySnow with wrong msg.value

  • user will lose the msg.value

function buySnow(uint256 amount) external payable canFarmSnow {
// if msg.value != (s_buyFee * amount) && user has approve the weth
if (msg.value == (s_buyFee * amount)) {
_mint(msg.sender, amount);
} else {
i_weth.safeTransferFrom(msg.sender, address(this), (s_buyFee * amount));
_mint(msg.sender, amount);
}
s_earnTimer = block.timestamp;
emit SnowBought(msg.sender, amount);
}

Risk

Medium

Likelihood:

  • Before user call buySnow function ,user has approve the amount of weth and call buySnow with wrong msg.value

Impact:

  • user will lose the msg.value

Proof of Concept

  1. jerry approve the amount of weth

  2. jerry call buySnow with wrong msg.value

function testCanmsgvalueNotEqualamount() public {
deal(jerry, FEE * 2);
vm.startPrank(jerry);
weth.approve(address(snow), FEE);
snow.buySnow{value: 2 * FEE}(1);// value != s_buyFee * amount
vm.stopPrank();
assert(snow.balanceOf(jerry) == 1);
assert(address(snow).balance == FEE * 2);
assert(jerry.balance == 0);// jerry will lose msg.value
}

Recommended Mitigation

Updates

Lead Judging Commences

yeahchibyke Lead Judge
3 months ago
yeahchibyke Lead Judge
3 months ago
yeahchibyke Lead Judge 3 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.