Skip to content
Business logic Audit finding Intermediate

Incompatibility with Account Abstraction and Multisigs due to enforced address symmetry in cross chain unstaking

The cross-chain unstake function on the spoke chain hardcodes the recipient on the hub chain to be the caller's own address, so users cannot choose a different destination. Users whose wallet address differs between chains, such as smart contract wallets, account abstraction wallets or multisigs, would have their withdrawn assets sent to an address they do not control on the hub chain.

KuwaTakushi Follow with Bobai23 and Tarnished

Originally disclosed on Code4rena

Submitted by KuwaTakushi, also found by Bobai23 and Tarnished

  • token/wiTRY/crosschain/UnstakeMessenger.sol #L120
  • token/wiTRY/crosschain/wiTryVaultComposer.sol #L266

Finding description

The UnstakeMessenger contract on the Spoke chain handles the initiation of cross chain unstaking requests. The unstake function constructs the cross chain payload but fails to allow the caller to specify a destination recipient address. It explicitly hardcodes the user field (the recipient of the funds on the Hub chain) to be msg.sender.

function unstake(uint256 returnTripAllocation) external payable nonReentrant returns (bytes32 guid) {
    ...
    bytes memory extraOptions = OptionsBuilder.newOptions();

    UnstakeMessage memory message = UnstakeMessage({
@>      user: msg.sender,
        extraOptions: extraOptions
    });

    bytes memory payload = abi.encode(MSG_TYPE_UNSTAKE, message);
    ...
}

On the Hub chain, the wiTryVaultComposer receives this message and uses the user field as the destination for the withdrawn assets.

function _handleUnstake(Origin calldata _origin, bytes32 _guid, IUnstakeMessenger.UnstakeMessage memory unstakeMsg)
    internal
    virtual
{
    address user = unstakeMsg.user;
    ...
    SendParam memory _sendParam = SendParam({
        dstEid: _origin.srcEid,
@>      to: bytes32(uint256(uint160(user))),
        amountLD: assets,
        minAmountLD: assets,
        extraOptions: options,
        composeMsg: "",
        oftCmd: ""
    });

    _send(ASSET_OFT, _sendParam, address(this));
    ...
}

This enforced address symmetry assumes that the user controls the same address on both chains. This assumption fails for Smart Contract Wallets, Account Abstraction (AA) wallets, and Multisigs (e.g., Gnosis Safe), as their addresses often differ across chains due to nonce mismatches.

Impact

Users with Account Abstraction (AA) wallets or Multisigs will permanently lose their assets.

Recommended mitigation steps

Update the unstake function in UnstakeMessenger to accept an optional _recipient parameter. This allows users to specify the destination address on the Hub chain.

- function unstake(uint256 returnTripAllocation, address _recipient) external payable nonReentrant returns (bytes32 guid) {
+ function unstake(uint256 returnTripAllocation) external payable nonReentrant returns (bytes32 guid) {
    if (peers[hubEid] == bytes32(0)) revert HubNotConfigured();
    if (returnTripAllocation == 0) revert InvalidReturnTripAllocation();

    address targetUser = _recipient == address(0) ? msg.sender : _recipient;

    bytes memory extraOptions = OptionsBuilder.newOptions();

    UnstakeMessage memory message = UnstakeMessage({
-        user: msg.sender,
+        user: targetUser,
        extraOptions: extraOptions
    });

    bytes memory payload = abi.encode(MSG_TYPE_UNSTAKE, message);
    ...
}

Proof of Concept

Add this PoC to UnstakeMessenger.t.sol:

View detailed Proof of Concept

Logs:

forge test --match-test test_POC_HardcodedRecipient_Prevents_Multisig_Migration -vvv
[⠆] Compiling...
[⠆] Compiling 1 files with Solc 0.8.20
[⠰] Solc 0.8.20 finished in 18.04s
Compiler run successful with warnings:
Warning (2018): Function state mutability can be restricted to view
   --> test/crosschainTests/crosschain/UnstakeMessenger.t.sol:246:5:
    |
246 |     function test_Constructor_InitializesCorrectly() public {
    |     ^ (Relevant source part starts here and spans across multiple lines).

Ran 1 test for test/crosschainTests/crosschain/UnstakeMessenger.t.sol:UnstakeMessengerTest
[PASS] test_POC_HardcodedRecipient_Prevents_Multisig_Migration() (gas: 491951)
Logs:
  -------------------------------------------------------
  [POC] Testing Forced Address Symmetry Vulnerability
  -------------------------------------------------------
  Sender (Spoke Chain):     0xE8B00b2fe39c1A1CF00DE5de5C14ac3A8db2B7eE
  Desired Recipient (Hub):  0x0eF6C1d0dbEd6836E84DF31f29B33C4EBDf71B4a
  Actual Forced Recipient:  0xE8B00b2fe39c1A1CF00DE5de5C14ac3A8db2B7eE
  -------------------------------------------------------

Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.66ms (816.20µs CPU time)

Ran 1 test suite in 59.29ms (2.66ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)

The original report as published on Code4rena, by KuwaTakushi. 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

The unstake function does not let the caller specify a destination recipient and instead hardcodes the hub-chain recipient to msg.sender, assuming the same address exists on both chains.

Impact

Users with account abstraction wallets or multisigs whose addresses differ across chains would permanently lose their unstaked assets, as the funds are sent to an address they do not control on the hub chain.

What the attacker needed

User has a wallet with different addresses per chain; user initiates a cross-chain unstake

The fix

The unstake function should be updated to accept an optional recipient parameter so users can specify the destination address on the hub chain.

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 you unstake tokens across two blockchains, the system decides where the money goes on the other chain. Here it always sends the money back to the same address you used to start the request. That is a problem because some wallets, like multisigs (wallets that need several people to approve a transaction), have a different address on each chain, so the money would arrive at an address nobody controls.

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 from Brix Money

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.