Incorrect de-structuring of parse_intent()'s return value will trigger unexpected operations
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)).
(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.
(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
- A user wants to deposit TON coins and sends an internal message to the Gateway contract
- Due to the wrong de-structuring, the
opvalue is their 160-bit EVM address padded with zeroes. - The transaction would fail with an
unknown_operror.
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.
(_, (int op, _)) = in_msg_body~parse_intent();
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.