Skip to content

proxy: carried patch — HTTP/3 pools keep the persistent QUIC info alive after a CDS removal (#1074) - #1077

Merged
bpalermo merged 1 commit into
mainfrom
proxy/1074-quic-client-teardown-uaf
Sep 30, 2026
Merged

bpalermo merged 1 commit into
mainfrom
proxy/1074-quic-client-teardown-uaf

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Carries proxy/bazel/patches/envoy-aether1074-quic-persistent-info-lifetime.patch on the 726d7ac pin, after aether1054c, for the w01 SIGBUS in #1074. An upstream Envoy bug (present on main); to be proposed upstream separately.

Mechanism

Crash: Caught Bus error, suspect faulting address 0x6f72702f747365 (ASCII "est/pro": a pointer loaded from freed memory reused by a string) in quic::QuicConnection::OnCanWrite ← EnvoyQuicClientConnection::onFileEvent, 57 ms after CDS removed 10 quic: twin clusters that still carried 70+ rps. Symbolized against the unstripped a1bcf05 binary, the fault is in QuicConnection::CanWrite() called at OnCanWrite+0x150, after writer_->IsWriteBlocked() at the top of OnCanWrite succeeded: the connection and its writer were alive. CanWrite then reads clock_->Now(), and the clock is not owned by the connection.

It lives in Quic::PersistentQuicInfoImpl (connection helper with its EnvoyQuicClock, alarm factory, QUIC config, crypto stream factory, writer factory), which was a unique_ptr member of the thread-local ClusterEntry (cluster_manager_impl.h, quic_info_). Http3ConnPoolImpl held it by reference, and every upstream QUIC connection keeps raw pointers into it (QuicConnection::clock_, each alarm's clock). On a CDS removal the worker erases the thread-local cluster, ~ClusterEntry runs drainConnPools() (DrainAndDelete: busy clients with live streams keep running) and then destroys its members, including the info. The pools live on in host_http_conn_pool_map_ with connections pointing into freed memory, and the next write-ready event or alarm dereferences the clock. It needs streams in flight at the removal, hence intermittent: the earlier prune found the twins idle, so their connections closed at drain start and nothing outlived the entry. Upstream since envoyproxy/envoy#19862 (2022), which moved the info into the cluster entry to share 0-RTT keys across pools.

#1073/#1076 stop aether from pruning live twins, which removes the trigger seen here; any other CDS removal of an HTTP/3 cluster under load (demand-set shrink, a destination leaving the dependency set) can still hit it until this lands.

The change

Http::PersistentQuicInfo gains enable_shared_from_this and a keepAlive() helper, and PersistentQuicInfoPtr becomes a shared_ptr. The cluster keeps creating and holding the info as before; Http3ConnPoolImpl and ConnectivityGrid each take a keep-alive reference at construction, so the info lives until the last pool using it is destroyed. A pool destroys its connections first (destructAllConnections() in its destructor), so their raw pointers never outlive it. No function signatures change; keepAlive() returns null for an info owned some other way (tests), which keeps the old behavior there. No change on a healthy path.

Test (red without, green with)

test/common/http/http3/conn_pool_test.cc PoolKeepsPersistentQuicInfoAliveAfterItsCreatorReleasesIt: create the info the way the cluster manager does, build a pool on it, release the creator's reference (the cluster going away): the info must still be alive; destroy the pool: the info must be gone. Without the pool change it is freed at release (info.expired() true). Also passing in the Envoy workspace: the rest of the HTTP/3 pool tests, conn_pool_grid_test, cluster_manager_impl_test, client_connection_factory_impl_test, quic_http_integration_test, multiplexed_integration_test, format and spelling.

The test cannot build inside proxy/ (quiche's test tooling is not wired into the downstream module, like the other QUIC tests), so it is noted in the suite file rather than listed; //bazel/patches:carried_patch_tests passes 8/8 with the patch applied and //:envoy builds.

What the soak should show

No change in normal operation. The crash signature (SIGBUS/SEGV in QuicConnection::OnCanWrite/CanWrite or an alarm shortly after a CDS removal of quic: clusters) should no longer occur even if a live HTTP/3 cluster is removed under load. A direct check: temporarily let the agent prune a twin with live streams (the pre-#1076 behavior) on kind under h3 load; before this patch that is the #1074 crash, after it the removed cluster's connections drain and close normally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WyMzptZ12rAgMW8cXtKqE4

…ve after a CDS removal (#1074)

Carries envoy-aether1074-quic-persistent-info-lifetime.patch on the 726d7ac
pin, after aether1054c. The per-cluster persistent QUIC info (connection
helper and clock, alarm factory, QUIC config) was owned by the thread-local
cluster entry while HTTP/3 pools referenced it and their connections held
raw pointers into it. A CDS removal destroys the entry after only draining
its pools, so a pool with live streams outlived the info and the next write
or alarm read the freed clock: the w01 SIGBUS in QuicConnection::CanWrite.
The info is now shared and each HTTP/3 pool and connectivity grid holds a
reference. An upstream bug. Its test (http3 conn_pool_test) needs quiche's
test tooling and runs in the Envoy workspace only; carried_patch_tests
passes and //:envoy builds with the patch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WyMzptZ12rAgMW8cXtKqE4
Signed-off-by: Bruno Palermo <[email protected]>
@bpalermo
bpalermo merged commit 71be75f into main Sep 30, 2026
25 checks passed
@bpalermo
bpalermo deleted the proxy/1074-quic-client-teardown-uaf branch September 30, 2026 09:20
@bpalermo

Copy link
Copy Markdown
Owner Author

Kind red/green (real CDS removal of a live h3 twin, no code revert)

Two kind nodes; a loader pod (SA ldr) drove ~400 rps plus 16 concurrent 0.5 s streams through a quic: twin (15–22 requests in flight at each removal). Trigger: delete the destination's registrar-generated Service while load flows → it leaves the dependency set → the agent CDS-removes the twin and its h2 clusters (cds: … removed 3|4 cluster(s)); the registrar recreates the Service 1–5 s later. Each destination used once.

arm proxy CDS removals Envoy crashes
RED unpatched main pin (a1bcf05) 23 4 (+1 during setup) — Caught Segmentation fault … #1 quic::QuicConnection::OnCanWrite ← EnvoyQuicClientConnection::OnCanWrite ← WriteIfNotBlocked ← EnvoyQuicClientConnection::onFileEvent ~1.5 s after the removal
GREEN patched (8aceedb, verified via /server_info) 34 0 (0 restarts, no Caught/exited unexpectedly)

4/23 ≈ 17% per removal, so 0/34 by chance ≈ 0.2%. With the patch, in-flight h3 streams on the removed twin completed with 200 (no 5xx); the only client errors were connect failures while the Service itself was deleted (the trigger, not the drain).

bpalermo added a commit that referenced this pull request Sep 30, 2026
…ied patches, config tables, CLAUDE.md package map (#1081)

* docs: refresh after the QUIC/hot-restart work — rollback advice, carried patches, config tables, CLAUDE.md package map

- runbook: the 1.0.11 escape hatch rolls the proxy (a1bcf05 vs 71be75f) and
  drops the #1074 patch unless proxy.image + proxy.supervisor.image are
  pinned; #979 is merged (soak-verdict placeholder); #1069 named as the
  #1054 root cause; new #1074 SIGBUS entry (#1077, envoyproxy/envoy#47893,
  chart 1.0.13); stray "0 disables the prune" moved.
- configuration: proxy drainStrategy/skipParentStats/terminationGrace,
  agent eastWestQuicIdleTimeout + flag, controller identity-gate flags,
  identity-ready section, cni-install --otlp-pin-endpoint, edge/registrar
  rows (the shared edge Service has no `type`; overload is fixed_heap).
- CLAUDE.md/AGENTS.md: TPROXY capture, QUIC/xDS/supervisor/CNI packages,
  port map, carried patches; proxy-ready ships in the supervisor image.
- README, getting-started, e2e, proposals 037/038/040 status lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* docs: record the 2026-09-30 re-soak verdict for the unconditional-QUIC build (#979)

Every QUIC gate passed and #1073/#1074 did not recur; the run failed only on
liveness (9 / 719,984) from a hot-restart/agent-restart overlap (#1085).
First-use 503 NC burst and TRIPLE 504 UT filed as #1086 and #1087.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant