Trick or Treat

First Flight #27
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Valid

L-2: Unsafe Ether Transfer Using `transfer` Function

Description:

The contract uses Solidity's transfer method to send Ether, which can lead to issues due to the fixed gas stipend.

Instance:

  • withdrawFees Function (Line 148):

    payable(owner()).transfer(balance);

Impact:

  • Potential Failure of Ether Transfer:

    • The transfer function forwards a fixed amount of 2300 gas to the recipient.

    • If the owner address is a contract with complex logic in its receive or fallback function, the gas may be insufficient, causing the transfer to fail.

  • Loss of Funds Accessibility:

    • If the transfer fails, the Ether remains locked in the contract until a successful withdrawal is possible.

Recommendation:

  • Use call Method for Transfers:

    • Replace transfer with call to forward all available gas and handle the transfer success status.

      (bool success, ) = payable(owner()).call{value: balance}("");
      require(success, "Transfer failed");
  • Implement Pull Payments:

    • Instead of pushing Ether to the owner, allow the owner to withdraw funds by calling a function, adhering to the pull payment pattern.

  • Ensure Proper Error Handling:

    • Handle cases where the transfer fails gracefully, possibly with retries or alternative mechanisms.

Updates

Appeal created

bube Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Use of `transfer` instead of `call`

Support

FAQs

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