Ztunnel panic in TraceParent::try_from on malformed traceparent header drops HBONE connections
Description
Ztunnel panics when parsing a malformed traceparent header: a 55-byte value without four dash-separated fields triggers an index-out-of-bounds in TraceParent::try_from. The panic terminates the inbound HBONE connection task and drops all streams on that connection. Headers with the correct length but the wrong field layout were also accepted instead of rejected.
Details
TraceParent::try_from n src/proxy.rs validates only the total length (55 bytes) of a traceparent value. It then indexes the result of split('-') at [0] through [3] . A 55-byte value that does not contain four dash-separated fields causes an index-out-of-bounds panic. For example, "0".repeat(55) panics.
Inbound HBONE handling calls this parser through extract_traceparent, in the request handler thath2::server::serve_connection runs inline in its accept loop, before the per-stream task is spawned. The panic terminates the HBONE connection task, so every stream multiplexed on that connection is dropped. The intended behavior is to ignore an invalid header and generate a new trace ID.
Values with the correct total length but the wrong layout, such as five fields or a 3-character version, were also accepted instead of rejected.
Fixes are available in 1.31.4 and 1.30.8.
Workaround
Follow one of these steps to reduce exposure:
- Restrict who can send traffic. Use L4
AuthorizationPolicy, so that only trusted identities can openHBONEconnections. - Sanitize the header before it reaches ztunnel. Where a waypoint or ingress gateway forwards traffic from untrusted external clients, that traffic can carry a crafted
traceparentto ztunnel under the gateway's mesh identity. Strip or overwritetraceparenton those routes, for example with anHTTPRouteRequestHeaderModifierfilter. This disables trace propagation for those routes
Proof of concept
Send an HBONE request to a ztunnel inbound listener from a client with a valid mesh identity. The request carries this header:
traceparent: 0000000000000000000000000000000000000000000000000000000That is 55 0 characters with no dashes. Ztunnel panics in src/proxy.rs, and the HBONE connection is dropped. The expected behavior is to ignore the header and generate a new trace ID.
Impact
A client that can send HBONE requests to ztunnel can repeatedly crash connection tasks. This disrupts all concurrent traffic on those connections, including traffic from other workloads that share the connection. It is a data-plane availability issue only. There is no confidentiality or integrity impact.
Exploitation requires a valid mesh identity. A client without one can only reach ztunnel if a gateway or waypoint forwards its traceparent header unchanged.
References
- Issue: istio/ztunnel#2233