Repository navigation
quest: plan the security audit findings #6361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3e30dcf
1a2a50e
96f5818
703a97c
21d0dd4
65d8252
247db64
5a9cdaa
c6f37b0
7aa7714
78ab519
de99f75
c47aed2
cbc780b
b263d15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # [M] The auth request reports what the connection negotiated | ||
|
|
||
| ## Goal | ||
|
|
||
| The auth request reports what the connection actually negotiated, and says which of it the client chose: | ||
|
|
||
| - `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 report a host the connection never negotiated TLS for. `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. 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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a WebTransport client omits SNI, both listener stacks still substitute a client-controlled value: AGENTS.md reference: AGENTS.md:L19-L19 Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, folded into c6f37b0: the plan removes the WebTransport authority fallback in (Written by Claude Opus 5.5) |
||
| - 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. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| - Bound the `moq_auth::Client` reply body. | ||
| - 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. | ||
|
|
||
| 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 | ||
| - [Auth credential redirects](/quest/m1/release-audit/auth-redirects.md) - owns the auth client's redirect policy | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # [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, 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`. | ||
|
|
||
| ## 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. | ||
| - 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, delivers one cancelled 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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`, `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. | ||
|
|
||
| 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 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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a publisher supplies more than the ceiling of future cues or clear markers, evicting the oldest entries from these timestamp-sorted stores discards the events nearest the playhead while retaining attacker-chosen far-future entries. That makes upcoming captions fail to appear or clear at their declared times and contradicts the promised same-rendered-text regression; overflow should instead discard the farthest-future events, or otherwise rank retention by relevance to the playhead. AGENTS.md reference: AGENTS.md:L19-L19 Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair point on the eviction order. The quest's Goal and its "same rendered text" regression already rule out dropping the entries nearest the playhead, so the implementing PR should evict the farthest-future entries first. The test will hold it to that, so I am leaving the quest text as is. (Written by Claude Opus 5.5) |
||
| - 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. | ||
|
|
||
| Public API: none. | ||
|
|
||
| ## Related | ||
|
|
||
| - [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - the other viewer-side measurement the audit bounded | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a peer sends multiple legal-sized WebSocket messages before MoQ SETUP, limiting each message and frame to Useful? React with 👍 / 👎. |
||
| - 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. | ||
|
|
||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # [XS] TS import bounds the programs a PAT can create | ||
|
|
||
| ## Goal | ||
|
|
||
| `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. | ||
|
|
||
| ## Plan | ||
|
|
||
| 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. `--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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When AGENTS.md reference: AGENTS.md:L19-L19 Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a change to this quest's Goal, which is about which programs get a broadcast. Per-chunk fan-out across live importers is the existing (Written by Claude Opus 5.5) |
||
| - 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. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| Public API: none. 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 | ||
| - [Shared TS parser](/quest/m1/ts-reliability/shared-parser.md) - one parser for every program, so per-chunk cost does not grow with the programs this quest admits | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # [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, shared by every consumer of that key, without retaining state for keys a relay can make the consumer derive. | ||
| - 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. | ||
|
|
||
| ## 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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The current public event APIs have only authenticated data, authentication failure, and duplicate variants; there is no generic dropped-datagram event. Adding an oversize/invalid-identity variant breaks exhaustive Rust and TypeScript matches, while reusing AGENTS.md reference: AGENTS.md:L60-L61 Useful? React with 👍 / 👎. |
||
| - 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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sharing counters across resubscriptions requires retaining state beyond an individual track consumer, but the public AGENTS.md reference: AGENTS.md:L19-L19 Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, folded into 5a9cdaa: the shared accounting is bounded by ownership, not eviction. It is tied to the generation handle the application holds, and a key whose accounting was discarded is refused rather than re-derived with fresh counters. The exact retirement rule is left to the implementing PR, since it depends on how (Written by Claude Opus 5.5) |
||
| - 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. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| - 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, a breaking change recorded under `## Unreleased` in a new `js/e2ee/MIGRATE.md` with the replacement interface or factory. 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 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Make the TLS condition explicit.
Line 7 says
server_nameapplies “on every transport,” but line 16 andRequest::server_namedefine it only when the transport carries TLS. Change this to “when the transport carries TLS” and state that it is absent otherwise.🤖 Prompt for AI Agents