Repository navigation
fix(capture): preserve downstream protocol on the non-mesh passthrough upstream (#568) - #570
Merged
Merged
Conversation
…h upstream (#568) Non-mesh traffic sniffed as cleartext HTTP by http_inspector (h2c OR http/1.1) transits the cap_http HCM and is forwarded to the ORIGINAL_DST passthrough_original_dst cluster via the redirect-all catch-all's passthrough fallthrough. That cluster carried no upstream HTTP protocol options, so Envoy defaulted the upstream dial to HTTP/1.1. An h2c gRPC client to a non-mesh h2-only server (OTLP otel-collector on :4317) thus got "reset reason: protocol error" — the HCM spoke HTTP/1.1 to an h2-only upstream. Add USE_DOWNSTREAM_PROTOCOL (use_downstream_protocol_config) typed extension protocol options to the passthrough cluster so the upstream mirrors the sniffed downstream protocol: h1 -> h1, h2c -> h2c. Both codec messages are populated. Mesh traffic (mTLS, SNI demux, ODCDS) is byte identical; only the non-mesh passthrough upstream protocol behavior changes. Raw-TCP and TLS passthrough still hit the L4 cap_passthrough default chain via tcp_proxy, which ignores these HTTP-codec options. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #568
Problem
A mesh pod under
captureRedirectAllDefault: truesending OTLP gRPC (h2c) to a non-mesh ClusterIP (e.g.otel-collector:4317, a plain h2c-only gRPC server) got:Root cause — which chain/cluster carried the broken traffic
original_dstrecovers the ClusterIP;http_inspectorsniffs the stream as h2c (cleartext HTTP/2).cap_passthroughDefaultFilterChain only catches TLS + non-HTTP raw TCP. Thecap_httpHCM chain matches — itsFilterChainMatchis{transport_protocol: raw_buffer, application_protocols: [http/1.0, http/1.1, h2c]}, and h2c is in that list.cap_http, the authorityotel-collector:4317is not a mesh authority and not a known target, so it hits the redirect-all catch-all's passthrough fallthrough → routes to thepassthrough_original_dstORIGINAL_DST cluster.TypedExtensionProtocolOptions, so Envoy defaulted the upstream dial to HTTP/1.1. The HCM spoke HTTP/1.1 to an h2-only server → reset before headers → the Envoy-injectedprotocol errorgRPC status.So: the broken traffic transited the
cap_httpHCM chain (not the L4 default chain) and terminated on thepassthrough_original_dstcluster, which defaulted to HTTP/1.1 upstream.Fix — option (a): preserve downstream protocol on the passthrough
Chosen option (a) (USE_DOWNSTREAM_PROTOCOL on the passthrough cluster). Rationale: the h2c connection is already inside the HCM because
http_inspectorlegitimately detected it as HTTP; the HCM speaks HTTP to its upstream, so the upstream must mirror the downstream protocol. Option (b) — diverting non-mesh traffic off the HCM onto the TCP floor — is structurally wrong here: to bypass the HCM you'd have to stop matching h2c intocap_http, which would also break legitimate non-mesh cleartext HTTP/1.1 egress that correctly transits the HCM today.config.UseDownstreamProtocolOptions()buildsHttpProtocolOptionswithuse_downstream_protocol_configand both HTTP/1 and HTTP/2 codec messages populated (so Envoy has concrete config for whichever protocol the downstream turns out to be).NewPassthroughOriginalDstCluster()now carries it viaTypedExtensionProtocolOptions. Result: h1 downstream → h1 upstream, h2c downstream → h2c upstream.Mesh traffic handling (per-source mTLS, SNI demux, ODCDS, TCP floor) is byte-identical — only the non-mesh passthrough upstream protocol changes. Raw-TCP and TLS passthrough still hit the L4
cap_passthroughdefault chain viatcp_proxy, which ignores these HTTP-codec options.Validation
//agent/internal/xds/config:config_test— asserts the helper selectsUseDownstreamProtocolConfigwith both codecs + the 30s idle timeout.//agent/internal/xds/proxy:proxy_test—TestNewPassthroughOriginalDstClusternow asserts the passthrough cluster carries the use-downstream config with both h1 and h2c populated (h1 traffic unaffected).//test/envoy_validate:envoy_validate_test— passes. Its capture bootstrap already buildsNewPassthroughOriginalDstCluster(), soenvoy --mode validatenow confirms Envoy accepts an ORIGINAL_DST cluster carrying HTTP protocol options.//agent/...(-integration) +//test/envoy_validate/...: 25/25 pass.Follow-up (not in this PR)
capture.aether.io/exclude-outbound-ports: "4317"mitigation into the soak/test manifests.🤖 Generated with Claude Code
https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR