Lucene search

K
code423n4Code4renaCODE423N4:2022-04-BACKD-FINDINGS-ISSUES-219
HistoryMay 08, 2022 - 12:00 a.m.

Avoid payable.transfer

2022-05-0800:00:00
Code4rena
github.com
7

Originally submitted by warden horsefacts in #199, duplicate of #52.

Avoid payable.transfer

EthPool and EthVault both use payable(address).transfer to transfer ETH.

It’s considered a best practice to avoid this pattern for ETH transfers, since it forwards a fixed amount of gas and may revert if future gas costs change. (See the Consensys Diligence article here).

EthPool#_doTransferOut

    function _doTransferOut(address payable to, uint256 amount) internal override {
        to.transfer(amount);
    }

EthVault#_transfer

    function _transfer(address to, uint256 amount) internal override {
        payable(to).transfer(amount);
    }

EthVault#_depositToTreasury

    function _depositToTreasury(uint256 amount) internal override {
        payable(addressProvider.getTreasury()).transfer(amount);
    }

Consider using OpenZeppelin Address.sendValue, but take care to avoid reentrancy. Callers of these internal functions should be protected with a reentrancy guard.


The text was updated successfully, but these errors were encountered:

All reactions