From 0abedcdd9b57a1e4751d2cbed69eb6f627995746 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 10 Nov 2026 21:49:39 -0800 Subject: [PATCH 1/3] quest: import #507 and #506; close #460 as moq-owned Plan QMux receive-credit accounting for stopped streams (a0) and the OS platform verifier for Rust builders and FFI clients (a1). Co-Authored-By: Claude Opus 5.5 --- quest/a0/README.md | 1 + quest/a0/qmux-recv-credit.md | 25 +++++++++++++++++++++++++ quest/a1/README.md | 2 ++ quest/a1/ffi-platform-verifier.md | 19 +++++++++++++++++++ quest/a1/platform-verifier.md | 18 ++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 quest/a0/qmux-recv-credit.md create mode 100644 quest/a1/ffi-platform-verifier.md create mode 100644 quest/a1/platform-verifier.md diff --git a/quest/a0/README.md b/quest/a0/README.md index a2e386e0..6cb3b81b 100644 --- a/quest/a0/README.md +++ b/quest/a0/README.md @@ -12,3 +12,4 @@ The Required list is ordered by priority. Independent children may proceed concu - [Quiche lifecycle](/quest/a0/quiche/README.md) - deterministic harness and retirement handling - [Node session and reader lifetime](/quest/a0/node-session-lifetime.md) - `closed` rejects on an abnormal end, and an abandoned reader releases its stream +- [QMux receive credit](/quest/a0/qmux-recv-credit.md) - stopped or dropped streams return their connection flow-control credit diff --git a/quest/a0/qmux-recv-credit.md b/quest/a0/qmux-recv-credit.md new file mode 100644 index 00000000..d9ba2f30 --- /dev/null +++ b/quest/a0/qmux-recv-credit.md @@ -0,0 +1,25 @@ +# [M] Return connection credit for stopped QMux receive streams + +## Goal + +Stopping or dropping a Rust QMux `RecvStream` with unread data no longer shrinks the connection's `MAX_DATA` window. Per RFC 9000 §4.5, every byte the peer sent on a stopped stream, up to its final size, is credited back to connection flow control exactly once, so abandoned streams can never wedge a healthy session. + +Ships on `main` as the next `qmux` 0.6.x patch. No `qmux-v0.5.x` backport. The TypeScript QMux already discards and credits on cancel, so it is out of scope. + +## Plan + +Three paths leak in `rs/qmux/src/session.rs` today; `report_consumed` only runs on application reads: + +- Unread bytes at `stop()` or `Drop`: the unread remainder of the current chunk plus whatever is still queued in `inbound_data`. +- STREAM data that arrives after STOP_SENDING. The writer task removes the recv entry when STOP_SENDING is queued, so late data is then either ignored before connection credit is counted (peer-initiated) or counted and never returned (locally initiated). +- The RESET_STREAM gap for an entry that has already been removed; it is never charged or credited. + +Decision: keep the stream's receive state after a local stop until its final size is known, as moq-dev/moq's `moq-quic` does. Do not only credit the bytes buffered at stop, because late data would still leak. On stop or drop, credit the unread and queued bytes. While the entry is stopped, count late STREAM data as received and credit it immediately, and credit the RESET_STREAM gap, then retire the entry on FIN or reset. A duplicate or late frame after retirement must not double-count, which preserves the existing post-terminal ignore and duplicate-RESET rules. The writer task's STOP_SENDING removal and the session task's lookups race today (see the comments at the STREAM and RESET_STREAM handlers), so the stopped state must close that race rather than add a new one. + +Regression tests, which fail without the fix: the reporter's scenario, where the peer writes more than half the stream window into each of N streams, each `RecvStream` is dropped unread, and a fresh stream still receives data; late data after STOP_SENDING; and a reset gap after a local stop. The draft-00/01 (non-QMux) paths have no connection flow control and must stay unchanged. + +Reference: moq-dev/moq's equivalent tests, `rs/moq-quic/src/connection/mux/tests.rs` `credit_returns_for_unread_and_stopped_streams` and `rs/moq-quic/src/tests/characterize/reset.rs` `stop_returns_connection_credit`. + +## Closes + +- [#507](https://github.com/moq-dev/web-transport/issues/507) - stopped/dropped RecvStream leaks connection flow-control credit diff --git a/quest/a1/README.md b/quest/a1/README.md index f186414c..c8b70741 100644 --- a/quest/a1/README.md +++ b/quest/a1/README.md @@ -14,5 +14,7 @@ The Required list is ordered by priority. Independent children may proceed concu - [Binding runtime coverage](/quest/a1/bindings/README.md) - independent language jobs - [Node idle configuration](/quest/a1/node-idle/README.md) - typed native input and Node options - [Response headers](/quest/a1/response-headers.md) - preserve success and rejection metadata +- [Rust platform verifier](/quest/a1/platform-verifier.md) - `with_system_roots()` verifies with the OS trust store +- [FFI platform verifier](/quest/a1/ffi-platform-verifier.md) - bindings verify on iOS and Android - [Current architecture docs](/quest/a1/docs-current.md) - repair stale workspace descriptions - [Package selection](/quest/a1/package-selection.md) - verified comparison and selection guide diff --git a/quest/a1/ffi-platform-verifier.md b/quest/a1/ffi-platform-verifier.md new file mode 100644 index 00000000..14922d18 --- /dev/null +++ b/quest/a1/ffi-platform-verifier.md @@ -0,0 +1,19 @@ +# [M] Verify FFI clients with the OS platform verifier + +## Goal + +Python, Kotlin and Swift clients that use default verification (neither certificate hashes nor disabled verification) verify servers with the OS trust store on every platform, including iOS and Android. Today `rs/web-transport-ffi/src/client.rs` loads `rustls-native-certs`, which finds no roots on iOS and likely none on Android, so those clients cannot verify any server. + +## Plan + +Follow moq-dev/moq#1968. The FFI client verifies with rustls-platform-verifier on its existing provider, and `rustls-native-certs` is dropped. On Android, add a `JNI_OnLoad` that initializes the platform verifier from the application Context (moq uses `android.app.ActivityThread.currentApplication()`), clearing any pending JNI exception so loading the library never fails. Until initialization succeeds, Android falls back to bundled webpki-roots and logs a warning. The fallback is Android-only. + +Update the Kotlin and Swift READMEs where they describe verification. Python, Kotlin and Swift share the `web-transport-ffi-v*` release. + +## Closes + +- [#506](https://github.com/moq-dev/web-transport/issues/506) - support for the platform verifier + +## Related + +- [Rust platform verifier](/quest/a1/platform-verifier.md) - the same switch in the Rust builders diff --git a/quest/a1/platform-verifier.md b/quest/a1/platform-verifier.md new file mode 100644 index 00000000..d24af6f7 --- /dev/null +++ b/quest/a1/platform-verifier.md @@ -0,0 +1,18 @@ +# [S] Verify system roots with the OS platform verifier + +## Goal + +`ClientBuilder::with_system_roots()` in web-transport-quinn and web-transport-noq verifies server certificates with rustls-platform-verifier, so the OS trust store decides, including custom enterprise roots and revocation where the OS supports them. The generic `web-transport` builder and the Node binding inherit this through web-transport-quinn. The method names stay the same; the PR reports the behavior change. + +## Plan + +Follow moq-dev/moq#1968, which made the same switch in moq-native. Replace the `rustls_native_certs` root loading in both builders with the platform verifier on the crate's existing provider (`crypto::default_provider()`), so rind stays the default provider. Drop the `rustls-native-certs` dependency from both crates. Also drop quinn's and noq's `platform-verifier` feature, which nothing uses: it only enables `ClientConfig::try_with_platform_verifier`, which bypasses this crate's provider-neutral crypto adapter. + +The FFI client does not use these builders and is handled in [FFI platform verifier](/quest/a1/ffi-platform-verifier.md). Android needs JNI initialization that only that quest provides. Here, document in the builders that on Android the platform verifier requires app initialization. + +Coordinate with [Noq on rind](/quest/a1/rind/noq.md), which rewrites the noq client builder; whichever lands second resolves the conflict. Update the crate READMEs and doc comments that describe `with_system_roots()`. + +## Related + +- [Issue #506](https://github.com/moq-dev/web-transport/issues/506) - platform verifier support; closed by the FFI quest +- [FFI platform verifier](/quest/a1/ffi-platform-verifier.md) - same switch for the language bindings From 666ceb82f22a1a9715fe9f77afe532cd76f077ee Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 10 Nov 2026 22:14:49 -0800 Subject: [PATCH 2/3] fix(nix): pin bindgen to the shell's libclang ubuntu-latest runners now ship /usr/lib/llvm-22. Without LIBCLANG_PATH, clang-sys picks the highest libclang version it finds, which is the host's, and it cannot load inside the Nix shell (libffi.so.8 missing), breaking the boring-sys build in CI. Co-Authored-By: Claude Opus 5.5 --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 0fe582eb..e2605d38 100644 --- a/flake.nix +++ b/flake.nix @@ -86,6 +86,8 @@ packages = tools; shellHook = '' + # bindgen otherwise prefers a newer host libclang, which cannot load in this shell. + export LIBCLANG_PATH=${pkgs.llvmPackages.libclang.lib}/lib # Linux Python extension wheels also need the compiler's C++ runtime. export LD_LIBRARY_PATH=${ pkgs.lib.makeLibraryPath ( From 694ca6714b1e5053ef0ddad1cfcf39c11e551066 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 10 Nov 2026 22:43:56 -0800 Subject: [PATCH 3/3] quest: address review on QMux credit and FFI verifier plans Correct the TypeScript QMux scope note, bound retained stopped-stream state by deferring MAX_STREAMS credit, and cover Android init paths and the verifier's Kotlin component. Co-Authored-By: Claude Opus 5.5 --- quest/a0/qmux-recv-credit.md | 4 ++-- quest/a1/ffi-platform-verifier.md | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/quest/a0/qmux-recv-credit.md b/quest/a0/qmux-recv-credit.md index d9ba2f30..e0572741 100644 --- a/quest/a0/qmux-recv-credit.md +++ b/quest/a0/qmux-recv-credit.md @@ -4,7 +4,7 @@ Stopping or dropping a Rust QMux `RecvStream` with unread data no longer shrinks the connection's `MAX_DATA` window. Per RFC 9000 §4.5, every byte the peer sent on a stopped stream, up to its final size, is credited back to connection flow control exactly once, so abandoned streams can never wedge a healthy session. -Ships on `main` as the next `qmux` 0.6.x patch. No `qmux-v0.5.x` backport. The TypeScript QMux already discards and credits on cancel, so it is out of scope. +Ships on `main` as the next `qmux` 0.6.x patch. No `qmux-v0.5.x` backport. The TypeScript QMux is out of scope. It credits the bytes buffered at cancel, but it then deletes the receive entry, so STREAM data and RESET_STREAM gaps that arrive after cancel still leak there. ## Plan @@ -14,7 +14,7 @@ Three paths leak in `rs/qmux/src/session.rs` today; `report_consumed` only runs - STREAM data that arrives after STOP_SENDING. The writer task removes the recv entry when STOP_SENDING is queued, so late data is then either ignored before connection credit is counted (peer-initiated) or counted and never returned (locally initiated). - The RESET_STREAM gap for an entry that has already been removed; it is never charged or credited. -Decision: keep the stream's receive state after a local stop until its final size is known, as moq-dev/moq's `moq-quic` does. Do not only credit the bytes buffered at stop, because late data would still leak. On stop or drop, credit the unread and queued bytes. While the entry is stopped, count late STREAM data as received and credit it immediately, and credit the RESET_STREAM gap, then retire the entry on FIN or reset. A duplicate or late frame after retirement must not double-count, which preserves the existing post-terminal ignore and duplicate-RESET rules. The writer task's STOP_SENDING removal and the session task's lookups race today (see the comments at the STREAM and RESET_STREAM handlers), so the stopped state must close that race rather than add a new one. +Decision: keep the stream's receive state after a local stop until its final size is known, as moq-dev/moq's `moq-quic` does. Do not only credit the bytes buffered at stop, because late data would still leak. On stop or drop, credit the unread and queued bytes. While the entry is stopped, count late STREAM data as received and credit it immediately, and credit the RESET_STREAM gap, then retire the entry on FIN or reset. A peer-initiated stream returns its MAX_STREAMS credit when its entry retires, not when the `RecvStream` drops, so a peer that withholds FIN and RESET_STREAM cannot grow the retained state past the stream limit. A duplicate or late frame after retirement must not double-count, which preserves the existing post-terminal ignore and duplicate-RESET rules. The writer task's STOP_SENDING removal and the session task's lookups race today (see the comments at the STREAM and RESET_STREAM handlers), so the stopped state must close that race rather than add a new one. Regression tests, which fail without the fix: the reporter's scenario, where the peer writes more than half the stream window into each of N streams, each `RecvStream` is dropped unread, and a fresh stream still receives data; late data after STOP_SENDING; and a reset gap after a local stop. The draft-00/01 (non-QMux) paths have no connection flow control and must stay unchanged. diff --git a/quest/a1/ffi-platform-verifier.md b/quest/a1/ffi-platform-verifier.md index 14922d18..f0092742 100644 --- a/quest/a1/ffi-platform-verifier.md +++ b/quest/a1/ffi-platform-verifier.md @@ -8,6 +8,12 @@ Python, Kotlin and Swift clients that use default verification (neither certific Follow moq-dev/moq#1968. The FFI client verifies with rustls-platform-verifier on its existing provider, and `rustls-native-certs` is dropped. On Android, add a `JNI_OnLoad` that initializes the platform verifier from the application Context (moq uses `android.app.ActivityThread.currentApplication()`), clearing any pending JNI exception so loading the library never fails. Until initialization succeeds, Android falls back to bundled webpki-roots and logs a warning. The fallback is Android-only. +`JNI_OnLoad` alone is not enough on Android: + +- JNA can load the library without running `JNI_OnLoad`. The Kotlin Android code must guarantee initialization before the first client, for example by loading the library through `System.loadLibrary`. +- `currentApplication()` returns null if the library loads before the Application exists. Retry initialization when each client is built. A client built during the fallback keeps webpki-roots. +- rustls-platform-verifier needs its Android Kotlin component at runtime. Ship it in the Android artifact with its shrinker keep rules, and document the same setup for Rust users on Android. + Update the Kotlin and Swift READMEs where they describe verification. Python, Kotlin and Swift share the `web-transport-ffi-v*` release. ## Closes