From 3e30dcfad7b7098be5afef38a5c5e163466db874 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 10:31:25 -0700 Subject: [PATCH 01/13] quest: plan the security audit findings Ten quests cover what the 2026-10-22 audit found outside the three Highs already fixed in separate PRs: peer count bounds, caption store bounds, the auth contract, HLS import origin, MSF duplicate ids, E2EE lifecycle, the C ABI, TS program fan-out, AMF0 reads, image hardening, and wire fuzz coverage. Co-Authored-By: DeepSeek V4.1 Flash --- quest/m0/README.md | 1 + quest/m0/hls-import-origin.md | 30 +++++++++++++++++++++++ quest/m1/README.md | 3 +++ quest/m1/auth-contract.md | 29 ++++++++++++++++++++++ quest/m1/c/README.md | 1 + quest/m1/c/abi-version.md | 29 ++++++++++++++++++++++ quest/m1/caption-store-bounds.md | 29 ++++++++++++++++++++++ quest/m1/peer-count-bounds.md | 31 ++++++++++++++++++++++++ quest/m1/ts-reliability/README.md | 1 + quest/m1/ts-reliability/program-cap.md | 22 +++++++++++++++++ quest/m2/README.md | 4 ++++ quest/m2/e2ee/README.md | 3 +++ quest/m2/e2ee/lifecycle-hardening.md | 33 ++++++++++++++++++++++++++ quest/m2/image-hardening.md | 23 ++++++++++++++++++ quest/m2/msf-duplicate-init.md | 20 ++++++++++++++++ quest/m2/rtmp-amf0-exact-reads.md | 18 ++++++++++++++ quest/m2/wire-fuzz-coverage.md | 32 +++++++++++++++++++++++++ 17 files changed, 309 insertions(+) create mode 100644 quest/m0/hls-import-origin.md create mode 100644 quest/m1/auth-contract.md create mode 100644 quest/m1/c/abi-version.md create mode 100644 quest/m1/caption-store-bounds.md create mode 100644 quest/m1/peer-count-bounds.md create mode 100644 quest/m1/ts-reliability/program-cap.md create mode 100644 quest/m2/e2ee/lifecycle-hardening.md create mode 100644 quest/m2/image-hardening.md create mode 100644 quest/m2/msf-duplicate-init.md create mode 100644 quest/m2/rtmp-amf0-exact-reads.md create mode 100644 quest/m2/wire-fuzz-coverage.md diff --git a/quest/m0/README.md b/quest/m0/README.md index 0417e3de2bd..4e9a3e55c70 100644 --- a/quest/m0/README.md +++ b/quest/m0/README.md @@ -51,3 +51,4 @@ Each lands its fixes in its own PR and plans only what needs a decision. - [Simplification audit](/quest/m0/audit-simplify.md) - overbuilt code and APIs are collapsed, merged, or narrowed into a net simpler whole - [Lint override and deprecation audit](/quest/m0/audit-lints.md) - every lint suppression is still needed and says why, nothing calls a deprecated API, and stale Rust overrides fail the build - [Interop audit](/quest/m0/audit-interop.md) - our interop runner entries match what we ship, and every red interop cell with a moq.dev side is fixed, reported, or noted as down +- [HLS import origin](/quest/m0/hls-import-origin.md) - a playlist cannot make the importer read a local file or reach another origin, on `main` or the current release diff --git a/quest/m0/hls-import-origin.md b/quest/m0/hls-import-origin.md new file mode 100644 index 00000000000..d11de578316 --- /dev/null +++ b/quest/m0/hls-import-origin.md @@ -0,0 +1,30 @@ +# [S] HLS import trusts only its playlist's origin + +## Goal + +The HLS importer follows nothing a playlist names outside the origin it was configured with: + +- `resolve_uri` accepts a relative reference, or an absolute URL whose scheme and authority equal the playlist's. +- `file:` is read only when the playlist itself is a `file:` URL. +- A variant's `RESOLUTION` multiplication cannot overflow. + +Today `rs/moq-hls/src/import.rs` returns any absolute URL verbatim, and `Fetcher::fetch` opens `file:` paths and issues arbitrary GETs. A hostile or compromised playlist can therefore read local files and reach the operator's internal network, and `width * height` can panic on a debug build. + +This code is on `release`, so the fix lands on `main` and is ported onto `release` as a separate PR that keeps the published API. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Check scheme and authority in `resolve_uri`, not at each fetch site, so `EXT-X-MAP`, every segment, and future references share one rule. +- Keep `file:` for a `file:` playlist, which is how local test fixtures work. +- Compute the variant area with `saturating_mul`. + +Tests: a playlist naming `file:///etc/passwd`, an instance-metadata address, and a cross-origin map and segment is refused; a relative segment still resolves; an enormous `RESOLUTION` does not panic. + +Public API: none. Wire: none. + +## Related + +- [Focused release backports](/quest/m0/release-backports/README.md) - the release port joins this shortlist once the main fix lands +- [MKV dimension overflow](/quest/m2/mkv-dimension-overflow.md) - the same class of catalogue-field overflow in another importer diff --git a/quest/m1/README.md b/quest/m1/README.md index e89770e38f3..b03c6217a2e 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -117,6 +117,9 @@ lite-07 stream type here. - [CI workflow audit](/quest/m1/audit-ci.md) - every workflow and job gives a signal someone sees, at a cost that signal justifies, or is fixed, moved, or deleted - [Artifact size audit](/quest/m1/audit-size.md) - binary, FFI, WASM, and bundle growth since the m0 run is explained, fixed, or planned - [Compile time audit](/quest/m1/audit-compile-time.md) - build-time hotspots are measured against the m0 baselines and the worst are fixed or planned +- [Peer count bounds](/quest/m1/peer-count-bounds.md) - namespace interests, a legacy announce list, a WebSocket upgrade, and public HTTP admission are bounded by what the peer sent or by an existing budget +- [Caption store bounds](/quest/m1/caption-store-bounds.md) - a hostile caption track cannot grow a viewer's cue and region store or its per-frame work without bound +- [Auth contract](/quest/m1/auth-contract.md) - the auth server receives the real SNI, a certificate grants nothing alone, and the auth client refuses a redirect that would replay a credential - [Performance audit](/quest/m1/audit-perf.md) - benchmarks that regressed since the m0 run are explained, fixed, or planned, and unbenched hot paths get coverage ## Related diff --git a/quest/m1/auth-contract.md b/quest/m1/auth-contract.md new file mode 100644 index 00000000000..bbc86cd8ac0 --- /dev/null +++ b/quest/m1/auth-contract.md @@ -0,0 +1,29 @@ +# [M] The auth request reports the real SNI and nothing weaker + +## Goal + +The auth server decides from facts the client cannot choose: + +- `moq_auth::Request::server_name` is the TLS SNI on every transport, as its contract says, not the client's `Host` or `:authority`. +- A verified client certificate stays a fact unless the auth server's grant says `peer`; it never reveals hidden routes on its own. +- The auth HTTP client cannot be redirected to another host with the session request in its body. + +Today `admit_http` fills `server_name` from `request_host(uri, headers)`, and the WebSocket bridge builds its URL from the same header. A client can therefore tell a hostname-scoped auth server it dialed a tenant it never dialed. `cluster_peer` also treats any certificate as a peer for hidden-route discovery. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Add `server_name()` to the `HttpStream` trait and return `TlsStream::get_ref().1.server_name()`; use it in `admit_http` and in the WebSocket session's link. Fall back to `Host` only on the plain-HTTP listener, and say so in the doc. +- Derive hidden-route visibility from the grant's `peer` flag, not `request.tls.is_some()`. Until peers set it, document the exemption where operators read it. +- Set `reqwest::redirect::Policy::none()` in `moq_auth::Client`, and bound the reply body. A 307/308 currently replays the credential-bearing request to wherever the auth server points. +- Update `doc/bin/relay/auth.md` so `server_name`, `peer`, and the certificate-is-a-fact rule match what the code does. + +Tests: an HTTP/1.1 request with a forged `Host` still reports the SNI; the same over WebSocket; a redirect answer is refused; a certificate-only session sees no hidden routes. + +Public API: one method on an internal trait, and a redirect policy. Wire: none. + +## Related + +- [In-band auth](/quest/m1/auth/README.md) - the request and grant contract this corrects +- [Focused release backports](/quest/m0/release-backports/README.md) - the auth client is shared with `release`, so check whether the redirect policy is a backport candidate diff --git a/quest/m1/c/README.md b/quest/m1/c/README.md index 21105a6f61d..627a156dbe9 100644 --- a/quest/m1/c/README.md +++ b/quest/m1/c/README.md @@ -66,3 +66,4 @@ requests internally and keeps its ABI, so that quest does not wait here. - [moq-c package](/quest/m1/c/package.md) - the generated header ships as `moq-c` 0.8.0 with `moq::c`, pkg-config, and a release workflow - [C consumers](/quest/m1/c/consumers.md) - the C interop client and `doc/lib/c` samples move onto the generated API +- [ABI version](/quest/m1/c/abi-version.md) - a C caller cannot be laid out against a newer library, and an early failure is documented as having no handle and no callback diff --git a/quest/m1/c/abi-version.md b/quest/m1/c/abi-version.md new file mode 100644 index 00000000000..0032ebf8055 --- /dev/null +++ b/quest/m1/c/abi-version.md @@ -0,0 +1,29 @@ +# [S] A C caller cannot be laid out against a newer library + +## Goal + +A program built against an older `moq.h` cannot have its config struct overflowed by a newer library, and an early failure is documented as having no handle and no callback: + +- Each `#[repr(C)]` config struct carries its own size, set by the caller, and the library refuses a size it does not know. +- `moq_client_defaults()` cannot write a larger struct into an older caller's slot. +- `moq_session_connect` and every other `on_status` registration say that a negative return means no handle and no callback, so the caller owns `user_data`. +- A spawned callback's cleanup cannot be lost to a poisoned mutex. + +Today the config structs have no size field, `moq_client_defaults()` returns by value, and `moq_session_connect` says to call close even on error. The bandwidth change wait calls `callback.call` outside `ffi::run`, so a panic there drops the terminal callback silently. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Add a leading `size` field to `moq_client_config` and the other config structs, and a `moq_abi_version()` for diagnostics. Zero is refused, so a caller that forgets the field fails loudly rather than reading uninitialized fields. +- Fix the "adding a field does not disturb existing callers" comment: it is true only when both sides agree on the size. +- Document the immediate-failure contract on every registration that returns a handle. +- Move the spawned cleanup inside `ffi::run`, or match `state.rs`'s `PoisonError::into_inner`. + +Tests: a zero size is refused; a short size is refused; the documented failure paths fire no callback. + +Public API: additive fields and one function. Wire: none. + +## Related + +- [Generated C bindings](/quest/m1/c/README.md) - the ABI this hardens before more consumers adopt it diff --git a/quest/m1/caption-store-bounds.md b/quest/m1/caption-store-bounds.md new file mode 100644 index 00000000000..b579270f17c --- /dev/null +++ b/quest/m1/caption-store-bounds.md @@ -0,0 +1,29 @@ +# [M] Bound the caption cues and regions a peer can accumulate + +## Goal + +A caption track from an untrusted publisher cannot grow a viewer's cue store, or its per-frame work, faster than the viewer plays: + +- `store.cues` and `store.regions` in `js/watch/src/text/renderer.ts` are bounded by the playhead window and a per-track ceiling. +- A payload with many cues parses in O(n log n), not by walking and splicing per cue. +- A cue's declared end time cannot keep it resident past a maximum duration. +- A region no retained cue references is dropped. + +Today `pruneCues` drops only cues whose end is behind the playhead, so a far-future cue is never pruned, and `store.regions` is never pruned at all. `insertCue` walks backwards and splices at the index for every cue, so a descending payload is quadratic. `commit()` rebuilds the overlay from the whole store on every group, so the per-frame cost compounds the growth. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Clamp a cue's end to its start plus a maximum cue duration, and drop cues behind the existing `PRUNE_BEHIND` horizon. +- Prune regions that no retained cue references in the same sweep, and cap both maps, evicting oldest first. Neither cap refuses a payload; they bound what the viewer retains. +- Insert by binary search, or sort once per payload, instead of the backward walk plus splice. +- Keep the double-escaped `sanitizeCue` and its renderer-version test unchanged: the audit confirmed the pinned `media-captions` builds only double-quoted attributes, so the current escape set is sufficient. + +Tests cover a future-dated cue stream, a fresh region per frame, and a descending 100k-cue payload, each asserting the bounded store and the same rendered text. + +Public API: none. + +## Related + +- [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - the other viewer-side measurement the audit bounded diff --git a/quest/m1/peer-count-bounds.md b/quest/m1/peer-count-bounds.md new file mode 100644 index 00000000000..90b594ba3b8 --- /dev/null +++ b/quest/m1/peer-count-bounds.md @@ -0,0 +1,31 @@ +# [M] Bound the state and work a peer's counts can choose + +## Goal + +Every count a peer sends that allocates or scans is bounded by what the peer actually sent, or by an existing budget, rather than by the number itself: + +- `SUBSCRIBE_NAMESPACE` retains no more namespaces than the session's announce budget (`rs/moq-net/src/ietf/subscriber.rs`, the per-stream `live` map). +- `ANNOUNCE_INIT` cannot turn a message body into a much larger allocation (`rs/moq-net/src/lite/announce.rs`). +- A WebSocket upgrade buffers no more than one qmux record before SETUP (`rs/moq-relay/src/websocket.rs`). +- Public HTTP admission is bounded per connection and per request (`rs/moq-relay/src/web.rs`, `rs/moq-relay/src/auth.rs`). + +The `AUTH_OK` pattern reduction is already done in [#6356](https://github.com/moq-dev/moq/pull/6356) and is not repeated here. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- ✅ The `AUTH_OK` fix reduces in one pass, with no new pattern cap (#6356). +- A namespace interest takes its `announces` permit before the decision, as moq-lite already does, and releases it only when the stream ends. A reflected or refused namespace therefore holds the same permit every other announce does. +- `ANNOUNCE_INIT` is a legacy lite-01/02 message. Make its decoder take the session's announce budget, or otherwise bound the count by the body and that budget, so the existing resource limit is the bound rather than a new constant. +- The WebSocket socket caps message and frame size at qmux's own `max_record_size`, from one shared constant, since qmux carries one record per message. +- `admit_http` takes a semaphore permit, and the h2 listener sets `max_concurrent_streams`. Over the limit answers 503 instead of queueing, which is backpressure rather than a refusal of valid input. + +Each fix lands with a regression test that fails on main. The admission fan-out gets a benchmark swept over connections and streams, per the fan-out rule. + +Public API: none. Wire: none. + +## Related + +- [In-band auth](/quest/m1/auth/README.md) - the `AUTH_OK` decoders this area started from +- [Relay session limits](/quest/m0/README.md) - the existing per-session request caps these follow diff --git a/quest/m1/ts-reliability/README.md b/quest/m1/ts-reliability/README.md index 2cedd1b3ba6..0d00a1654b0 100644 --- a/quest/m1/ts-reliability/README.md +++ b/quest/m1/ts-reliability/README.md @@ -91,6 +91,7 @@ remain with their current quests. - [PAT changes](/quest/m1/ts-reliability/pat-lifecycle.md) - a revised PAT never leaves a broadcast meaning another program - [Stream routes](/quest/m1/ts-reliability/stream-routes.md) - every PID gets a declared route, and what is not carried is counted - [Release clock false alarms](/quest/m1/ts-reliability/release-clock-false-alarms.md) - no false jitter leap at a 500 ms delay and no false drift alarm +- [Program cap](/quest/m1/ts-reliability/program-cap.md) - a PAT listing every program number cannot create a broadcast per program ## Related diff --git a/quest/m1/ts-reliability/program-cap.md b/quest/m1/ts-reliability/program-cap.md new file mode 100644 index 00000000000..48c3be70062 --- /dev/null +++ b/quest/m1/ts-reliability/program-cap.md @@ -0,0 +1,22 @@ +# [XS] TS import bounds the programs a PAT can create + +## Goal + +`moq import ts --program all` creates a broadcast per PAT program only up to a bound the run already has, instead of one per `u16` a hostile multiplex can name. + +Today `rs/moq-mux/src/container/ts/programs.rs` loops over every `pat.program_numbers()` and creates a broadcast, catalog producer, importer, and consumer for each. A sub-megabyte transport stream can list all 65,536 program numbers across PAT sections, so one input creates tens of thousands of live broadcasts. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Bound the program count by the origin's announce budget, or by an operator-selected program list, rather than a new arbitrary constant. `--program all` is opt-in; the default already refuses multi-program input. +- Fail the import with the existing multi-program error shape, naming the count and the bound. +- Test with a synthesized PAT naming far more programs than a real multiplex. + +Public API: one new error case. Wire: none. + +## Related + +- [TS fidelity and recovery](/quest/m1/ts-reliability/README.md) - the TS import contract this belongs to +- [PMT lifecycle](/quest/m1/ts-reliability/pat-lifecycle.md) - the PAT handling beside it diff --git a/quest/m2/README.md b/quest/m2/README.md index c6dbabf0107..152acba67b8 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -102,6 +102,10 @@ ranked just below deterministic TS legs, which it requires. - [Mobile completion](/quest/m2/mobile-completion.md) - verify the Swift and Kotlin bindings over Rust-owned capture - [Bindings in the interop matrix](/quest/m2/interop-bindings.md) - Kotlin, Swift, and Dart publish and subscribe against every other interop client - [WebGPU HDR](/quest/m2/webgpu-hdr.md) - HDR renditions play as HDR where the browser and display can show it, and tone-map to SDR elsewhere +- [MSF duplicate init](/quest/m2/msf-duplicate-init.md) - an MSF catalog refuses a repeated `initDataList` id instead of resolving it last-wins +- [AMF0 exact reads](/quest/m2/rtmp-amf0-exact-reads.md) - a truncated RTMP string fails with `UnexpectedEof` instead of parsing NUL padding +- [Image hardening](/quest/m2/image-hardening.md) - the relay image runs unprivileged and its builder stage is pinned +- [Wire fuzz coverage](/quest/m2/wire-fuzz-coverage.md) - every peer-facing decoder has a target that asserts an invariant, and the unsafe peer input reaches runs under Miri - [One port](/quest/m2/one-port/README.md) - one UDP port carries QUIC, SRT, and WebRTC media through an embedder hook, and one TCP port carries HTTP, RTMP, and RTMPS - [QUIC caps](/quest/m2/rate-quic.md) - paced MAX_DATA credit in and a capped pacer out hold a QUIC session to its token's bitrate - [WebSocket caps](/quest/m2/rate-websocket.md) - paced reads and writes over bounded socket buffers hold WebSocket to the same caps diff --git a/quest/m2/e2ee/README.md b/quest/m2/e2ee/README.md index 25b8bcecb71..b48c73cf259 100644 --- a/quest/m2/e2ee/README.md +++ b/quest/m2/e2ee/README.md @@ -66,6 +66,9 @@ Decided with the maintainer on 2026-10-17: physical names are a one-way hash, so - [Cross-language encrypted proof](/quest/m2/e2ee/interop.md) - browser TypeScript and native Rust exchange encrypted media both ways, with relays forwarding and metering blind +- [One epoch, one producer](/quest/m2/e2ee/lifecycle-hardening.md) - the epoch rule + holds in the TypeScript API, a failed grouped write ends the group, and an + out-of-range datagram is dropped ## Closes diff --git a/quest/m2/e2ee/lifecycle-hardening.md b/quest/m2/e2ee/lifecycle-hardening.md new file mode 100644 index 00000000000..e8cff2a2609 --- /dev/null +++ b/quest/m2/e2ee/lifecycle-hardening.md @@ -0,0 +1,33 @@ +# [M] E2EE lifecycle invariants hold in every API + +## Goal + +The rules the [E2EE epic](/quest/m2/e2ee/README.md) already decided hold in every API, not only in Rust: + +- A producing generation can only be opened under an epoch it minted, so two producers can never share an epoch and repeat an AES-GCM nonce. +- A grouped write that fails after encryption ends the group, because the transport's frame index can no longer line up with the nonce. +- A datagram whose wire identity is out of range is dropped with the bad-datagram event, not thrown as a fatal error. +- The AEAD operation and byte budgets are per key, or the per-subscription receiver reset is documented. +- The draft states what a relay can truncate inside a group, so an application never mistakes a short group for a complete one. + +The Rust core already keeps the epoch unrepresentable outside the crate. The TypeScript package exports the concrete `Generation.Producer` through `export * as Generation`, and `Producer.make` is a public static that ships in the types. An app that persists an epoch and calls it twice gets two producers with independent claims, both starting at group 0 and frame 0 under the same key. The Rust grouped writer also leaves a group open after a post-encryption `write_frame` error, while the TS twin aborts. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Keep the typed generation shape in the runtime but stop exporting the concrete class: export a `Producer`/`Consumer` interface, or gate `make` behind a module-private capability from `internal.ts`. A test asserts the package surface cannot mint a producer for a fixed epoch. +- Abort the Rust group on any `inner.write_frame` error, matching `js/e2ee/src/group.ts`, and add the Rust twin of the TS test. +- Map an out-of-range sequence or an oversize payload to the dropped-datagram event in both languages, with a `2^53` sequence test in each suite. +- Scope the AEAD counters to the `(generation, physical name, domain)` tuple in the owning consumer, or state the per-subscription receiver cap in the draft's limits. +- State the mid-group truncation limit in the draft's security considerations, or add an authenticated terminal object if group atomicity is meant to be a guarantee. The audit found no way for a receiver to tell a shorter group from a truncated one. +- Point the vacuous `compile_fail` doctest at the real private constructor. + +The epoch section in `drafts/draft-lcurley-moq-e2ee.md` already states the rule; link it from the TypeScript docs rather than restating it. + +Public API: the TypeScript entrypoint stops exporting the concrete generation class. Wire: none. + +## Related + +- [Encrypted browser components](/quest/m2/e2ee/browser.md) - the consumer that must not reintroduce the concrete class +- [E2EE interop](/quest/m2/e2ee/interop.md) - the cross-language proof these fixes join diff --git a/quest/m2/image-hardening.md b/quest/m2/image-hardening.md new file mode 100644 index 00000000000..080d5b18704 --- /dev/null +++ b/quest/m2/image-hardening.md @@ -0,0 +1,23 @@ +# [XS] The relay image runs unprivileged and builds reproducibly + +## Goal + +The published container image runs as a non-root user, and its builder stage is pinned so the same source produces the same image. + +Today the final stage is `FROM scratch` with no `USER`, so the relay runs as uid 0, and the builder is `docker.io/nixos/nix:latest`. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Add a dedicated non-root user and `USER` to the final stage. The binary needs no privileged port at runtime; the documented deployments bind 443 inside a network namespace that maps it. +- Pin the builder image by digest, with the version named in a comment so a bump is a one-line diff. +- Leave release signing out of scope. The installer still trusts TLS and a same-origin checksum; changing that needs its own decision about a signing key and who holds it. + +Tests: the image builds and the entrypoint runs as the unprivileged user. + +Public API: none. Wire: none. + +## Related + +- [Release execution](/quest/m2/release/README.md) - the image publish path this changes diff --git a/quest/m2/msf-duplicate-init.md b/quest/m2/msf-duplicate-init.md new file mode 100644 index 00000000000..0d1f4662192 --- /dev/null +++ b/quest/m2/msf-duplicate-init.md @@ -0,0 +1,20 @@ +# [XS] An MSF catalog refuses duplicate init data ids + +## Goal + +An MSF catalog that repeats an `initDataList` id is refused with a typed error, instead of resolving to whichever entry comes last. + +Today `rs/moq-msf/src/lib.rs` collects the list into a `HashMap`, so a repeated id silently replaces the earlier entry. The strict duplicate-key pass used for `moq-json` catalogs does not cover this path. Two readers that keep different entries hand different decoder initialization bytes to different parties for the same broadcast. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Reject a duplicate id while building `by_id`, reusing the duplicate detection the hang catalog already has. +- Cover the malformed catalog with the example from the audit: two entries named `v` with different `data`, and a track that names `v`. + +Public API: one new error variant on the existing `#[non_exhaustive]` error. Wire: none. + +## Related + +- [strict JSON](/quest/m1/compress/README.md) - the duplicate-key rule this extends to the MSF path diff --git a/quest/m2/rtmp-amf0-exact-reads.md b/quest/m2/rtmp-amf0-exact-reads.md new file mode 100644 index 00000000000..1c5be8fe00e --- /dev/null +++ b/quest/m2/rtmp-amf0-exact-reads.md @@ -0,0 +1,18 @@ +# [XS] AMF0 reads exactly what it declared + +## Goal + +A truncated AMF0 string or property name fails with `UnexpectedEof`, instead of succeeding with NUL padding. + +Today `rs/moq-rtmp/src/rml/amf0/deserialization.rs` allocates the declared length and calls `bytes.read(&mut buffer)`, ignoring the returned count. `Read` for a byte slice returns a short read at EOF, so the zero fill is parsed as content. A publish stream key or object property can silently carry embedded NULs, and two RTMP implementations disagree about what the frame said. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Use `read_exact` at both sites. +- Test the audit's payload: string marker, declared length 16, one byte present, which must error rather than yield a padded value. + +The RTMP listener is unauthenticated by design, so this is reachable by anyone who can reach the port. + +Public API: none. Wire: none. diff --git a/quest/m2/wire-fuzz-coverage.md b/quest/m2/wire-fuzz-coverage.md new file mode 100644 index 00000000000..d30c4a91346 --- /dev/null +++ b/quest/m2/wire-fuzz-coverage.md @@ -0,0 +1,32 @@ +# [S] Every peer-facing decoder has a fuzz target that asserts an invariant + +## Goal + +Each decoder that consumes peer bytes is fuzzed with an assertion stronger than "it did not panic", and the hand-written unsafe that peer input reaches runs under Miri or a target of its own. + +Today `rs/moq-net/fuzz` covers lite, IETF messages, announces, varint, path, and pattern. The gaps the audit found: + +- The IETF SETUP decoder has no arm in `ietf_wire`. The old `draft*-setup-*` regression inputs now replay through the `Parameters` kind, so the u16 size, delta-encoded KVP block, and `decode_params!` path is uncovered. +- The incremental frame and group ingest (`lite::subscriber::FrameIngest`, `ietf::subscriber::GroupIngest`/`SubgroupRecv`, the `lite::ietf` state/object/property decoders) has no target. +- Request-stream framing (`Body`, `Framed`, `FollowUp`, `Next`, `whole_message`) is only unit-tested. +- Every seed body is six bytes or less, so no length-prefix or count rejection path is exercised near its cap. +- `rs/moq-c`, `rs/moq-uring`, and `rs/moq-sock` have no fuzz target and no Miri run, though `cmsg` walking and the io_uring address parsing are exactly where a bounded-buffer mistake would live. + +## Plan + +Decided 2026-10-22 from the security audit, with the maintainer: + +- Add the SETUP kinds to `ietf_wire` and restore the regression inputs through them. +- Add one target for a stream of frame headers, records, and payloads through the incremental ingest, asserting the declared sizes and the stream position stay consistent. +- Add seeds that approach a limit (`0xffff` and 64 MiB prefixes) so the rejection paths run. +- Add a Miri job for the crates whose unsafe is reachable from a peer, and a target for `moq-sock`'s cmsg walk and `moq-uring`'s `RecvMeta::parse`. +- Wire every target and the Miri run into the nightly gate, and keep the merge-gate replay of committed regressions. + +The point is the invariant, not the coverage number: a target that only checks for a panic would miss the bugs this audit is about. + +Public API: none. Wire: none. + +## Related + +- [moq-net internals](/quest/m1/net-internals.md) - the session drivers these targets exercise +- [CI cost and latency](/quest/m0/ci/README.md) - where the nightly budget lives From 96f5818050ce6cea49215434378d4f67bcf2b1c3 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 11:30:40 -0700 Subject: [PATCH 02/13] quest: fold review findings into the security audit quests HLS import holds redirects to the origin rule, the C defaults take a caller-sized out-parameter, HTTP admission backpressures instead of answering 503, and the auth redirect policy moves to the release audit's existing quest. Co-Authored-By: Claude Opus 5.5 --- quest/m0/hls-import-origin.md | 9 ++++++--- quest/m1/README.md | 2 +- quest/m1/auth-contract.md | 9 ++++----- quest/m1/c/abi-version.md | 9 +++++---- quest/m1/peer-count-bounds.md | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/quest/m0/hls-import-origin.md b/quest/m0/hls-import-origin.md index d11de578316..06f3468aafc 100644 --- a/quest/m0/hls-import-origin.md +++ b/quest/m0/hls-import-origin.md @@ -5,10 +5,11 @@ The HLS importer follows nothing a playlist names outside the origin it was configured with: - `resolve_uri` accepts a relative reference, or an absolute URL whose scheme and authority equal the playlist's. +- An HTTP redirect is held to the same rule before it is followed. - `file:` is read only when the playlist itself is a `file:` URL. - A variant's `RESOLUTION` multiplication cannot overflow. -Today `rs/moq-hls/src/import.rs` returns any absolute URL verbatim, and `Fetcher::fetch` opens `file:` paths and issues arbitrary GETs. A hostile or compromised playlist can therefore read local files and reach the operator's internal network, and `width * height` can panic on a debug build. +Today `rs/moq-hls/src/import.rs` returns any absolute URL verbatim, `Fetcher::fetch` opens `file:` paths and issues arbitrary GETs, and the reqwest client follows redirects by default. A hostile or compromised playlist can therefore read local files and reach the operator's internal network, and `width * height` can panic on a debug build. This code is on `release`, so the fix lands on `main` and is ported onto `release` as a separate PR that keeps the published API. @@ -17,12 +18,14 @@ This code is on `release`, so the fix lands on `main` and is ported onto `releas Decided 2026-10-22 from the security audit, with the maintainer: - Check scheme and authority in `resolve_uri`, not at each fetch site, so `EXT-X-MAP`, every segment, and future references share one rule. +- Apply that rule to every redirect hop too, either through the client's redirect policy or by following 3xx in the importer, so an open redirect on the origin cannot bounce a fetch elsewhere. +- A caller-supplied `Config::client` keeps its own redirect policy, which the importer cannot override per request. It has no in-repo consumer, so propose dropping it on `main` or narrowing it to what an authenticated origin needs (headers); the release port, which keeps the API, documents that the caller's client owns redirect handling. - Keep `file:` for a `file:` playlist, which is how local test fixtures work. - Compute the variant area with `saturating_mul`. -Tests: a playlist naming `file:///etc/passwd`, an instance-metadata address, and a cross-origin map and segment is refused; a relative segment still resolves; an enormous `RESOLUTION` does not panic. +Tests: a playlist naming `file:///etc/passwd`, an instance-metadata address, and a cross-origin map and segment is refused; a same-origin URL that redirects off-origin is refused; a relative segment still resolves; an enormous `RESOLUTION` does not panic. -Public API: none. Wire: none. +Public API: possibly `Config::client` on `main`, reported in the PR with a `MIGRATE.md` entry if it changes. Wire: none. ## Related diff --git a/quest/m1/README.md b/quest/m1/README.md index 2419f587b31..9ad7cd8e39d 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -120,7 +120,7 @@ lite-07 stream type here. - [Compile time audit](/quest/m1/audit-compile-time.md) - build-time hotspots are measured against the m0 baselines and the worst are fixed or planned - [Peer count bounds](/quest/m1/peer-count-bounds.md) - namespace interests, a legacy announce list, a WebSocket upgrade, and public HTTP admission are bounded by what the peer sent or by an existing budget - [Caption store bounds](/quest/m1/caption-store-bounds.md) - a hostile caption track cannot grow a viewer's cue and region store or its per-frame work without bound -- [Auth contract](/quest/m1/auth-contract.md) - the auth server receives the real SNI, a certificate grants nothing alone, and the auth client refuses a redirect that would replay a credential +- [Auth contract](/quest/m1/auth-contract.md) - the auth server receives the real SNI, and a certificate grants nothing alone - [Performance audit](/quest/m1/audit-perf.md) - benchmarks that regressed since the m0 run are explained, fixed, or planned, and unbenched hot paths get coverage ## Related diff --git a/quest/m1/auth-contract.md b/quest/m1/auth-contract.md index bbc86cd8ac0..27fe948a915 100644 --- a/quest/m1/auth-contract.md +++ b/quest/m1/auth-contract.md @@ -6,7 +6,6 @@ The auth server decides from facts the client cannot choose: - `moq_auth::Request::server_name` is the TLS SNI on every transport, as its contract says, not the client's `Host` or `:authority`. - A verified client certificate stays a fact unless the auth server's grant says `peer`; it never reveals hidden routes on its own. -- The auth HTTP client cannot be redirected to another host with the session request in its body. Today `admit_http` fills `server_name` from `request_host(uri, headers)`, and the WebSocket bridge builds its URL from the same header. A client can therefore tell a hostname-scoped auth server it dialed a tenant it never dialed. `cluster_peer` also treats any certificate as a peer for hidden-route discovery. @@ -16,14 +15,14 @@ Decided 2026-10-22 from the security audit, with the maintainer: - Add `server_name()` to the `HttpStream` trait and return `TlsStream::get_ref().1.server_name()`; use it in `admit_http` and in the WebSocket session's link. Fall back to `Host` only on the plain-HTTP listener, and say so in the doc. - Derive hidden-route visibility from the grant's `peer` flag, not `request.tls.is_some()`. Until peers set it, document the exemption where operators read it. -- Set `reqwest::redirect::Policy::none()` in `moq_auth::Client`, and bound the reply body. A 307/308 currently replays the credential-bearing request to wherever the auth server points. +- Bound the `moq_auth::Client` reply body. - Update `doc/bin/relay/auth.md` so `server_name`, `peer`, and the certificate-is-a-fact rule match what the code does. -Tests: an HTTP/1.1 request with a forged `Host` still reports the SNI; the same over WebSocket; a redirect answer is refused; a certificate-only session sees no hidden routes. +Tests: an HTTP/1.1 request with a forged `Host` still reports the SNI; the same over WebSocket; a certificate-only session sees no hidden routes. -Public API: one method on an internal trait, and a redirect policy. Wire: none. +Public API: one method on an internal trait. Wire: none. ## Related - [In-band auth](/quest/m1/auth/README.md) - the request and grant contract this corrects -- [Focused release backports](/quest/m0/release-backports/README.md) - the auth client is shared with `release`, so check whether the redirect policy is a backport candidate +- [Auth credential redirects](/quest/m1/release-audit/auth-redirects.md) - owns the auth client's redirect policy diff --git a/quest/m1/c/abi-version.md b/quest/m1/c/abi-version.md index 0032ebf8055..9b4c45739cc 100644 --- a/quest/m1/c/abi-version.md +++ b/quest/m1/c/abi-version.md @@ -5,24 +5,25 @@ A program built against an older `moq.h` cannot have its config struct overflowed by a newer library, and an early failure is documented as having no handle and no callback: - Each `#[repr(C)]` config struct carries its own size, set by the caller, and the library refuses a size it does not know. -- `moq_client_defaults()` cannot write a larger struct into an older caller's slot. +- `moq_client_defaults` fills a caller-owned struct up to the caller's size, rather than returning one by value. - `moq_session_connect` and every other `on_status` registration say that a negative return means no handle and no callback, so the caller owns `user_data`. - A spawned callback's cleanup cannot be lost to a poisoned mutex. -Today the config structs have no size field, `moq_client_defaults()` returns by value, and `moq_session_connect` says to call close even on error. The bandwidth change wait calls `callback.call` outside `ffi::run`, so a panic there drops the terminal callback silently. +Today the config structs have no size field, `moq_client_defaults()` returns its struct by value, and `moq_session_connect` says to call close even on error. The bandwidth change wait calls `callback.call` outside `ffi::run`, so a panic there drops the terminal callback silently. ## Plan Decided 2026-10-22 from the security audit, with the maintainer: - Add a leading `size` field to `moq_client_config` and the other config structs, and a `moq_abi_version()` for diagnostics. Zero is refused, so a caller that forgets the field fails loudly rather than reading uninitialized fields. +- Change `moq_client_defaults()` to take a pointer to the caller's struct and return a status. A by-value return of a struct that grows changes the return slot, and possibly the calling convention, before either side can read `size`, so the field alone does not protect it. - Fix the "adding a field does not disturb existing callers" comment: it is true only when both sides agree on the size. - Document the immediate-failure contract on every registration that returns a handle. - Move the spawned cleanup inside `ffi::run`, or match `state.rs`'s `PoisonError::into_inner`. -Tests: a zero size is refused; a short size is refused; the documented failure paths fire no callback. +Tests: a zero size is refused; a short size is refused; defaults written for an older size touch no byte past it; the documented failure paths fire no callback. -Public API: additive fields and one function. Wire: none. +Public API: additive fields, one function, and a breaking `moq_client_defaults` signature with a `MIGRATE.md` entry; `cpp/moq` and the Dart bindings follow. Wire: none. ## Related diff --git a/quest/m1/peer-count-bounds.md b/quest/m1/peer-count-bounds.md index 90b594ba3b8..ff44d5f8c92 100644 --- a/quest/m1/peer-count-bounds.md +++ b/quest/m1/peer-count-bounds.md @@ -19,7 +19,7 @@ Decided 2026-10-22 from the security audit, with the maintainer: - A namespace interest takes its `announces` permit before the decision, as moq-lite already does, and releases it only when the stream ends. A reflected or refused namespace therefore holds the same permit every other announce does. - `ANNOUNCE_INIT` is a legacy lite-01/02 message. Make its decoder take the session's announce budget, or otherwise bound the count by the body and that budget, so the existing resource limit is the bound rather than a new constant. - The WebSocket socket caps message and frame size at qmux's own `max_record_size`, from one shared constant, since qmux carries one record per message. -- `admit_http` takes a semaphore permit, and the h2 listener sets `max_concurrent_streams`. Over the limit answers 503 instead of queueing, which is backpressure rather than a refusal of valid input. +- Bound admission with backpressure, not load shedding: the h2 listener sets `max_concurrent_streams`, and any global bound on in-flight admissions stops accepting or polling new work while full rather than answering 503. A valid request in an ordinary burst waits; it is never refused by a threshold, and what it holds while waiting stays within the connection and stream bounds. Each fix lands with a regression test that fails on main. The admission fan-out gets a benchmark swept over connections and streams, per the fan-out rule. From 703a97c43bf888a067952c8bcc72b339491a1f65 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 11:32:04 -0700 Subject: [PATCH 03/13] quest: fold HLS import origin into the release audit pointer One public quest owns the HLS resource boundary. The release audit's pointer gains the origin rule, redirect hops, file: scope, and the Config::client caveat, without reproduction details. Co-Authored-By: Claude Opus 5.5 --- quest/m0/README.md | 1 - quest/m0/hls-import-origin.md | 33 ------------------------- quest/m1/release-audit/hls-admission.md | 14 +++++++++++ 3 files changed, 14 insertions(+), 34 deletions(-) delete mode 100644 quest/m0/hls-import-origin.md diff --git a/quest/m0/README.md b/quest/m0/README.md index 4e9a3e55c70..0417e3de2bd 100644 --- a/quest/m0/README.md +++ b/quest/m0/README.md @@ -51,4 +51,3 @@ Each lands its fixes in its own PR and plans only what needs a decision. - [Simplification audit](/quest/m0/audit-simplify.md) - overbuilt code and APIs are collapsed, merged, or narrowed into a net simpler whole - [Lint override and deprecation audit](/quest/m0/audit-lints.md) - every lint suppression is still needed and says why, nothing calls a deprecated API, and stale Rust overrides fail the build - [Interop audit](/quest/m0/audit-interop.md) - our interop runner entries match what we ship, and every red interop cell with a moq.dev side is fixed, reported, or noted as down -- [HLS import origin](/quest/m0/hls-import-origin.md) - a playlist cannot make the importer read a local file or reach another origin, on `main` or the current release diff --git a/quest/m0/hls-import-origin.md b/quest/m0/hls-import-origin.md deleted file mode 100644 index 06f3468aafc..00000000000 --- a/quest/m0/hls-import-origin.md +++ /dev/null @@ -1,33 +0,0 @@ -# [S] HLS import trusts only its playlist's origin - -## Goal - -The HLS importer follows nothing a playlist names outside the origin it was configured with: - -- `resolve_uri` accepts a relative reference, or an absolute URL whose scheme and authority equal the playlist's. -- An HTTP redirect is held to the same rule before it is followed. -- `file:` is read only when the playlist itself is a `file:` URL. -- A variant's `RESOLUTION` multiplication cannot overflow. - -Today `rs/moq-hls/src/import.rs` returns any absolute URL verbatim, `Fetcher::fetch` opens `file:` paths and issues arbitrary GETs, and the reqwest client follows redirects by default. A hostile or compromised playlist can therefore read local files and reach the operator's internal network, and `width * height` can panic on a debug build. - -This code is on `release`, so the fix lands on `main` and is ported onto `release` as a separate PR that keeps the published API. - -## Plan - -Decided 2026-10-22 from the security audit, with the maintainer: - -- Check scheme and authority in `resolve_uri`, not at each fetch site, so `EXT-X-MAP`, every segment, and future references share one rule. -- Apply that rule to every redirect hop too, either through the client's redirect policy or by following 3xx in the importer, so an open redirect on the origin cannot bounce a fetch elsewhere. -- A caller-supplied `Config::client` keeps its own redirect policy, which the importer cannot override per request. It has no in-repo consumer, so propose dropping it on `main` or narrowing it to what an authenticated origin needs (headers); the release port, which keeps the API, documents that the caller's client owns redirect handling. -- Keep `file:` for a `file:` playlist, which is how local test fixtures work. -- Compute the variant area with `saturating_mul`. - -Tests: a playlist naming `file:///etc/passwd`, an instance-metadata address, and a cross-origin map and segment is refused; a same-origin URL that redirects off-origin is refused; a relative segment still resolves; an enormous `RESOLUTION` does not panic. - -Public API: possibly `Config::client` on `main`, reported in the PR with a `MIGRATE.md` entry if it changes. Wire: none. - -## Related - -- [Focused release backports](/quest/m0/release-backports/README.md) - the release port joins this shortlist once the main fix lands -- [MKV dimension overflow](/quest/m2/mkv-dimension-overflow.md) - the same class of catalogue-field overflow in another importer diff --git a/quest/m1/release-audit/hls-admission.md b/quest/m1/release-audit/hls-admission.md index 8ec7bfcff78..5c4d999590f 100644 --- a/quest/m1/release-audit/hls-admission.md +++ b/quest/m1/release-audit/hls-admission.md @@ -15,3 +15,17 @@ This public quest is deliberately a brief pointer at the maintainer's request; it does not include sensitive reproduction details or claim a demonstrated exploit. Report any caller-visible policy or API change and consider a release backport after validation. + +Planning settled from the 2026-10-22 security audit: + +- Absolute references resolve only when their scheme and authority equal + the playlist's, checked once where references resolve so every resource + kind shares the rule. +- Every redirect hop is held to the same rule before it is followed. +- `file:` resources are read only when the playlist itself is a `file:` URL, + which keeps local fixtures working. +- A caller-supplied `Config::client` keeps its own redirect policy, which the + importer cannot override per request. It has no in-repo consumer, so + propose dropping or narrowing it on `main` (a `MIGRATE.md` entry if it + changes); a release port that keeps the API documents that the caller's + client owns redirect handling. From 21d0dd48523e03a9e82d5756c46035aad10fe85a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 11:38:50 -0700 Subject: [PATCH 04/13] quest: fold the second review round into the audit quests The C ABI break gets a versioned SONAME, plain HTTP reports no SNI, TS programs are created only for described PMTs, E2EE AEAD budgets are shared per key, and the HLS variant-area overflow gets its own quest. Co-Authored-By: Claude Opus 5.5 --- quest/m1/auth-contract.md | 2 +- quest/m1/c/abi-version.md | 3 ++- quest/m1/ts-reliability/program-cap.md | 9 +++++---- quest/m2/README.md | 1 + quest/m2/e2ee/lifecycle-hardening.md | 4 ++-- quest/m2/hls-variant-area.md | 18 ++++++++++++++++++ 6 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 quest/m2/hls-variant-area.md diff --git a/quest/m1/auth-contract.md b/quest/m1/auth-contract.md index 27fe948a915..bf9a1cec38e 100644 --- a/quest/m1/auth-contract.md +++ b/quest/m1/auth-contract.md @@ -13,7 +13,7 @@ Today `admit_http` fills `server_name` from `request_host(uri, headers)`, and th Decided 2026-10-22 from the security audit, with the maintainer: -- Add `server_name()` to the `HttpStream` trait and return `TlsStream::get_ref().1.server_name()`; use it in `admit_http` and in the WebSocket session's link. Fall back to `Host` only on the plain-HTTP listener, and say so in the doc. +- Add `server_name()` to the `HttpStream` trait and return `TlsStream::get_ref().1.server_name()`; use it in `admit_http` and in the WebSocket session's link. On the plain-HTTP listener leave `server_name` absent rather than filling it from `Host`, since the auth request has no field that would tell an auth server the value is client-chosen; say so in the doc. - Derive hidden-route visibility from the grant's `peer` flag, not `request.tls.is_some()`. Until peers set it, document the exemption where operators read it. - Bound the `moq_auth::Client` reply body. - Update `doc/bin/relay/auth.md` so `server_name`, `peer`, and the certificate-is-a-fact rule match what the code does. diff --git a/quest/m1/c/abi-version.md b/quest/m1/c/abi-version.md index 9b4c45739cc..b3bc7204caf 100644 --- a/quest/m1/c/abi-version.md +++ b/quest/m1/c/abi-version.md @@ -17,13 +17,14 @@ Decided 2026-10-22 from the security audit, with the maintainer: - Add a leading `size` field to `moq_client_config` and the other config structs, and a `moq_abi_version()` for diagnostics. Zero is refused, so a caller that forgets the field fails loudly rather than reading uninitialized fields. - Change `moq_client_defaults()` to take a pointer to the caller's struct and return a status. A by-value return of a struct that grows changes the return slot, and possibly the calling convention, before either side can read `size`, so the field alone does not protect it. +- These are themselves ABI breaks for an already-compiled caller, which a migration note cannot reach: an old binary would call the new `moq_client_defaults` with the old convention and pass structs without the leading field. Give the shared library a SONAME (and macOS install name) that changes with each breaking release, so an old binary fails to load instead of miscalling. - Fix the "adding a field does not disturb existing callers" comment: it is true only when both sides agree on the size. - Document the immediate-failure contract on every registration that returns a handle. - Move the spawned cleanup inside `ffi::run`, or match `state.rs`'s `PoisonError::into_inner`. Tests: a zero size is refused; a short size is refused; defaults written for an older size touch no byte past it; the documented failure paths fire no callback. -Public API: additive fields, one function, and a breaking `moq_client_defaults` signature with a `MIGRATE.md` entry; `cpp/moq` and the Dart bindings follow. Wire: none. +Public API: a breaking ABI (the leading field and the `moq_client_defaults` signature) with a `MIGRATE.md` entry, one new function, and a versioned SONAME; `cpp/moq` and the Dart bindings follow. Wire: none. ## Related diff --git a/quest/m1/ts-reliability/program-cap.md b/quest/m1/ts-reliability/program-cap.md index 48c3be70062..e9cf5632b6b 100644 --- a/quest/m1/ts-reliability/program-cap.md +++ b/quest/m1/ts-reliability/program-cap.md @@ -2,7 +2,7 @@ ## Goal -`moq import ts --program all` creates a broadcast per PAT program only up to a bound the run already has, instead of one per `u16` a hostile multiplex can name. +`moq import ts --program all` creates a broadcast only for a program the input actually describes, instead of one per program number a hostile PAT names. Today `rs/moq-mux/src/container/ts/programs.rs` loops over every `pat.program_numbers()` and creates a broadcast, catalog producer, importer, and consumer for each. A sub-megabyte transport stream can list all 65,536 program numbers across PAT sections, so one input creates tens of thousands of live broadcasts. @@ -10,9 +10,10 @@ Today `rs/moq-mux/src/container/ts/programs.rs` loops over every `pat.program_nu Decided 2026-10-22 from the security audit, with the maintainer: -- Bound the program count by the origin's announce budget, or by an operator-selected program list, rather than a new arbitrary constant. `--program all` is opt-in; the default already refuses multi-program input. -- Fail the import with the existing multi-program error shape, naming the count and the bound. -- Test with a synthesized PAT naming far more programs than a real multiplex. +- Create a program's broadcast only once its PMT declares a supported stream, so the state scales with the PMT bytes the input carried, not with the PAT's list. The session's announce budget (100,000 by default, above the `u16` domain) does not bind on its own; it stays the bound a TS input shares with any publisher, and an operator-selected program list narrows it. `--program all` is opt-in; the default already refuses multi-program input. +- No new program-count constant: a cap below the PAT's domain would only refuse valid multiplexes. +- When the announce budget refuses a program, fail the import with the existing multi-program error shape, naming the count and the bound. +- Test with a synthesized PAT naming far more programs than it carries PMTs for, and assert only the described programs exist. Public API: one new error case. Wire: none. diff --git a/quest/m2/README.md b/quest/m2/README.md index 55cef912b13..32db26c5e2d 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -105,6 +105,7 @@ ranked just below deterministic TS legs, which it requires. - [WebGPU HDR](/quest/m2/webgpu-hdr.md) - HDR renditions play as HDR where the browser and display can show it, and tone-map to SDR elsewhere - [MSF duplicate init](/quest/m2/msf-duplicate-init.md) - an MSF catalog refuses a repeated `initDataList` id instead of resolving it last-wins - [AMF0 exact reads](/quest/m2/rtmp-amf0-exact-reads.md) - a truncated RTMP string fails with `UnexpectedEof` instead of parsing NUL padding +- [HLS variant area](/quest/m2/hls-variant-area.md) - a hostile `RESOLUTION` cannot panic or misorder variant ranking - [Image hardening](/quest/m2/image-hardening.md) - the relay image runs unprivileged and its builder stage is pinned - [Wire fuzz coverage](/quest/m2/wire-fuzz-coverage.md) - every peer-facing decoder has a target that asserts an invariant, and the unsafe peer input reaches runs under Miri - [One port](/quest/m2/one-port/README.md) - one UDP port carries QUIC, SRT, and WebRTC media through an embedder hook, and one TCP port carries HTTP, RTMP, and RTMPS diff --git a/quest/m2/e2ee/lifecycle-hardening.md b/quest/m2/e2ee/lifecycle-hardening.md index e8cff2a2609..fb5361d67a7 100644 --- a/quest/m2/e2ee/lifecycle-hardening.md +++ b/quest/m2/e2ee/lifecycle-hardening.md @@ -7,7 +7,7 @@ The rules the [E2EE epic](/quest/m2/e2ee/README.md) already decided hold in ever - A producing generation can only be opened under an epoch it minted, so two producers can never share an epoch and repeat an AES-GCM nonce. - A grouped write that fails after encryption ends the group, because the transport's frame index can no longer line up with the nonce. - A datagram whose wire identity is out of range is dropped with the bad-datagram event, not thrown as a fatal error. -- The AEAD operation and byte budgets are per key, or the per-subscription receiver reset is documented. +- The AEAD operation and byte budgets are per key, shared by every consumer of that key. - The draft states what a relay can truncate inside a group, so an application never mistakes a short group for a complete one. The Rust core already keeps the epoch unrepresentable outside the crate. The TypeScript package exports the concrete `Generation.Producer` through `export * as Generation`, and `Producer.make` is a public static that ships in the types. An app that persists an epoch and calls it twice gets two producers with independent claims, both starting at group 0 and frame 0 under the same key. The Rust grouped writer also leaves a group open after a post-encryption `write_frame` error, while the TS twin aborts. @@ -19,7 +19,7 @@ Decided 2026-10-22 from the security audit, with the maintainer: - Keep the typed generation shape in the runtime but stop exporting the concrete class: export a `Producer`/`Consumer` interface, or gate `make` behind a module-private capability from `internal.ts`. A test asserts the package surface cannot mint a producer for a fixed epoch. - Abort the Rust group on any `inner.write_frame` error, matching `js/e2ee/src/group.ts`, and add the Rust twin of the TS test. - Map an out-of-range sequence or an oversize payload to the dropped-datagram event in both languages, with a `2^53` sequence test in each suite. -- Scope the AEAD counters to the `(generation, physical name, domain)` tuple in the owning consumer, or state the per-subscription receiver cap in the draft's limits. +- Share the AEAD counters across every consumer of a `(generation, physical name, domain)` key, so resubscribing cannot reset a key's failed-open or byte budget. Documenting a per-subscription reset is not an alternative: the same key is derived again, so the bound must be too. - State the mid-group truncation limit in the draft's security considerations, or add an authenticated terminal object if group atomicity is meant to be a guarantee. The audit found no way for a receiver to tell a shorter group from a truncated one. - Point the vacuous `compile_fail` doctest at the real private constructor. diff --git a/quest/m2/hls-variant-area.md b/quest/m2/hls-variant-area.md new file mode 100644 index 00000000000..e2bfea18278 --- /dev/null +++ b/quest/m2/hls-variant-area.md @@ -0,0 +1,18 @@ +# [XS] HLS variant ranking cannot overflow on a hostile resolution + +## Goal + +Ranking a master playlist's variants by `RESOLUTION` cannot panic or wrap, whatever dimensions the playlist declares. + +Today `select_variants` in `rs/moq-hls/src/import.rs` computes `width * height` on playlist-supplied values, which panics on a checked build and wraps on a release build, misordering the variants. + +## Plan + +From the 2026-10-22 security audit. Compute the area without overflow (saturating or widened arithmetic), so an absurd resolution ranks as the largest rather than an arbitrary one. A test with an enormous `RESOLUTION` covers both the panic and the ordering. + +Public API: none. Wire: none. + +## Related + +- [MKV import refuses out-of-range values](/quest/m2/mkv-dimension-overflow.md) - the same class of catalogue-field overflow in another importer +- [HLS admission](/quest/m1/release-audit/hls-admission.md) - the other HLS import hardening from the audit From 65d8252f835b9f79c550836c31630aa72974d927 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 11:45:19 -0700 Subject: [PATCH 05/13] quest: caption cues merge sorted payloads; MSF duplicates use serde errors Co-Authored-By: Claude Opus 5.5 --- quest/m1/caption-store-bounds.md | 2 +- quest/m2/msf-duplicate-init.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/quest/m1/caption-store-bounds.md b/quest/m1/caption-store-bounds.md index b579270f17c..79831d8a79a 100644 --- a/quest/m1/caption-store-bounds.md +++ b/quest/m1/caption-store-bounds.md @@ -17,7 +17,7 @@ Decided 2026-10-22 from the security audit, with the maintainer: - Clamp a cue's end to its start plus a maximum cue duration, and drop cues behind the existing `PRUNE_BEHIND` horizon. - Prune regions that no retained cue references in the same sweep, and cap both maps, evicting oldest first. Neither cap refuses a payload; they bound what the viewer retains. -- Insert by binary search, or sort once per payload, instead of the backward walk plus splice. +- Sort each payload once and merge it into the store, instead of the backward walk plus splice. A per-cue binary search still splices, so it stays quadratic. - Keep the double-escaped `sanitizeCue` and its renderer-version test unchanged: the audit confirmed the pinned `media-captions` builds only double-quoted attributes, so the current escape set is sufficient. Tests cover a future-dated cue stream, a fresh region per frame, and a descending 100k-cue payload, each asserting the bounded store and the same rendered text. diff --git a/quest/m2/msf-duplicate-init.md b/quest/m2/msf-duplicate-init.md index 0d1f4662192..69eeb39691c 100644 --- a/quest/m2/msf-duplicate-init.md +++ b/quest/m2/msf-duplicate-init.md @@ -2,7 +2,7 @@ ## Goal -An MSF catalog that repeats an `initDataList` id is refused with a typed error, instead of resolving to whichever entry comes last. +An MSF catalog that repeats an `initDataList` id is refused as a deserialization error, instead of resolving to whichever entry comes last. Today `rs/moq-msf/src/lib.rs` collects the list into a `HashMap`, so a repeated id silently replaces the earlier entry. The strict duplicate-key pass used for `moq-json` catalogs does not cover this path. Two readers that keep different entries hand different decoder initialization bytes to different parties for the same broadcast. @@ -10,10 +10,10 @@ Today `rs/moq-msf/src/lib.rs` collects the list into a `HashMap`, so a repeated Decided 2026-10-22 from the security audit, with the maintainer: -- Reject a duplicate id while building `by_id`, reusing the duplicate detection the hang catalog already has. +- Reject a duplicate id while building `by_id` with `serde::de::Error::custom`, the path the catalog's other semantic checks already use. - Cover the malformed catalog with the example from the audit: two entries named `v` with different `data`, and a track that names `v`. -Public API: one new error variant on the existing `#[non_exhaustive]` error. Wire: none. +Public API: none. Wire: none. ## Related From 247db64b9e9113792b64ea6ad69728ce6bb1ace5 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 11:46:20 -0700 Subject: [PATCH 06/13] quest: retarget the C ABI quest at the generated async failure contract The hand-written ABI is being replaced, so the struct size, defaults out-parameter, and SONAME work is dropped. What remains is the early failure and terminal callback contract for generated async calls. Co-Authored-By: Claude Opus 5.5 --- quest/m1/c/README.md | 2 +- quest/m1/c/abi-version.md | 31 ---------------------------- quest/m1/c/async-failure-contract.md | 25 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 quest/m1/c/abi-version.md create mode 100644 quest/m1/c/async-failure-contract.md diff --git a/quest/m1/c/README.md b/quest/m1/c/README.md index 627a156dbe9..7c93368226d 100644 --- a/quest/m1/c/README.md +++ b/quest/m1/c/README.md @@ -66,4 +66,4 @@ requests internally and keeps its ABI, so that quest does not wait here. - [moq-c package](/quest/m1/c/package.md) - the generated header ships as `moq-c` 0.8.0 with `moq::c`, pkg-config, and a release workflow - [C consumers](/quest/m1/c/consumers.md) - the C interop client and `doc/lib/c` samples move onto the generated API -- [ABI version](/quest/m1/c/abi-version.md) - a C caller cannot be laid out against a newer library, and an early failure is documented as having no handle and no callback +- [Async failure contract](/quest/m1/c/async-failure-contract.md) - a generated async call that fails early fires no callback, and one that started always delivers its terminal callback diff --git a/quest/m1/c/abi-version.md b/quest/m1/c/abi-version.md deleted file mode 100644 index b3bc7204caf..00000000000 --- a/quest/m1/c/abi-version.md +++ /dev/null @@ -1,31 +0,0 @@ -# [S] A C caller cannot be laid out against a newer library - -## Goal - -A program built against an older `moq.h` cannot have its config struct overflowed by a newer library, and an early failure is documented as having no handle and no callback: - -- Each `#[repr(C)]` config struct carries its own size, set by the caller, and the library refuses a size it does not know. -- `moq_client_defaults` fills a caller-owned struct up to the caller's size, rather than returning one by value. -- `moq_session_connect` and every other `on_status` registration say that a negative return means no handle and no callback, so the caller owns `user_data`. -- A spawned callback's cleanup cannot be lost to a poisoned mutex. - -Today the config structs have no size field, `moq_client_defaults()` returns its struct by value, and `moq_session_connect` says to call close even on error. The bandwidth change wait calls `callback.call` outside `ffi::run`, so a panic there drops the terminal callback silently. - -## Plan - -Decided 2026-10-22 from the security audit, with the maintainer: - -- Add a leading `size` field to `moq_client_config` and the other config structs, and a `moq_abi_version()` for diagnostics. Zero is refused, so a caller that forgets the field fails loudly rather than reading uninitialized fields. -- Change `moq_client_defaults()` to take a pointer to the caller's struct and return a status. A by-value return of a struct that grows changes the return slot, and possibly the calling convention, before either side can read `size`, so the field alone does not protect it. -- These are themselves ABI breaks for an already-compiled caller, which a migration note cannot reach: an old binary would call the new `moq_client_defaults` with the old convention and pass structs without the leading field. Give the shared library a SONAME (and macOS install name) that changes with each breaking release, so an old binary fails to load instead of miscalling. -- Fix the "adding a field does not disturb existing callers" comment: it is true only when both sides agree on the size. -- Document the immediate-failure contract on every registration that returns a handle. -- Move the spawned cleanup inside `ffi::run`, or match `state.rs`'s `PoisonError::into_inner`. - -Tests: a zero size is refused; a short size is refused; defaults written for an older size touch no byte past it; the documented failure paths fire no callback. - -Public API: a breaking ABI (the leading field and the `moq_client_defaults` signature) with a `MIGRATE.md` entry, one new function, and a versioned SONAME; `cpp/moq` and the Dart bindings follow. Wire: none. - -## Related - -- [Generated C bindings](/quest/m1/c/README.md) - the ABI this hardens before more consumers adopt it diff --git a/quest/m1/c/async-failure-contract.md b/quest/m1/c/async-failure-contract.md new file mode 100644 index 00000000000..b0c329ebf63 --- /dev/null +++ b/quest/m1/c/async-failure-contract.md @@ -0,0 +1,25 @@ +# [XS] Generated C async calls state and keep their failure contract + +## Goal + +Every async call in the generated C API has a callback contract a C caller can rely on for freeing `user_data`: + +- A call that fails before returning a task returns no task and never invokes its callback, so the caller still owns `user_data`. +- A call that returned a task invokes its callback exactly once with a terminal result, even when the work panics or a lock it shares is poisoned. + +Today the hand-written `moq_session_connect` says to call close even on error, and its bandwidth wait calls `callback.call` outside `ffi::run`, so a panic there drops the terminal callback silently. The generated API replaces that ABI, so the contract belongs in the generator's async plumbing rather than in `rs/moq-c`. + +## Plan + +From the 2026-10-22 security audit: + +- Document the immediate-failure rule on each async callback typedef in the generated header, once in the generator rather than per function. +- Run the terminal callback through the same panic and poisoning handling as the rest of the call, so cleanup cannot be lost. + +Tests: a call refused before it starts fires no callback; a call whose work panics still delivers one terminal callback. + +Public API: header documentation and a guaranteed terminal callback. Wire: none. + +## Required + +- [moq-c package](/quest/m1/c/package.md) - the generated C API this contract applies to From 5a9cdaa6748102e2d961e085d891c5c6f14be22a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 11:52:27 -0700 Subject: [PATCH 07/13] quest: Fly listen port, E2EE accounting ownership, AMF0 property test Co-Authored-By: Claude Opus 5.5 --- quest/m2/e2ee/lifecycle-hardening.md | 7 ++++--- quest/m2/image-hardening.md | 5 +++-- quest/m2/rtmp-amf0-exact-reads.md | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/quest/m2/e2ee/lifecycle-hardening.md b/quest/m2/e2ee/lifecycle-hardening.md index fb5361d67a7..7cf7a2a7837 100644 --- a/quest/m2/e2ee/lifecycle-hardening.md +++ b/quest/m2/e2ee/lifecycle-hardening.md @@ -7,7 +7,7 @@ The rules the [E2EE epic](/quest/m2/e2ee/README.md) already decided hold in ever - A producing generation can only be opened under an epoch it minted, so two producers can never share an epoch and repeat an AES-GCM nonce. - A grouped write that fails after encryption ends the group, because the transport's frame index can no longer line up with the nonce. - A datagram whose wire identity is out of range is dropped with the bad-datagram event, not thrown as a fatal error. -- The AEAD operation and byte budgets are per key, shared by every consumer of that key. +- The AEAD operation and byte budgets are per key, shared by every consumer of that key, without retaining state for keys a relay can make the consumer derive. - The draft states what a relay can truncate inside a group, so an application never mistakes a short group for a complete one. The Rust core already keeps the epoch unrepresentable outside the crate. The TypeScript package exports the concrete `Generation.Producer` through `export * as Generation`, and `Producer.make` is a public static that ships in the types. An app that persists an epoch and calls it twice gets two producers with independent claims, both starting at group 0 and frame 0 under the same key. The Rust grouped writer also leaves a group open after a post-encryption `write_frame` error, while the TS twin aborts. @@ -20,12 +20,13 @@ Decided 2026-10-22 from the security audit, with the maintainer: - Abort the Rust group on any `inner.write_frame` error, matching `js/e2ee/src/group.ts`, and add the Rust twin of the TS test. - Map an out-of-range sequence or an oversize payload to the dropped-datagram event in both languages, with a `2^53` sequence test in each suite. - Share the AEAD counters across every consumer of a `(generation, physical name, domain)` key, so resubscribing cannot reset a key's failed-open or byte budget. Documenting a per-subscription reset is not an alternative: the same key is derived again, so the bound must be too. -- State the mid-group truncation limit in the draft's security considerations, or add an authenticated terminal object if group atomicity is meant to be a guarantee. The audit found no way for a receiver to tell a shorter group from a truncated one. +- Bound that shared state by ownership, not eviction: tie it to the generation handle the application holds, which owns the derived keys, and refuse to re-derive a key whose accounting was discarded rather than resetting it. Settle the exact retirement rule in the PR, since `Credential::consume` can be called for epochs and names a relay chooses. +- State the mid-group truncation limit in the draft's security considerations. The audit found no way for a receiver to tell a shorter group from a truncated one; an authenticated terminal object would be a wire change and its own quest if group atomicity is ever meant to be a guarantee. - Point the vacuous `compile_fail` doctest at the real private constructor. The epoch section in `drafts/draft-lcurley-moq-e2ee.md` already states the rule; link it from the TypeScript docs rather than restating it. -Public API: the TypeScript entrypoint stops exporting the concrete generation class. Wire: none. +Public API: the TypeScript entrypoint stops exporting the concrete generation class, a breaking change recorded under `## Unreleased` in a new `js/e2ee/MIGRATE.md` with the replacement interface or factory. Wire: none. ## Related diff --git a/quest/m2/image-hardening.md b/quest/m2/image-hardening.md index 080d5b18704..82f39d1eb60 100644 --- a/quest/m2/image-hardening.md +++ b/quest/m2/image-hardening.md @@ -10,11 +10,12 @@ Today the final stage is `FROM scratch` with no `USER`, so the relay runs as uid Decided 2026-10-22 from the security audit, with the maintainer: -- Add a dedicated non-root user and `USER` to the final stage. The binary needs no privileged port at runtime; the documented deployments bind 443 inside a network namespace that maps it. +- Add a dedicated non-root user and `USER` to the final stage. +- `rs/moq-relay/fly.toml` binds 443 directly (`MOQ_LISTEN` and `internal_port`), which an unprivileged process cannot. Prefer moving that deployment to an unprivileged internal port behind the same public 443, if Fly's UDP forwarding allows it; otherwise grant `CAP_NET_BIND_SERVICE` explicitly. - Pin the builder image by digest, with the version named in a comment so a bump is a one-line diff. - Leave release signing out of scope. The installer still trusts TLS and a same-origin checksum; changing that needs its own decision about a signing key and who holds it. -Tests: the image builds and the entrypoint runs as the unprivileged user. +Tests: the image builds, the entrypoint runs as the unprivileged user, and the Fly listen configuration starts under it. Public API: none. Wire: none. diff --git a/quest/m2/rtmp-amf0-exact-reads.md b/quest/m2/rtmp-amf0-exact-reads.md index 1c5be8fe00e..3278be4751a 100644 --- a/quest/m2/rtmp-amf0-exact-reads.md +++ b/quest/m2/rtmp-amf0-exact-reads.md @@ -11,7 +11,7 @@ Today `rs/moq-rtmp/src/rml/amf0/deserialization.rs` allocates the declared lengt Decided 2026-10-22 from the security audit, with the maintainer: - Use `read_exact` at both sites. -- Test the audit's payload: string marker, declared length 16, one byte present, which must error rather than yield a padded value. +- Test both sites: the audit's string payload (string marker, declared length 16, one byte present), and an object whose property name declares more bytes than remain. Each must error rather than yield a padded value. The RTMP listener is unauthenticated by design, so this is reachable by anyone who can reach the port. From c6f37b02dc29cb781ed5495a3c67623f7b354dfb Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 12:28:45 -0700 Subject: [PATCH 08/13] quest: WebTransport SNI fallbacks, TS programs without announce budget, C cancellation Co-Authored-By: Claude Opus 5.5 --- quest/m1/auth-contract.md | 3 ++- quest/m1/c/async-failure-contract.md | 5 +++-- quest/m1/ts-reliability/program-cap.md | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/quest/m1/auth-contract.md b/quest/m1/auth-contract.md index bf9a1cec38e..95cd7ab900d 100644 --- a/quest/m1/auth-contract.md +++ b/quest/m1/auth-contract.md @@ -14,11 +14,12 @@ Today `admit_http` fills `server_name` from `request_host(uri, headers)`, and th Decided 2026-10-22 from the security audit, with the maintainer: - Add `server_name()` to the `HttpStream` trait and return `TlsStream::get_ref().1.server_name()`; use it in `admit_http` and in the WebSocket session's link. On the plain-HTTP listener leave `server_name` absent rather than filling it from `Host`, since the auth request has no field that would tell an auth server the value is client-chosen; say so in the doc. +- Remove the same fallback from WebTransport on both listener stacks: `request_for` substitutes the request authority (`rs/moq-relay/src/auth.rs`) and the io_uring path the URL host (`rs/moq-relay/src/uring.rs`) when the client sent no SNI. - Derive hidden-route visibility from the grant's `peer` flag, not `request.tls.is_some()`. Until peers set it, document the exemption where operators read it. - Bound the `moq_auth::Client` reply body. - Update `doc/bin/relay/auth.md` so `server_name`, `peer`, and the certificate-is-a-fact rule match what the code does. -Tests: an HTTP/1.1 request with a forged `Host` still reports the SNI; the same over WebSocket; a certificate-only session sees no hidden routes. +Tests: an HTTP/1.1 request with a forged `Host` still reports the SNI; the same over WebSocket; a WebTransport session without SNI reports none on both stacks; a certificate-only session sees no hidden routes. Public API: one method on an internal trait. Wire: none. diff --git a/quest/m1/c/async-failure-contract.md b/quest/m1/c/async-failure-contract.md index b0c329ebf63..737f814aa08 100644 --- a/quest/m1/c/async-failure-contract.md +++ b/quest/m1/c/async-failure-contract.md @@ -5,7 +5,7 @@ Every async call in the generated C API has a callback contract a C caller can rely on for freeing `user_data`: - A call that fails before returning a task returns no task and never invokes its callback, so the caller still owns `user_data`. -- A call that returned a task invokes its callback exactly once with a terminal result, even when the work panics or a lock it shares is poisoned. +- A call that returned a task invokes its callback exactly once with a terminal result, even when the work panics, a lock it shares is poisoned, or the caller frees the task to cancel it. Today the hand-written `moq_session_connect` says to call close even on error, and its bandwidth wait calls `callback.call` outside `ffi::run`, so a panic there drops the terminal callback silently. The generated API replaces that ABI, so the contract belongs in the generator's async plumbing rather than in `rs/moq-c`. @@ -15,8 +15,9 @@ From the 2026-10-22 security audit: - Document the immediate-failure rule on each async callback typedef in the generated header, once in the generator rather than per function. - Run the terminal callback through the same panic and poisoning handling as the rest of the call, so cleanup cannot be lost. +- Make cancellation a terminal result: freeing a pending task delivers one cancelled callback, so the caller reclaims `user_data` in one place on every path. If the generator instead stops all callbacks once the free returns, document that ownership transfer explicitly; either way, settle it once for every async call. -Tests: a call refused before it starts fires no callback; a call whose work panics still delivers one terminal callback. +Tests: a call refused before it starts fires no callback; a call whose work panics still delivers one terminal callback; freeing a pending task, including from inside another callback, follows the documented cancellation rule exactly once. Public API: header documentation and a guaranteed terminal callback. Wire: none. diff --git a/quest/m1/ts-reliability/program-cap.md b/quest/m1/ts-reliability/program-cap.md index e9cf5632b6b..8a27e201764 100644 --- a/quest/m1/ts-reliability/program-cap.md +++ b/quest/m1/ts-reliability/program-cap.md @@ -10,12 +10,11 @@ Today `rs/moq-mux/src/container/ts/programs.rs` loops over every `pat.program_nu Decided 2026-10-22 from the security audit, with the maintainer: -- Create a program's broadcast only once its PMT declares a supported stream, so the state scales with the PMT bytes the input carried, not with the PAT's list. The session's announce budget (100,000 by default, above the `u16` domain) does not bind on its own; it stays the bound a TS input shares with any publisher, and an operator-selected program list narrows it. `--program all` is opt-in; the default already refuses multi-program input. -- No new program-count constant: a cap below the PAT's domain would only refuse valid multiplexes. -- When the announce budget refuses a program, fail the import with the existing multi-program error shape, naming the count and the bound. +- Create a program's broadcast only once its PMT declares a supported stream, so the state scales with the PMT bytes the input carried, not with the PAT's list. `--program all` is the operator's opt-in to every described program, and an operator-selected program list narrows it; the default already refuses multi-program input. +- No new program-count constant or run budget: a cap below the PAT's domain would only refuse valid multiplexes. The session announce budget does not apply here, since it counts what a remote peer announces to us, not broadcasts `Programs` creates locally. - Test with a synthesized PAT naming far more programs than it carries PMTs for, and assert only the described programs exist. -Public API: one new error case. Wire: none. +Public API: none. Wire: none. ## Related From 7aa7714d82337a68aa6e7cf8c1b79375d18d0bcb Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 12:39:45 -0700 Subject: [PATCH 09/13] quest: HLS checks the resolved origin, exact variant area, pin both nix refs Co-Authored-By: Claude Opus 5.5 --- quest/m1/release-audit/hls-admission.md | 8 +++++--- quest/m2/hls-variant-area.md | 2 +- quest/m2/image-hardening.md | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/quest/m1/release-audit/hls-admission.md b/quest/m1/release-audit/hls-admission.md index 5c4d999590f..c3a477843b5 100644 --- a/quest/m1/release-audit/hls-admission.md +++ b/quest/m1/release-audit/hls-admission.md @@ -18,9 +18,11 @@ consider a release backport after validation. Planning settled from the 2026-10-22 security audit: -- Absolute references resolve only when their scheme and authority equal - the playlist's, checked once where references resolve so every resource - kind shares the rule. +- A reference is accepted only when the URL it finally resolves to has the + playlist's scheme and authority, whatever form the reference took + (absolute, network-path, or relative). Check once where references + resolve so every resource kind shares the rule, and cover each form in + the tests. - Every redirect hop is held to the same rule before it is followed. - `file:` resources are read only when the playlist itself is a `file:` URL, which keeps local fixtures working. diff --git a/quest/m2/hls-variant-area.md b/quest/m2/hls-variant-area.md index e2bfea18278..83447b35031 100644 --- a/quest/m2/hls-variant-area.md +++ b/quest/m2/hls-variant-area.md @@ -8,7 +8,7 @@ Today `select_variants` in `rs/moq-hls/src/import.rs` computes `width * height` ## Plan -From the 2026-10-22 security audit. Compute the area without overflow (saturating or widened arithmetic), so an absurd resolution ranks as the largest rather than an arbitrary one. A test with an enormous `RESOLUTION` covers both the panic and the ordering. +From the 2026-10-22 security audit. Compute the area as an exact widened product (for example `u128` from the two `u64` dimensions), so every resolution ranks by its true area. Saturating would collapse large areas into ties that bandwidth and map order then break arbitrarily. A test with an enormous `RESOLUTION` covers both the panic and the ordering. Public API: none. Wire: none. diff --git a/quest/m2/image-hardening.md b/quest/m2/image-hardening.md index 82f39d1eb60..3ff766f50af 100644 --- a/quest/m2/image-hardening.md +++ b/quest/m2/image-hardening.md @@ -12,7 +12,7 @@ Decided 2026-10-22 from the security audit, with the maintainer: - Add a dedicated non-root user and `USER` to the final stage. - `rs/moq-relay/fly.toml` binds 443 directly (`MOQ_LISTEN` and `internal_port`), which an unprivileged process cannot. Prefer moving that deployment to an unprivileged internal port behind the same public 443, if Fly's UDP forwarding allows it; otherwise grant `CAP_NET_BIND_SERVICE` explicitly. -- Pin the builder image by digest, with the version named in a comment so a bump is a one-line diff. +- Pin the builder image by digest, with the version named in a comment so a bump is a one-line diff. The `Dockerfile` also names the same image as the source of the `/nix` cache mount; both references use the one digest, ideally through a shared pinned stage. - Leave release signing out of scope. The installer still trusts TLS and a same-origin checksum; changing that needs its own decision about a signing key and who holds it. Tests: the image builds, the entrypoint runs as the unprivileged user, and the Fly listen configuration starts under it. From 78ab519e596a748b839005b9e105cd8e5b5768c2 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 12:46:24 -0700 Subject: [PATCH 10/13] quest: correct the SNI premise, E2EE truncation goal, fuzz scope, caption clears Co-Authored-By: Claude Opus 5.5 --- quest/m1/README.md | 2 +- quest/m1/auth-contract.md | 10 +++++----- quest/m1/caption-store-bounds.md | 4 ++-- quest/m2/README.md | 2 +- quest/m2/e2ee/lifecycle-hardening.md | 2 +- quest/m2/wire-fuzz-coverage.md | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/quest/m1/README.md b/quest/m1/README.md index 9ad7cd8e39d..60614ee5e2b 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -120,7 +120,7 @@ lite-07 stream type here. - [Compile time audit](/quest/m1/audit-compile-time.md) - build-time hotspots are measured against the m0 baselines and the worst are fixed or planned - [Peer count bounds](/quest/m1/peer-count-bounds.md) - namespace interests, a legacy announce list, a WebSocket upgrade, and public HTTP admission are bounded by what the peer sent or by an existing budget - [Caption store bounds](/quest/m1/caption-store-bounds.md) - a hostile caption track cannot grow a viewer's cue and region store or its per-frame work without bound -- [Auth contract](/quest/m1/auth-contract.md) - the auth server receives the real SNI, and a certificate grants nothing alone +- [Auth contract](/quest/m1/auth-contract.md) - the auth server receives the certificate-selecting SNI, documented as client-chosen, and a certificate grants nothing alone - [Performance audit](/quest/m1/audit-perf.md) - benchmarks that regressed since the m0 run are explained, fixed, or planned, and unbenched hot paths get coverage ## Related diff --git a/quest/m1/auth-contract.md b/quest/m1/auth-contract.md index 95cd7ab900d..42f5b89734c 100644 --- a/quest/m1/auth-contract.md +++ b/quest/m1/auth-contract.md @@ -1,13 +1,13 @@ -# [M] The auth request reports the real SNI and nothing weaker +# [M] The auth request reports what the connection negotiated ## Goal -The auth server decides from facts the client cannot choose: +The auth request reports what the connection actually negotiated, and says which of it the client chose: -- `moq_auth::Request::server_name` is the TLS SNI on every transport, as its contract says, not the client's `Host` or `:authority`. +- `moq_auth::Request::server_name` is the SNI that selected the relay's certificate on every transport, as its contract says, not the client's `Host` or `:authority`. The SNI is still client-chosen, among the names the relay serves, and the doc says so: a hostname-scoped auth server binds tenancy to the token, not to `server_name` alone. - A verified client certificate stays a fact unless the auth server's grant says `peer`; it never reveals hidden routes on its own. -Today `admit_http` fills `server_name` from `request_host(uri, headers)`, and the WebSocket bridge builds its URL from the same header. A client can therefore tell a hostname-scoped auth server it dialed a tenant it never dialed. `cluster_peer` also treats any certificate as a peer for hidden-route discovery. +Today `admit_http` fills `server_name` from `request_host(uri, headers)`, and the WebSocket bridge builds its URL from the same header. A client can therefore report a host the connection never negotiated TLS for. `cluster_peer` also treats any certificate as a peer for hidden-route discovery. ## Plan @@ -17,7 +17,7 @@ Decided 2026-10-22 from the security audit, with the maintainer: - Remove the same fallback from WebTransport on both listener stacks: `request_for` substitutes the request authority (`rs/moq-relay/src/auth.rs`) and the io_uring path the URL host (`rs/moq-relay/src/uring.rs`) when the client sent no SNI. - Derive hidden-route visibility from the grant's `peer` flag, not `request.tls.is_some()`. Until peers set it, document the exemption where operators read it. - Bound the `moq_auth::Client` reply body. -- Update `doc/bin/relay/auth.md` so `server_name`, `peer`, and the certificate-is-a-fact rule match what the code does. +- Update `doc/bin/relay/auth.md` so `server_name` (the certificate-selecting SNI, client-chosen), `peer`, and the certificate-is-a-fact rule match what the code does. Tests: an HTTP/1.1 request with a forged `Host` still reports the SNI; the same over WebSocket; a WebTransport session without SNI reports none on both stacks; a certificate-only session sees no hidden routes. diff --git a/quest/m1/caption-store-bounds.md b/quest/m1/caption-store-bounds.md index 79831d8a79a..440d815eb3e 100644 --- a/quest/m1/caption-store-bounds.md +++ b/quest/m1/caption-store-bounds.md @@ -4,7 +4,7 @@ A caption track from an untrusted publisher cannot grow a viewer's cue store, or its per-frame work, faster than the viewer plays: -- `store.cues` and `store.regions` in `js/watch/src/text/renderer.ts` are bounded by the playhead window and a per-track ceiling. +- `store.cues`, `store.regions`, and `store.clears` in `js/watch/src/text/renderer.ts` are bounded by the playhead window and a per-track ceiling. - A payload with many cues parses in O(n log n), not by walking and splicing per cue. - A cue's declared end time cannot keep it resident past a maximum duration. - A region no retained cue references is dropped. @@ -16,7 +16,7 @@ Today `pruneCues` drops only cues whose end is behind the playhead, so a far-fut Decided 2026-10-22 from the security audit, with the maintainer: - Clamp a cue's end to its start plus a maximum cue duration, and drop cues behind the existing `PRUNE_BEHIND` horizon. -- Prune regions that no retained cue references in the same sweep, and cap both maps, evicting oldest first. Neither cap refuses a payload; they bound what the viewer retains. +- Prune regions that no retained cue references in the same sweep, and cap the cue, region, and clear-marker stores, evicting oldest first. Clear markers from empty frames are inserted and pruned like cues, so far-future markers neither accumulate nor splice. No cap refuses a payload; they bound what the viewer retains. - Sort each payload once and merge it into the store, instead of the backward walk plus splice. A per-cue binary search still splices, so it stays quadratic. - Keep the double-escaped `sanitizeCue` and its renderer-version test unchanged: the audit confirmed the pinned `media-captions` builds only double-quoted attributes, so the current escape set is sufficient. diff --git a/quest/m2/README.md b/quest/m2/README.md index 32db26c5e2d..d8c860c6b77 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -107,7 +107,7 @@ ranked just below deterministic TS legs, which it requires. - [AMF0 exact reads](/quest/m2/rtmp-amf0-exact-reads.md) - a truncated RTMP string fails with `UnexpectedEof` instead of parsing NUL padding - [HLS variant area](/quest/m2/hls-variant-area.md) - a hostile `RESOLUTION` cannot panic or misorder variant ranking - [Image hardening](/quest/m2/image-hardening.md) - the relay image runs unprivileged and its builder stage is pinned -- [Wire fuzz coverage](/quest/m2/wire-fuzz-coverage.md) - every peer-facing decoder has a target that asserts an invariant, and the unsafe peer input reaches runs under Miri +- [Wire fuzz coverage](/quest/m2/wire-fuzz-coverage.md) - the audited moq-net decoders have targets that assert an invariant, and the unsafe peer input reaches runs under Miri - [One port](/quest/m2/one-port/README.md) - one UDP port carries QUIC, SRT, and WebRTC media through an embedder hook, and one TCP port carries HTTP, RTMP, and RTMPS - [QUIC caps](/quest/m2/rate-quic.md) - paced MAX_DATA credit in and a capped pacer out hold a QUIC session to its token's bitrate - [WebSocket caps](/quest/m2/rate-websocket.md) - paced reads and writes over bounded socket buffers hold WebSocket to the same caps diff --git a/quest/m2/e2ee/lifecycle-hardening.md b/quest/m2/e2ee/lifecycle-hardening.md index 7cf7a2a7837..049da278bab 100644 --- a/quest/m2/e2ee/lifecycle-hardening.md +++ b/quest/m2/e2ee/lifecycle-hardening.md @@ -8,7 +8,7 @@ The rules the [E2EE epic](/quest/m2/e2ee/README.md) already decided hold in ever - A grouped write that fails after encryption ends the group, because the transport's frame index can no longer line up with the nonce. - A datagram whose wire identity is out of range is dropped with the bad-datagram event, not thrown as a fatal error. - The AEAD operation and byte budgets are per key, shared by every consumer of that key, without retaining state for keys a relay can make the consumer derive. -- The draft states what a relay can truncate inside a group, so an application never mistakes a short group for a complete one. +- The draft states that a relay can truncate a group undetectably, so an application does not rely on group completeness. The Rust core already keeps the epoch unrepresentable outside the crate. The TypeScript package exports the concrete `Generation.Producer` through `export * as Generation`, and `Producer.make` is a public static that ships in the types. An app that persists an epoch and calls it twice gets two producers with independent claims, both starting at group 0 and frame 0 under the same key. The Rust grouped writer also leaves a group open after a post-encryption `write_frame` error, while the TS twin aborts. diff --git a/quest/m2/wire-fuzz-coverage.md b/quest/m2/wire-fuzz-coverage.md index d30c4a91346..aeafa303687 100644 --- a/quest/m2/wire-fuzz-coverage.md +++ b/quest/m2/wire-fuzz-coverage.md @@ -1,8 +1,8 @@ -# [S] Every peer-facing decoder has a fuzz target that asserts an invariant +# [S] The audited moq-net decoders and peer-reachable unsafe have invariant fuzz targets ## Goal -Each decoder that consumes peer bytes is fuzzed with an assertion stronger than "it did not panic", and the hand-written unsafe that peer input reaches runs under Miri or a target of its own. +The moq-net decoders the audit found uncovered are fuzzed with an assertion stronger than "it did not panic", and the hand-written unsafe that peer input reaches in `moq-c`, `moq-uring`, and `moq-sock` runs under Miri or a target of its own. Other peer-facing decoders, such as the media importers and RTMP's AMF0, are outside this quest. Today `rs/moq-net/fuzz` covers lite, IETF messages, announces, varint, path, and pattern. The gaps the audit found: From de99f75bb7675f30540d026eecafd4256ddac67e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 12:47:02 -0700 Subject: [PATCH 11/13] quest: C async calls deliver one cancelled callback on free Co-Authored-By: Claude Opus 5.5 --- quest/m1/c/async-failure-contract.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quest/m1/c/async-failure-contract.md b/quest/m1/c/async-failure-contract.md index 737f814aa08..94f3c00848c 100644 --- a/quest/m1/c/async-failure-contract.md +++ b/quest/m1/c/async-failure-contract.md @@ -15,9 +15,9 @@ From the 2026-10-22 security audit: - Document the immediate-failure rule on each async callback typedef in the generated header, once in the generator rather than per function. - Run the terminal callback through the same panic and poisoning handling as the rest of the call, so cleanup cannot be lost. -- Make cancellation a terminal result: freeing a pending task delivers one cancelled callback, so the caller reclaims `user_data` in one place on every path. If the generator instead stops all callbacks once the free returns, document that ownership transfer explicitly; either way, settle it once for every async call. +- Make cancellation a terminal result: freeing a pending task delivers one cancelled callback, so the caller reclaims `user_data` in one place on every path. The rule is the same for every async call. -Tests: a call refused before it starts fires no callback; a call whose work panics still delivers one terminal callback; freeing a pending task, including from inside another callback, follows the documented cancellation rule exactly once. +Tests: a call refused before it starts fires no callback; a call whose work panics still delivers one terminal callback; freeing a pending task, including from inside another callback, delivers one cancelled callback. Public API: header documentation and a guaranteed terminal callback. Wire: none. From c47aed22d2b06585457583c4bfa456b18aa50f90 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 12:47:39 -0700 Subject: [PATCH 12/13] quest: the image quest pins the builder rather than claiming reproducibility Co-Authored-By: Claude Opus 5.5 --- quest/m2/image-hardening.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quest/m2/image-hardening.md b/quest/m2/image-hardening.md index 3ff766f50af..718f9940487 100644 --- a/quest/m2/image-hardening.md +++ b/quest/m2/image-hardening.md @@ -1,8 +1,8 @@ -# [XS] The relay image runs unprivileged and builds reproducibly +# [XS] The relay image runs unprivileged and pins its builder ## Goal -The published container image runs as a non-root user, and its builder stage is pinned so the same source produces the same image. +The published container image runs as a non-root user, and its builder image is pinned by digest, so the build tooling cannot drift under the same source. Today the final stage is `FROM scratch` with no `USER`, so the relay runs as uid 0, and the builder is `docker.io/nixos/nix:latest`. From cbc780b8d04998fdcbf44fc65c96b3602b5b3c2f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 12:53:32 -0700 Subject: [PATCH 13/13] quest: MSF duplicate init ids are refused by the JS reader too Co-Authored-By: Claude Opus 5.5 --- quest/m2/msf-duplicate-init.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/quest/m2/msf-duplicate-init.md b/quest/m2/msf-duplicate-init.md index 69eeb39691c..e60d0c9d523 100644 --- a/quest/m2/msf-duplicate-init.md +++ b/quest/m2/msf-duplicate-init.md @@ -2,16 +2,17 @@ ## Goal -An MSF catalog that repeats an `initDataList` id is refused as a deserialization error, instead of resolving to whichever entry comes last. +An MSF catalog that repeats an `initDataList` id is refused as a decode error by every in-repo reader (`rs/moq-msf` and `js/msf`), instead of resolving to whichever entry comes last. -Today `rs/moq-msf/src/lib.rs` collects the list into a `HashMap`, so a repeated id silently replaces the earlier entry. The strict duplicate-key pass used for `moq-json` catalogs does not cover this path. Two readers that keep different entries hand different decoder initialization bytes to different parties for the same broadcast. +Today `rs/moq-msf/src/lib.rs` collects the list into a `HashMap`, and `js/msf/src/catalog.ts` into a `Map`, so a repeated id silently replaces the earlier entry. The strict duplicate-key pass used for `moq-json` catalogs does not cover this path. Two readers that keep different entries hand different decoder initialization bytes to different parties for the same broadcast. ## Plan Decided 2026-10-22 from the security audit, with the maintainer: - Reject a duplicate id while building `by_id` with `serde::de::Error::custom`, the path the catalog's other semantic checks already use. -- Cover the malformed catalog with the example from the audit: two entries named `v` with different `data`, and a track that names `v`. +- Reject it the same way in `js/msf`'s catalog decoder. +- Cover the malformed catalog in both suites with the example from the audit: two entries named `v` with different `data`, and a track that names `v`. Public API: none. Wire: none.