Skip to content
Smart contracts Audit finding Intermediate

Incorrect de-structuring of parse_intent()'s return value will trigger unexpected operations

g Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-04-zetachain-cross-chain-judging/issues/365

Found by

g

Summary

The wrong de-structuring of parse_intent() when the TON Gateway contract receives an internal message will trigger the incorrect operation.

Root Cause

parse_intent()'s return values the following format (slice, (int, int)).

FUNC
(slice, (int, int)) ~parse_intent(slice message_body) impure inline {
    int op = message_body~load_uint(size::op_code_size);
    int query_id = message_body~load_uint(size::query_id_size);

    return (message_body, (op, query_id));
}

However, recv_internal() misuses it by assigning the first element in the returned tuple to an int.

FUNC
(int op, _) = in_msg_body~parse_intent();

The first tuple should be the message_body, which is of slice type and not an int.

Internal Pre-conditions

None

External Pre-conditions

None

Attack Path

  1. A user wants to deposit TON coins and sends an internal message to the Gateway contract
  2. Due to the wrong de-structuring, the op value is their 160-bit EVM address padded with zeroes.
  3. The transaction would fail with an unknown_op error.

Impact

Internal messages will fail with unknown_op or trigger different operations than expected. This affects all user and admin operations, including update_code (for upgrading the contract).

PoC

No response

Mitigation

Consider fixing the de-structuring to the following.

FUNC
(_, (int op, _)) = in_msg_body~parse_intent();

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A medium-severity smart contracts bug in ZetaChain Cross-Chain. Sherlock made it public on 28 May 2025. Found in the 857 audit contest (finding M-32).

About Smart contracts

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by g

View all

23 more disclosed reports, best first.

More from ZetaChain Cross-Chain

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.