Redeeming a Settlement won’t work for unsigned messages when the communicating dApps have different addresses on the different chains
The MulticallRootRouter sets the refundee of a settlement to the output recipient, which may be a branch-chain dApp address that does not exist on the root chain. If the settlement fails, the assets cannot be redeemed because the settlement owner is set to that unknown address.
alexxander Follow with 3docSec
Originally disclosed on Code4rena
Submitted by alexxander, also found by 3docSec
Lines of code
https://github.com/code-423n4/2023-09-maia/blob/f5ba4de628836b2a29f9b5fff59499690008c463/src/MulticallRootRouter.sol#L163-L171 https://github.com/code-423n4/2023-09-maia/blob/f5ba4de628836b2a29f9b5fff59499690008c463/src/MulticallRootRouter.sol#L186-L194 https://github.com/code-423n4/2023-09-maia/blob/f5ba4de628836b2a29f9b5fff59499690008c463/src/RootBridgeAgent.sol#L311-L315
Impact
Funds cannot be redeemed and remain stuck in a settlement.
Proof Of Concept
In MulticallRootRouter, execute() calls _approveAndCallOut(...); however, it passes the Output Params recipient also as the refundee. This is dangerous because the recipient Dapp on the BranchChain can have a different address or not exist on the Root Chain. Therefore, if a settlement fails, it won’t be able to be redeemed since the settlement owner is set as the refundee.
Here is a scenario:
- dApp A on a Branch Chain with (
address = 0xbeef) initiates aCallOut(...) 0x01withOutputParams (0x01)for theRootRouter. RootBridgeAgentexecutor callsMulticallRootRouterexecute()which then performs some number of arbitrary calls and gets theOutputParamsassets into theMulticallRootRouter.MulticallRootRouterattempts to bridge out the assets to the BranchChain and creates a settlement, passing therecipient (address = 0xbeef)but also sets therefundee as (address = 0xbeef).- If the settlement fails, there is no guarantee that
0xbeefis a known dApp on the Root Chain and the assets won’t be able to be redeemed.
function execute(bytes calldata encodedData, uint16) external payable override lock requiresExecutor {
// Parse funcId
bytes1 funcId = encodedData[0];
// code ...
/// FUNC ID: 2 (multicallSingleOutput)
} else if (funcId == 0x02) {
// Decode Params
(
IMulticall.Call[] memory callData,
OutputParams memory outputParams,
uint16 dstChainId,
GasParams memory gasParams
) = abi.decode(_decode(encodedData[1:]), (IMulticall.Call[], OutputParams, uint16, GasParams));
// Perform Calls
_multicall(callData);
// Bridge Out assets
_approveAndCallOut(
outputParams.recipient,
outputParams.recipient,
outputParams.outputToken,
outputParams.amountOut,
outputParams.depositOut,
dstChainId,
gasParams
);
}
// code ...
}
function _createSettlement(
uint32 _settlementNonce,
address payable _refundee,
address _recipient,
uint16 _dstChainId,
bytes memory _params,
address _globalAddress,
uint256 _amount,
uint256 _deposit,
bool _hasFallbackToggled
) internal returns (bytes memory _payload) {
// code ...
// Update Settlement
settlement.owner = _refundee;
settlement.recipient = _recipient;
// code ...
}
function redeemSettlement(uint32 _settlementNonce) external override lock {
// Get settlement storage reference
Settlement storage settlement = getSettlement[_settlementNonce];
// Get deposit owner.
address settlementOwner = settlement.owner;
// Check if Settlement is redeemable.
if (settlement.status == STATUS_SUCCESS) revert SettlementRedeemUnavailable();
if (settlementOwner == address(0)) revert SettlementRedeemUnavailable();
// Check if Settlement Owner is msg.sender or msg.sender is the virtual account of the settlement owner.
if (msg.sender != settlementOwner) {
if (msg.sender != address(IPort(localPortAddress).getUserAccount(settlementOwner))) {
revert NotSettlementOwner();
}
}
/// more code ...
}
Recommended Mitigation Steps
Include an argument that enables users to specify the refundee when creating settlements without using a Virtual Account.
Assessed type
Context
Addressed here.
Note: for full discussion, see here.
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 code passes the output recipient as both the recipient and the refundee when creating a settlement, without allowing a separate refundee address.
Impact
Funds from a failed settlement could become stuck and cannot be redeemed.
What the attacker needed
A dApp on a branch chain; settlement fails; recipient address not on root chain
The fix
The code should be changed to allow specifying a separate refundee when creating settlements, rather than reusing the recipient.
How it was found
- A dApp on a branch chain initiates a call out to the root router with output parameters.
- The root bridge agent executor calls execute() on MulticallRootRouter, which performs calls and receives the output assets.
- MulticallRootRouter attempts to bridge the assets back to the branch chain and creates a settlement, setting both recipient and refundee to the branch-chain dApp address.
- If the settlement fails, the refundee address may not exist on the root chain, so the settlement cannot be redeemed.
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.
When a cross-chain message fails, the system creates a settlement that holds the funds until the owner redeems them. The owner is set to the refundee address, but here that address is the recipient on another chain, which may not exist on this chain. So the funds get stuck because no one can prove they are the owner.
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.