wise-foundation / lending-audit

5 stars 4 forks source link

[WLG-02S] Deprecated Native Asset Transfers #162

Open vm06007 opened 1 year ago

vm06007 commented 1 year ago

WLG-02S: Deprecated Native Asset Transfers

Type Severity Location
Language Specific WiseLending.sol:L57-L59, L450-L452, L500-L502, L589-L591, L871-L873, L1048-L1050

Description:

The linked statements perform low-level native asset transfers via the transfer function exposed by the address payable data type.

Impact:

As new EIPs such as EIP-2930 are introduced to the blockchain, gas costs can change and the transfer instruction of Solidity specifies a fixed gas stipend that is prone to failure should such changes be integrated to the blockchain the contract is deployed in. A prime example of this behaviour are legacy versions of Gnosis were susceptible to this issue and would cause native transfers to fail if sent to a new address.

Example:

payable(master).transfer(
    msg.value
);

Recommendation:

We advise alternative ways of transferring assets to be utilized instead, such as OpenZeppelin's Address.sol library and in particular the sendValue method exposed by it. If re-entrancies are desired to be prevented based on gas costs, we instead advise a mechanism to be put in place that either credits an account with a native balance they can withdraw at a secondary transaction or that performs the native asset transfers at the end of the top-level transaction's execution.

vm06007 commented 1 year ago

Resolved in: https://github.com/wise-foundation/lending-audit/pull/163