# Malicious actors can manipulate the cross_chain_callback callback

Validator signature omits from_chain, letting an attacker front-run the callback with a wrong from_chain to force create_cross_txs[txid] into Failed state permanently.

- Payout: Audit contest
- Severity: high
- Program: Chakra
- Found by: shaflow2
- Disclosed: 2025-02-20
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-08-chakra-findings/issues/11
- Library page: https://bugbountylibrary.com/r/c4%3A2024-08-chakra%3AH-14
- Tags: area:web3 domain:web3 impact:dos impact:integrity kind:contest platform:code4rena sev:high tech:solidity technique:race-window technique:source-review vuln:access-control vuln:business-logic vuln:signature-replay

**Target:** Settlement receive_cross_chain_callback / verifySignature
**Root cause:** verifySignature hashes only (txid, from_handler, to_handler, status), excluding from_chain, so a signature valid for the correct chain also validates an attacker-supplied wrong from_chain.
**Steps:**
1. Observe a pending receive_cross_chain_callback(txid, from_chain, from_handler, to_handler, status, sign_type, signatures) transaction.
2. Front-run it with identical txid/from_handler/to_handler/status/signatures but a bogus `from_chain`.
3. verifySignature passes since from_chain is not in message_hash.
4. processCrossChainCallback calls is_valid_handler(from_chain, from_handler) which returns false, so handler returns false.
5. create_cross_txs[txid].status is set to CrossChainMsgStatus.Failed, blocking legitimate execution.
**How found:** Code review of verifySignature noticed the signed message_hash omitted from_chain while processCrossChainCallback used from_chain for handler validation and status assignment.
**Exploitation:** Attacker watches the mempool for the final callback leg, copies the valid validator signatures, and submits the same call with a wrong from_chain at higher gas. Signature check passes, handler validation fails, and the txid is permanently marked Failed.
**Escalation:** Any third-leg callback can be trivially sabotaged, so all cross-chain transactions can be forced into failure state.
**Insight:** When a signed message omits a parameter that later gates validation or state transitions, check whether an attacker can supply a different value for that parameter while reusing the same signature to force a failure or alternate branch.

## Proof of concept (copied exactly from the original report)

**receive_cross_chain_callback missing from_chain in signature**

```
function receive_cross_chain_callback(
        uint256 txid,
        string memory from_chain,
        uint256 from_handler,
        address to_handler,
        CrossChainMsgStatus status,
        uint8 sign_type,
        bytes calldata signatures
    ) external {
        verifySignature(
            txid,
            from_handler,
            to_handler,
            status,
            sign_type,
            signatures
        );
        processCrossChainCallback(
            txid,
            from_chain,
            from_handler,
            to_handler,
            status,
            sign_type,
            signatures
        );
        emitCrossChainResult(txid);
    }
```

**verifySignature message hash omits from_chain**

```
function verifySignature(
        uint256 txid,
        uint256 from_handler,
        address to_handler,
        CrossChainMsgStatus status,
        uint8 sign_type,
        bytes calldata signatures
    ) internal view {
        bytes32 message_hash = keccak256(
            abi.encodePacked(txid, from_handler, to_handler, status)
        );

        require(
            signature_verifier.verify(message_hash, signatures, sign_type),
            "Invalid signature"
        );
    }
```

**Failed status set when handler returns false**

```
if (
            ISettlementHandler(to_handler).receive_cross_chain_callback(
                txid,
                from_chain,
                from_handler,
                status,
                sign_type,
                signatures
            )
        ) {
            create_cross_txs[txid].status = status;
        } else {
            create_cross_txs[txid].status = CrossChainMsgStatus.Failed;
        }
```

