Users will lose their cross-chain transaction if the destination router do not have enough WETH reserves.
When a cross-chain transaction arrives at a destination router with insufficient WETH reserves, the router sends the wrapped token to the execution target address instead of the user. For payload transfers, that target is the destination bridge adapter, which cannot withdraw the token, so the user's funds are lost.
haxatron1 Follow with EV_om, MrPotatoMagic and 5 others
Originally disclosed on Code4rena
Submitted by haxatron, also found by EV_om, MrPotatoMagic, deth, rouhsamad, Aamir, Topmark, and bart1e
When the DecentEthRouter receives the dcntEth OFT token from a cross-chain transaction, if the WETH balance of the destination router is less than amount of dcntEth received (this could be due to the router receiving more cross-chain transactions than than sending cross-chain transactions which depletes its WETH reserves), then the dcntEth will get transferred to the address specified by _to.
function onOFTReceived(
uint16 _srcChainId,
bytes calldata,
uint64,
bytes32,
uint _amount,
bytes memory _payload
) external override onlyLzApp {
...
if (weth.balanceOf(address(this)) < _amount) {
=> dcntEth.transfer(_to, _amount);
return;
}
if (msgType == MT_ETH_TRANSFER) {
if (!gasCurrencyIsEth || !deliverEth) {
weth.transfer(_to, _amount);
} else {
weth.withdraw(_amount);
payable(_to).transfer(_amount);
}
} else {
weth.approve(address(executor), _amount);
executor.execute(_from, _to, deliverEth, _amount, callPayload);
}
}
This dcntEth is sent to the user so that they can either redeem the WETH / ETH from the router once the WETH balance is refilled or send it back to the source chain to redeem back the WETH.
The problem is that if the msgType != MTETHTRANSFER, then the _to address is not the user, it is instead the target meant to be called by the destination chain’s bridge executor (if the source chain uses a decent bridge adapter, the target is always the destination chain’s bridge adapter which does not have a way to withdraw the dcntEth).
The following snippet shows what occurs in the bridge executor (_executeEth omitted as it does largely the same thing as _executeWeth):
DecentBridgeExecutor.sol#L24-L82
function _executeWeth(
address from,
address target,
uint256 amount,
bytes memory callPayload
) private {
uint256 balanceBefore = weth.balanceOf(address(this));
weth.approve(target, amount);
(bool success, ) = target.call(callPayload);
if (!success) {
weth.transfer(from, amount);
return;
}
uint256 remainingAfterCall = amount -
(balanceBefore - weth.balanceOf(address(this)));
// refund the sender with excess WETH
weth.transfer(from, remainingAfterCall);
}
...
function execute(
address from,
address target,
bool deliverEth,
uint256 amount,
bytes memory callPayload
) public onlyOwner {
weth.transferFrom(msg.sender, address(this), amount);
if (!gasCurrencyIsEth || !deliverEth) {
_executeWeth(from, target, amount, callPayload);
} else {
_executeEth(from, target, amount, callPayload);
}
}
Therefore, once the dcntEth is transferred to the execution target (which is almost always the destination chain bridge adapter, see Appendix for the code walkthrough). The user cannot do anything to retrieve the dcntEth out of the execution target, so the cross-chain transaction is lost.
Recommended Mitigation Steps
Pass a destination chain refund address into the payload sent cross-chain and replace the _to address used in DecentEthRouter.sol#L267:
if (weth.balanceOf(address(this)) < _amount) {
// REPLACE '_to' with the destination chain refund address
=> dcntEth.transfer(_to, _amount);
return;
}
Appendix
To see why the target is always the destination bridge adapter if the source chain is a decent bridge adapter:
UTB.sol will first call the bridge function in the adapter with the destination bridge adapter address as the 2nd argument.
DecentBridgeAdapter.sol#L117C1-L124C11
function bridge(
...
router.bridgeWithPayload{value: msg.value}(
lzIdLookup[dstChainId],
destinationBridgeAdapter[dstChainId],
swapParams.amountIn,
false,
dstGas,
bridgePayload
);
}
Which calls the below function in the router, where the _toAddress is the 2nd argument and therefore is the destination bridge adapter address:
DecentEthRouter.sol#L196C1-L204C23
/// @inheritdoc IDecentEthRouter
function bridgeWithPayload(
uint16 _dstChainId,
address _toAddress,
uint _amount,
bool deliverEth,
uint64 _dstGasForCall,
bytes memory additionalPayload
) public payable {
return
_bridgeWithPayload(
MT_ETH_TRANSFER_WITH_PAYLOAD,
_dstChainId,
_toAddress,
_amount,
_dstGasForCall,
additionalPayload,
deliverEth
);
...
which calls _bridgeWithPayload which calls _getCallParams to encode the payload to send to the destination chain:
DecentEthRouter.sol#L148C1-L168C15
function _bridgeWithPayload(
uint8 msgType,
uint16 _dstChainId,
address _toAddress,
uint _amount,
uint64 _dstGasForCall,
bytes memory additionalPayload,
bool deliverEth
) internal {
(
bytes32 destinationBridge,
bytes memory adapterParams,
bytes memory payload
) = _getCallParams(
msgType,
_toAddress,
_dstChainId,
_dstGasForCall,
deliverEth,
additionalPayload
);
...
The _toAddress parameter is always the 3rd parameter in the payload sent.
function _getCallParams
...
if (msgType == MT_ETH_TRANSFER) {
payload = abi.encode(msgType, msg.sender, _toAddress, deliverEth);
} else {
payload = abi.encode(
msgType,
msg.sender,
_toAddress,
deliverEth,
additionalPayload
);
}
...
Which matches _to variable in onOFTReceived
/// @inheritdoc IOFTReceiverV2
function onOFTReceived(
uint16 _srcChainId,
bytes calldata,
uint64,
bytes32,
uint _amount,
bytes memory _payload
) external override onlyLzApp {
(uint8 msgType, address _from, address _to, bool deliverEth) = abi
.decode(_payload, (uint8, address, address, bool));
bytes memory callPayload = "";
if (msgType == MT_ETH_TRANSFER_WITH_PAYLOAD) {
(, , , , callPayload) = abi.decode(
_payload,
(uint8, address, address, bool, bytes)
);
}
...
wkantaros (Decent) confirmed but disagreed with severity
This and all duplicate submissions detail an interesting way in which cross-chain relays will fail to properly invoke the target recipient of the relayed call, effectively leading to loss of funds as the assets will be transferred to an entity that potentially is not equipped to handle the token.
Based on discussions in #505, this is a very likely scenario and thus a high-risk severity is appropriate as the vulnerability should manifest consistently in non-Ethereum chains.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the fallback branch transfers the wrapped token to the payload's execution target rather than to a user-controlled refund address.
Impact
Users could permanently lose the bridged funds because the wrapped token is sent to a contract that cannot withdraw it.
What the attacker needed
Destination router has low WETH reserves; cross-chain transfer with a payload; source uses the Decent bridge adapter
The fix
The payload should carry a destination-chain refund address, and the fallback transfer should send the wrapped token to that address instead of the execution target.
How it was found
- A user initiates a cross-chain transfer with a payload through the Decent bridge adapter.
- The adapter calls the router with the destination bridge adapter as the recipient address.
- The router encodes that address into the cross-chain payload.
- On the destination chain, the router receives the payload and checks its WETH balance.
- If the WETH balance is too low, the router transfers the wrapped token to the encoded target address.
- The target is the destination bridge adapter, which cannot withdraw the wrapped token, so the funds are stuck.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A cross-chain bridge moves tokens between blockchains. If the destination side runs out of the token it normally pays out, it sends a different token instead. Here that replacement token went to an internal contract address rather than the user, and that contract has no way to send it on, so the user cannot get their money back.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.