Trick or Treat

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

transfer() is deprecated and should not be used to transfer Ether

Summary

In withdrawFees(), transfer() is used to send ether to the owner. This is not recommended as transfer() sends a fixed gas of 2300 and is deprecated, which may not be sufficient in the future if the EVM gas costs changes. This will cause the funds in the contract to be stucked.

Vulnerability Details

function withdrawFees() public onlyOwner {
uint256 balance = address(this).balance;
-> payable(owner()).transfer(balance);
emit FeeWithdrawn(owner(), balance);
}

Impact

Tools Used

Foundry

Recommendations

transfer() has been deprecated and call() should be used instead.

function withdrawFees() public onlyOwner {
uint256 balance = address(this).balance;
- payable(owner()).transfer(balance);
+ (bool success,) = payable(owner()).call{value: balance}("");
+ require(success);
emit FeeWithdrawn(owner(), balance);
}
Updates

Appeal created

bube Lead Judge 8 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.