Skip to content
Business logic Audit finding Intermediate

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:

  1. dApp A on a Branch Chain with (address = 0xbeef) initiates a CallOut(...) 0x01 with OutputParams (0x01) for the RootRouter.
  2. RootBridgeAgent executor calls MulticallRootRouter execute() which then performs some number of arbitrary calls and gets the OutputParams assets into the MulticallRootRouter.
  3. MulticallRootRouter attempts to bridge out the assets to the BranchChain and creates a settlement, passing the recipient (address = 0xbeef) but also sets the refundee as (address = 0xbeef).
  4. If the settlement fails, there is no guarantee that 0xbeef is 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

0xLightt (Maia) confirmed

0xBugsy (Maia) commented:

Addressed here.

Note: for full discussion, see here.


The original report as published on Code4rena, by alexxander. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. A dApp on a branch chain initiates a call out to the root router with output parameters.
  2. The root bridge agent executor calls execute() on MulticallRootRouter, which performs calls and receives the output assets.
  3. 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.
  4. 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.

More by alexxander

View all

10 more disclosed reports, best first.

More from Maia DAO - Ulysses

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.