Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: medium
Valid

L-01: `transfer()` is deprecated and should not be used to transfer Ether

Summary

In ChristmasDinner::_refundETH(), transfer() is used to send ether. 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 _refundETH(address payable _to) internal {
uint256 refundValue = etherBalance[_to];
-> _to.transfer(refundValue);
etherBalance[_to] = 0;
}

Impact

Sent gas may not be sufficient in the future if the EVM gas costs changes. This will cause the funds in the contract to be stucked.

Tools Used

Foundry

Recommendations

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

function _refundETH(address payable _to) internal {
uint256 refundValue = etherBalance[_to];
- _to.transfer(refundValue);
+ (bool success,) = _to.call{value: refundValue}("");
+ require(success);
etherBalance[_to] = 0;
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

transfer instead of call

Support

FAQs

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

Give us feedback!