Snowman Merkle Airdrop

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

[L-4] Not checking for success of transfer function in collectFee()

[L-4] Not checking for success of transfer function in Snow::collectFee()

Description

  • The collectFee() function is calling WETH token's transfer function to transfer all fees to the collector

  • However, there are no checks to ensure that that the transfer is a success

function collectFee() external onlyCollector {
uint256 collection = i_weth.balanceOf(address(this));
@> i_weth.transfer(s_collector, collection);
(bool collected,) = payable(s_collector).call{value: address(this).balance}("");
require(collected, "Fee collection failed!!!");
}

Risk

Likelihood:

  • Whenever the collectFee() function is called and transfer fails

Impact:

  • No fee transfer but function executed fully

Proof of Concept

Add the following testcase to the test suite of Snow

function test_falseTransfer() public {
TestWETH test_weth = new TestWETH();
uint256 fee = 1;
Snow newSnow = new Snow(address(test_weth), fee, collector);
vm.startPrank(collector);
newSnow.collectFee();
}

Also add the following contract to the import list. This contract is just to replicate a situation where the token transfer has failed.

// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.24;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Snow} from "../../src/Snow.sol";
contract TestWETH is ERC20 {
uint256 public counter;
address public immutable owner;
address public snow_addr;
constructor() ERC20("MockWETH", "mWETH") {
owner = msg.sender;
}
function transfer(address, uint256) public pure override returns (bool) {
return false;
}
}

Recommended Mitigation

Add checks to ensure that the transfer function is a success

- i_weth.transfer(s_collector, collection);
+ bool res = i_weth.transfer(s_collector, collection);
+ assert(res == true);
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.