Reproduced Exploit

Chakra: a failed destination message still settles and burns the escrow

The Code4rena report is about the Cairo handler: receive_cross_chain_callback writes tx_status = SETTLED and, in mint-burn mode, burns the escrow even when the destination message failed. This playground is that handler in Solidity. A failed status still settles the source message and burns 1000 CH…

Aug 2024•Other•logic•2 min read

Loss

1000 CHK escrow burned and the message marked settled after a failed destination

Chain

Other

Category

logic

Date

Aug 2024

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 49145-h-12-handlers-receive-cross-chain-callback-will-always-set-t. Standalone Foundry PoC and full write-up: 49145-h-12-handlers-receive-cross-chain-callback-will-always-set-t_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/wrong-condition · vuln/logic/state-update

Key info#

FieldValue
Loss1000 CHK escrow burned and the message marked settled after a failed destination
Vulnerable contractHandler.receiveCrossChainCallback
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateLocal synthetic · 2024-08
Compilersolc 0.8.27, cancun, via IR
Bug classCallback ignores the destination status in mint-burn mode

TL;DR#

The Code4rena report is about the Cairo handler: receive_cross_chain_callback writes tx_status = SETTLED and, in mint-burn mode, burns the escrow even when the destination message failed. This playground is that handler in Solidity. A failed status still settles the source message and burns 1000 CHK. The contest's Solidity handler burns only on success.

The vulnerable code#

SOLIDITY
function receive_cross_chain_callback(uint256 id, uint8 crossChainMsgStatus) external returns (bool) {
    Created memory createdTx = created[id];
    if (mode == MODE_MINT_BURN) {
        token.transfer(sink, createdTx.amount);
    }
    created[id] = Created({amount: createdTx.amount, status: SETTLED});
    return true;
}

The status argument is unread. A failed destination should leave the escrow in place and must not mark the source message settled.

Root cause#

The callback treats every destination result as success. Mint-burn mode then destroys the tokens that were waiting on the source chain.

Preconditions#

  • Mint-burn mode, with 1000 CHK escrowed on the handler.
  • The destination reports failure.

Attack walkthrough#

  1. The handler holds 1000 CHK for a pending message.
  2. The callback arrives with status failed.
  3. txStatus is written as settled anyway.
  4. The 1000 CHK is transferred to the burn sink. The handler balance is 0.

Diagrams#

flowchart TD A["1000 CHK sits in escrow"] --> B["Destination callback reports failure"] B --> C["Handler ignores the status"] C --> D["txStatus is written SETTLED"] D --> E["Mint-burn sends the 1000 CHK to the sink"]

Impact#

A failed cross-chain message still destroys the source escrow. This run burns 1000 CHK that should have stayed claimable.

How to reproduce#

BASH
cd 49145-h-12-handlers-receive-cross-chain-callback-will-always-set-t_exp
forge test -vv

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.