Precise Scarlet Millipede
Medium
The sendMessage()::L1CrossDomainMessenger.sol
function will fail if _refundAddress
is a contract that cannot receive ether.
In L1CrossDomainMessenger.sol : https://github.com/sherlock-audit/2024-08-morphl2/blob/main/morph/contracts/contracts/l1/L1CrossDomainMessenger.sol#L359-L363
uint256 _refund = msg.value - _fee - _value;
if (_refund > 0) {
(bool _success, ) = _refundAddress.call{value: _refund}(""); // <-- can cause a DOS (Deny Of Service)
require(_success, "Failed to refund the fee");
}
These lines of code can cause a DOS : Deny Of Service.
If the _refundAddress
is a contract that can not receive ether, meaning neither a receive() payable
nor fallback() payable
function is implemented, the transaction will automatically fail.
_refundAddress
is a contract_refundAddress
does not implement areceive() payable
function nor afallback() payable
function.- There is a
_refund
amount to refund
_refundAddress
is a contract that can not receive ETH- there is a surplus of eth sent by the user, meaning there is a
_refund
amount to send to the_refundAddress
- the contract tries to send this
_refund
amount of native ETH to the_refundAddress
- the transaction fails
Deny Of Service, the transaction will fail every time.
One possibility would be to convert the _refund
amount to wrap ether
(WETH), and then send it to the _refundAddress
.
Wether _refundAddress
is a contract able to receive ether or not, the transaction will always go through.
Or, check if the _refundAddress
is a contract, if it's not => refund with native ether, if it is
=> refund with Wrap Ether (WETH).