Using transfer() for ETH refund on ReceiverImplementation.sol
Impact
The use of the deprecated transfer() function will inevitably make the transaction fail when:
The receiver smart contract does not implement a payable function.
The receiver smart contract does implement a payable fallback which uses more than 2300 gas unit.
The receiver smart contract implements a payable fallback function that needs less than 2300 gas units but is called through proxy, raising the call's gas usage above 2300.
More over, using higher than 2300 gas might be mandatory for some multisig wallets.
Proof of Concept
Solidity’s transfer() and send() use a hardcoded gas amount.
in ReceiverImplementation.sol, receiveAndSendToken(), receiveAndSendNative(), receiveAndUnwrapNative() functions are using transfer (with fixed stipend 2300 gas)
if those receivers (refundAddress) are smart contract, there is possibility of failure, and then revert the transaction.
Lines of code
https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/ReceiverImplementation.sol#L23 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/ReceiverImplementation.sol#L51 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/ReceiverImplementation.sol#L71 https://github.com/code-423n4/2022-07-axelar/blob/main/contracts/deposit-service/ReceiverImplementation.sol#L86
Vulnerability details
Using
transfer()
for ETH refund onReceiverImplementation.sol
Impact
The use of the deprecated
transfer()
function will inevitably make the transaction fail when:More over, using higher than 2300 gas might be mandatory for some multisig wallets.
Proof of Concept
transfer()
andsend()
use a hardcoded gas amount.receiveAndSendToken()
,receiveAndSendNative()
,receiveAndUnwrapNative()
functions are using transfer (with fixed stipend 2300 gas)refundAddress
) are smart contract, there is possibility of failure, and then revert the transaction.Recommended Mitigation Steps
Recommend using
call()
instead oftransfer()
, and make sure to check for reentrancy.