diff --git a/quest/m0/README.md b/quest/m0/README.md index c1e361e2c7f..713c2897821 100644 --- a/quest/m0/README.md +++ b/quest/m0/README.md @@ -28,6 +28,8 @@ edge, which embeds moq-relay; it moved there on 2026-09-28. - [Nightly passes on main](/quest/m0/nightly/README.md) - the scheduled Nightly passes end to end, so red means a new break - [Interop and Video pass on main](/quest/m0/interop-green/README.md) - the scheduled Interop and Video workflows pass, so red means a new break +- [JS qmux keeps credit and final sizes consistent with Rust](/quest/m0/qmux-js-credit.md) - a JS WebSocket session no longer stalls on cancelled streams or gets closed by a Rust peer with FINAL_SIZE_ERROR, and its control queue stays bounded +- [Peer and config values never panic or wrap moq-net arithmetic](/quest/m0/peer-arithmetic.md) - a peer's retry interval, object id, drop end or sequence, and huge configured durations no longer panic a task or wrap - [Publish the release line's drain() wrappers](/quest/m0/ffi-shutdown-backport.md) - Dart `moq` 0.1.1 reaches pub.dev from `release` - [Release's audio encoder rolls groups before the cap](/quest/m0/release-audio-group-cap.md) - a long `groupDuration` with short frames never throws `GroupTooLarge` on `release` - [Local checks pass on unchanged main](/quest/m0/local-checks-main.md) - `sh/go/publish-wrapper.test.sh` passes under a global `tag.gpgsign = true`, so `just check` passes on a clean `main` diff --git a/quest/m0/peer-arithmetic.md b/quest/m0/peer-arithmetic.md new file mode 100644 index 00000000000..0bcf0f34f4f --- /dev/null +++ b/quest/m0/peer-arithmetic.md @@ -0,0 +1,16 @@ +# [S] Peer and config values never panic or wrap moq-net arithmetic + +## Goal + +No value a peer sends or an application configures panics a moq-net task or silently wraps: + +- `rs/moq-net/src/ietf/publisher.rs` `refusal`: a REQUEST_ERROR Retry Interval near `u64::MAX` panics through kio's `Instant + Duration`. Any peer we send PUBLISH_NAMESPACE to can trigger it. +- `rs/moq-net/src/ietf/publisher.rs` `save_join`: `largest.object + 1` on an upstream's LARGEST_OBJECT of `u64::MAX`. +- `rs/moq-net/src/reconnect.rs`: `now + duration` and `mul_f64` on `Goaway.handover`, `Config::timeout` and `Backoff` panic for huge configured values once a GOAWAY arrives; `Server::deadline` already treats overflow as no deadline. +- `rs/moq-net/src/lite/subscriber.rs` and `subscriber/fills.rs`: SUBSCRIBE_DROP's inclusive end `u64::MAX` becomes `..u64::MAX` through `saturating_add(1)`, so the drop misses group `u64::MAX`. +- `rs/moq-net/src/lite/publisher.rs` `DatagramSend::send`: a sequence of 2^62 or more relayed from lite-07 to a lite-05/06 subscriber fails to encode and is dropped silently, and the subscription ends in a reset instead of a finish. +- `rs/moq-net/src/route/mod.rs` `requests`: `fd[&id].0 + 1` on an advertised seqno `u64::MAX` (test-only today; becomes reachable when lite-07 drives the router). + +## Plan + +Found by the 2026-11-07 invariant audit (ietf-1, ietf-2, lite-3, lite-4, lite-9, model-3). Each site gets `checked_add` with an explicit meaning for overflow (no deadline, unsupported, refused) and a test at the extreme value. Prefer refusing the impossible value at decode or at `Reconnect::new` where that is simpler than handling it downstream. diff --git a/quest/m0/qmux-js-credit.md b/quest/m0/qmux-js-credit.md new file mode 100644 index 00000000000..be987bcc1e1 --- /dev/null +++ b/quest/m0/qmux-js-credit.md @@ -0,0 +1,19 @@ +# [S] JS qmux keeps credit and final sizes consistent with Rust + +## Goal + +A JS qmux session (the WebSocket fallback) never stalls or gets closed by a Rust peer because of its own flow-control bookkeeping, and a peer cannot grow its memory without bound: + +- Bytes that arrive on a stream we already stopped (late STREAM frames, and the final-size gap of a later RESET_STREAM) count toward connection receive credit. Today `js/qmux/src/session.ts` (`#onStream`, `#onResetStream`) returns early once the receive half is deleted on cancel, so each cancelled stream permanently shrinks the window until MAX_DATA is never sent again. +- A RESET_STREAM's final size is at least every byte already handed to the socket. Today `sendOffset` advances only after `scheduler.enqueueStream` resolves, so a STOP_SENDING handled while a frame is mid-`sink.write` replies with a short final size, which Rust's `rs/moq-quic/src/connection/streams/recv.rs` refuses with FINAL_SIZE_ERROR. +- MAX_DATA, MAX_STREAMS_{BIDI,UNI} and MAX_STREAM_DATA (per stream) replace any queued copy, as Rust does with its pending flags, instead of each taking a new entry on the uncapped control lane. +- An empty binary WebSocket message is a no-op on every qmux version, matching `rs/qmux/src/transport/websocket.rs`; qmux-00 currently throws. +- WebSocket messages larger than the record size are refused before they are buffered where the platform allows it: Rust `rs/qmux/src/ws.rs` `Upgraded` validates or sets the tungstenite `max_message_size` itself instead of trusting the caller, and JS documents the `ws` `maxPayload` it needs. + +## Plan + +Found by the 2026-11-07 invariant audit (qmux-1 to qmux-5). qmux-1 and qmux-2 are the urgent ones: an honest Rust relay triggers both whenever a JS app cancels group streams over WebSocket. + +- Keep each stopped peer stream's receive offset (and final size once known) until FIN or RESET so late bytes are accounted, and port Rust's `credit_returns_for_unread_and_stopped_streams` (`rs/moq-quic/src/connection/mux/tests.rs`). +- Count bytes as sent when the scheduler takes the frame from its queue, or track the in-flight frame per stream and include it in the RESET final size. Test with a sink whose `write` is held open while STOP_SENDING arrives. +- Send the MAX_* frames through `replaceControl` keyed by type (and stream id for MAX_STREAM_DATA); fix the "bounded" claim in `scheduler.ts`. diff --git a/quest/m1/README.md b/quest/m1/README.md index 39f77f2cd7b..9c9f89b8fe1 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -33,6 +33,11 @@ moves what remains of them once their claims merge. - [JS cache pool](/quest/m1/js-cache-pool.md) - `js/net` bills cached frames and drop-set runs to a per-broadcast byte pool ported from Rust - [Drop set](/quest/m1/drop-set.md) - the drop set's track and cursor runs are billed to the cache pool, so fragmenting drops costs what the pool holds; eviction folds final runs or ends the cursor with `TooFarBehind` +- [Only the relay's own stats publisher uses the stats prefix](/quest/m1/stats-prefix.md) - a broad grant can no longer publish unmetered media or spoof node stats under `.stats` +- [js/net enforces the input checks Rust does](/quest/m1/js-net-input-checks.md) - GOAWAY redirects to loopback spellings, credential logging, ANNOUNCE_INIT size, sequence range, and version pinning match Rust +- [Rust and JS accept exactly the same tokens and key sets](/quest/m1/token-parse-strict.md) - a null `exp` no longer means never-expiring in Rust, duplicate kids and bad scope roots are refused, and every relay lease is validated +- [A refused lite SUBSCRIBE_UPDATE ends the subscription](/quest/m1/lite-update-refused.md) - the publisher no longer serves a removed range or reports the wrong start after the model refuses an update +- [Cluster peers have one identity each and fresh inputs](/quest/m1/cluster-peer-identity.md) - a duplicate cluster id, a self-dial, or a rotated cluster token fails loud instead of partitioning or looping the mesh - [Media fuzz findings](/quest/m1/fuzz-findings/README.md) - the nightly media fuzz targets run clean: mp4-atom, MKV block, TS step, SPS overflow, and catalog encoder bugs they found are fixed - [A smaller, safer API than release](/quest/m1/api-audit/README.md) - every surface added since release has a consumer or is gone, overlapping operations are collapsed, names mirror across Rust, JS, and the bindings, and every break says how to migrate - [moq-webrtc drops the ICE wire counters nothing reads](/quest/m1/ice-wire-counters.md) - the per-packet `Wire` atomics go once #8122 makes the ICE module private @@ -55,6 +60,10 @@ moves what remains of them once their claims merge. - [QMux reads the app-limited flag on big-endian Linux](/quest/m1/qmux-app-limited-endian.md) - the send-rate filter's app-limited mask follows the target's byte order - [A cancelled dispatch lane stops its phase promptly](/quest/m1/dispatch-cancel-race.md) - a TERM landing just before a lane forks its phase's command still stops that command, instead of waiting out the phase - [Lifecycles are explicit state](/quest/m1/explicit-state/README.md) - every lifecycle the 2026-11-07 audit found implicit is one enum or union, fixing the bugs in the 11 lifecycles it redesigns, with review and agent rules against new ones +- [Copies of one group identity must agree beyond their bytes](/quest/m1/copy-identity.md) - copies that differ in timestamp, object fields, or frame count fail as a protocol violation +- [Session auth grants and replies stay consistent and bounded](/quest/m1/auth-stream-bounds.md) - an AUTH_ERROR revokes its grant, queued grants and retiring tokens are bounded, and dropping queued requests cannot deadlock +- [Relay settings and admin input that cannot work are refused](/quest/m1/relay-config-checks.md) - clustered stats without a node name, pin without workers, repeated filter keys, and unknown transports fail loud +- [Track drop runs are forgotten below the floor](/quest/m1/drop-runs-prune.md) - a track's dropped-group record stays proportional to its window in Rust and JS ## Related diff --git a/quest/m1/auth-stream-bounds.md b/quest/m1/auth-stream-bounds.md new file mode 100644 index 00000000000..82188051bd1 --- /dev/null +++ b/quest/m1/auth-stream-bounds.md @@ -0,0 +1,14 @@ +# [S] Session auth grants and replies stay consistent and bounded + +## Goal + +moq-net's session-side auth (`rs/moq-net/src/auth.rs`, `auth/tokens.rs`, and the AUTH stream loops in `lite/publisher.rs` and `ietf/auth.rs`) keeps four promises it currently leaves to callers: + +- A token answered with AUTH_ERROR leaves the enforced scope at once. Today an AUTH_OK too large to encode is replaced by AUTH_ERROR and `state.done = true` without `Issue::finish`, so the grant `reply()` already recorded keeps admitting requests for the session. +- Replies queued for a peer that withholds stream credit are bounded: a newer `Reply::Grant` replaces a queued one instead of appending to the outbox. +- Tokens replaced by `Tokens::set` are withdrawn even when they were never answered; a backend failing transiently while the app rotates JWTs does not pile up retrying AUTH streams. +- `Handle::requests` never drops queued `Request`s under the state lock (dropping one re-enters it); take them out and drop them after the guard. + +## Plan + +Found by the 2026-11-07 invariant audit (lite-2, lite-5, lite-6, lite-8). Each gets a test: `allows()` is false after an oversize accept, repeated `Issued::update` on a blocked stream keeps one queued grant, two `set` calls with no answer leave one retiring generation, and swapping the acceptor with queued requests does not deadlock. diff --git a/quest/m1/cluster-peer-identity.md b/quest/m1/cluster-peer-identity.md new file mode 100644 index 00000000000..e8c96fb58fc --- /dev/null +++ b/quest/m1/cluster-peer-identity.md @@ -0,0 +1,15 @@ +# [S] Cluster peers have one identity each and fresh inputs + +## Goal + +A relay mesh fails loud on identity mistakes instead of silently partitioning or looping, and its peer inputs stay current and bounded (`rs/moq-relay/src/cluster.rs`, `relay.rs`): + +- A peer session whose declared hop (`Request::peer_hop`) equals our `cluster.id` is refused with an error naming the duplicate, instead of every route from it being dropped as reflected. +- One relay has one dial key: `DialTarget` keys on `canonicalize_peer_key` (which also strips URL userinfo, so credentials stop reaching logs and the `remote` span), and the self filter applies to static `cluster.connect` entries too. A test covers the self filter. +- `--cluster-lan` on a relay without a QUIC listener is refused at startup instead of advertising SRV port 0. +- The `cluster.token` file is re-read on redial (or watched like the API file), so a rotated or expiring token does not break every redial until restart. +- The `cluster.api.url` body and file are read with a size cap; an oversized answer keeps the last good peer list. + +## Plan + +Found by the 2026-11-07 invariant audit (relay-2, relay-4, relay-5, relay-7, relay-9, relay-10). diff --git a/quest/m1/copy-identity.md b/quest/m1/copy-identity.md new file mode 100644 index 00000000000..0cbbba322fd --- /dev/null +++ b/quest/m1/copy-identity.md @@ -0,0 +1,13 @@ +# [M] Copies of one group identity must agree beyond their bytes + +## Goal + +Two copies of the same broadcast+track+group (another route, a FETCH answer, a re-offer, a mid-frame recovery) that disagree on anything a reader sees fail the later copy with a protocol violation, instead of readers of each copy seeing different content under one identity. Today `rs/moq-net/src/model/group/content.rs` `row()`, `write_chunk` and the recovery in `frame.rs` compare only size, `inflated` and overlapping bytes; nothing compares a frame's timestamp, its IETF object fields, or the group's final frame count, so a copy with one more frame can raise `largest` after `finish_largest` declared it settled. + +## Plan + +Found by the 2026-11-07 invariant audit (model-1). Put the timestamp and a digest of the object fields in the shared row, and the group's fin in `Content`; a copy that disagrees, commits past the fin, or finishes short of it gets `ProtocolViolation`. Tests: two copies with differing timestamps, differing fields, and an extra frame. Check the JS counterpart (`js/net/src/group.ts`) and match it in the same PR. + +## Related + +- [A reader on a failed copy continues on the held re-offer](/quest/m1/copy-recover.md) - also stitches frames across copies diff --git a/quest/m1/drop-runs-prune.md b/quest/m1/drop-runs-prune.md new file mode 100644 index 00000000000..7151a038a7f --- /dev/null +++ b/quest/m1/drop-runs-prune.md @@ -0,0 +1,13 @@ +# [S] Track drop runs are forgotten below the floor + +## Goal + +A track's record of dropped groups stays proportional to the window readers can still ask for, in Rust and JS. Today `drops` only grows: `RangeMap` in `rs/moq-net/src/model/track.rs` is never pruned, and JS `insertDrop` (`js/net/src/internal.ts`) copies and re-merges the whole array for the state and every sink on each SUBSCRIBE_DROP, while `#drop` in `js/net/src/track.ts` scans the whole cache. A peer dropping alternating groups, or a long live track with sporadic gaps, grows it forever at quadratic total cost in JS. + +## Plan + +Found by the 2026-11-07 invariant audit (js-4). Runs below the cache/arrivals floor are forgotten, as `Delivered.forgetBelow` does, and JS inserts in place. This waits on [Drop set](/quest/m1/drop-set.md), which redesigns these runs with their reason and budget; prune that representation rather than today's. + +## Required + +- [Drop set](/quest/m1/drop-set.md) - drop runs carry their reason and budget, the structure this quest prunes diff --git a/quest/m1/js-net-input-checks.md b/quest/m1/js-net-input-checks.md new file mode 100644 index 00000000000..92d4b051709 --- /dev/null +++ b/quest/m1/js-net-input-checks.md @@ -0,0 +1,16 @@ +# [S] js/net enforces the input checks Rust does + +## Goal + +`@moq/net` rejects the inputs `rs/moq-net` rejects, so JS is not the weaker side of a session: + +- A GOAWAY redirect is classified on the host actually dialed. `isLocal` in `js/net/src/connection/goaway.ts` parses the opaque `moql:`/`moqt:` host, so `127.1`, `0x7f000001` and `2130706433` pass as non-local while `dialable()` rewrites them to `https:`, which resolves to 127.0.0.1. With `redirect: "follow"` a relay can steer the client and its tokens to loopback. +- `redact` in `js/net/src/util/log.ts` logs scheme, host and port only. For `moql:` URLs `url.origin` is `"null"` and the path, which can carry a token, is kept. +- The lite-01/02 ANNOUNCE_INIT is capped like Rust's (`frame::SEGMENT - 16`) and its count is checked against the announce budget before decoding (`js/net/src/lite/announce.ts`). +- `checkSequence` (`js/net/src/util/sequence.ts`) refuses a group sequence at or above 2^64, as datagrams already do, so `appendGroup` after group 2^64-1 fails instead of minting a group past `UNBOUNDED`. +- `accept.ts` requires a pinned `AcceptProps.version` to be one the client offered, as `rs/moq-net/src/server.rs` does. +- `open.ts` `patience` treats an RTT of 0 as unknown, so a transport that reports 0 before its first sample does not make every stalled open reset a lower-priority stream. + +## Plan + +Found by the 2026-11-07 invariant audit (js-2, js-5 to js-9). Tests for each, including the three loopback spellings. js-1 (announce queue growth) is already [JS announced coalescing](/quest/m3/js-announced-coalesce.md). diff --git a/quest/m1/lite-update-refused.md b/quest/m1/lite-update-refused.md new file mode 100644 index 00000000000..9610a589ba1 --- /dev/null +++ b/quest/m1/lite-update-refused.md @@ -0,0 +1,9 @@ +# [S] A refused lite SUBSCRIBE_UPDATE ends the subscription + +## Goal + +When the model refuses a lite SUBSCRIBE_UPDATE, the publisher's per-range state is left unchanged and the subscription ends with the refusal, as the initial SUBSCRIBE and the ietf publisher already do. Today `TrackRun::update` in `rs/moq-net/src/lite/publisher.rs` only uses `self.track.update(..).is_ok()` to decide `self.named`, then rewrites `ids`, `unstarted`, `frames`, `floor` and `cap` anyway, so the publisher's view and the model's diverge and SUBSCRIBE_STARTED can name a range with another range's start. + +## Plan + +Found by the 2026-11-07 invariant audit (lite-1). On `Err`, set `self.refused` and return before mutating, as the `Bounds::new` arm does; carve out `Closed` only if it is benign. Add a test: an update that swaps ranges for one the cache cannot settle ends the subscription instead of serving the removed range. diff --git a/quest/m1/relay-config-checks.md b/quest/m1/relay-config-checks.md new file mode 100644 index 00000000000..605cb5b2e87 --- /dev/null +++ b/quest/m1/relay-config-checks.md @@ -0,0 +1,16 @@ +# [S] Relay settings and admin input that cannot work are refused + +## Goal + +moq-relay refuses at load or request time what it currently accepts and then ignores or mishandles: + +- Stats enabled on a clustered relay without `stats.node` is refused, or `stats.node` defaults to `cluster.node`, so nodes stop overwriting each other's `/node` broadcast. +- `runtime.pin` without `runtime.workers` is refused, matching the file's "refused rather than ignored" rule. +- A repeated key on `/sessions` or `/sessions/revalidate` (`session.rs` `Filter::from_query`) is an error instead of the last value winning. +- Refusal counters (`refusals.rs`) stay bounded with stats disabled, where nothing calls the pruning `Registry::report`. +- `auth.rs` maps every `moq_tokio::Transport` without `unreachable!` (the enum is `#[non_exhaustive]`), and the qmux-01-only ALPN choice in `websocket.rs` is derived from the version, not a hand-kept string list. +- `session::Registry` registration drops only their own entry, so an embedder registering a reused `Request` id cannot unlist another live session. + +## Plan + +Found by the 2026-11-07 invariant audit (relay-3, relay-6, relay-8, relay-11 to relay-14). diff --git a/quest/m1/stats-prefix.md b/quest/m1/stats-prefix.md new file mode 100644 index 00000000000..bb667a218a5 --- /dev/null +++ b/quest/m1/stats-prefix.md @@ -0,0 +1,9 @@ +# [XS] Only the relay's own stats publisher uses the stats prefix + +## Goal + +No client session can publish or announce under the relay's stats prefix (`.stats` by default), whatever its grant. Today `Cluster::publisher` scopes purely from the grant's patterns, while the stats registry excludes the whole `/**` subtree from metering, so a root `**` grant can publish unmetered media there and replace a node's `.stats/node/` broadcast that aggregators read. + +## Plan + +Found by the 2026-11-07 invariant audit (relay-1). Cut the prefix out of non-peer publish scopes in `Cluster::mounted`/`scope` (`rs/moq-relay/src/cluster.rs`); peers still relay each other's stats. Test that a `**` publisher cannot announce under the prefix and that subscribers still can read it. diff --git a/quest/m1/token-parse-strict.md b/quest/m1/token-parse-strict.md new file mode 100644 index 00000000000..aa825ef3828 --- /dev/null +++ b/quest/m1/token-parse-strict.md @@ -0,0 +1,15 @@ +# [S] Rust and JS accept exactly the same tokens and key sets + +## Goal + +Token and key parsing is strict and identical in `rs/moq-auth` and `js/auth`, and every grant the relay holds has been validated: + +- `exp`, `iat` and `nbf` refuse `null` and values outside the range both languages represent. Today Rust reads `"exp": null` as no expiry (a token that never expires) while JS refuses it; the Grant wire `expires` has the same gap. +- A KeySet with a duplicate `kid` is refused at parse in both languages instead of the first match winning. +- A JWK's scope root passes `path::validate` on import in both languages, as the `with_scope` doc promises. +- The relay detects a token the way the server parses one (`presents_token` vs form-decoded `jwt`), so `?%6Awt=` cannot fall through to the public grant; key sources are cached instead of re-read and re-parsed per token. +- `Lease::new` (`rs/moq-relay/src/auth.rs`) runs `Grant::validate`, so an embedder's grant cannot skip the tier charset and upstream-implies-peer checks. + +## Plan + +Found by the 2026-11-07 invariant audit (auth-2, auth-4, auth-9, auth-11, auth-12). Each refusal gets a vector in the Rust/JS interop test (`js/auth/src/interop.test.ts`), including a null-`exp` token. diff --git a/quest/m2/README.md b/quest/m2/README.md index bfbcd17fba8..4301d7fd23e 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -186,6 +186,9 @@ quests that require them. - [moq-quic drops inherited surfaces with no consumer](/quest/m2/moq-quic-unused-surface.md) - unused accept, connection, and stream-id surfaces leave moq-quic's public API before the cut - [Publish reports rendition stats as hang's type](/quest/m2/rendition-stats-type.md) - `Rendition.stats` and `Report.Writer` take the rendition stats schema's input type, so encoders write plain numbers - [MoQ on rind](/quest/m1/rind/README.md) - every MoQ crate takes its crypto from rind, a pure-Rust graviola fork, so no build compiles C crypto (held in m1 by an open claim) +- [A recreated or restarted track cannot reuse group sequences](/quest/m2/sequence-reuse.md) - recreating a track or restarting an instance cannot give new content an old group identity unless the app seeds past it, and datagrams are documented as exempt +- [Subscriptions name the oldest group without a u64::MAX sentinel](/quest/m2/anchor-oldest.md) - `Anchor` gets an explicit oldest variant, decoded the same way on every wire +- [moq auth serve bounds what a leaked token or public caller can do](/quest/m2/auth-serve-policy.md) - tokens need an `exp` unless the operator opts out, and a public listener authenticates relays - [Cut readiness](/quest/m2/cut-gate/README.md) - the checks the cut needs that break nothing: main no slower than release, vendored fixes ported, and moq-c at parity - [Probe](/quest/m2/probe/README.md) - a session probes up to the bitrate it wants to send or receive, so a stopped simulcast rendition resumes and a viewer up-switches; browser padding is parked in m3 (held in m2 by open claims; moves to m3) - [Finish the milestone re-cut](/quest/m2/recut-held.md) - claim-held epics move to the milestone their kind and priority give them once their claims merge diff --git a/quest/m2/anchor-oldest.md b/quest/m2/anchor-oldest.md new file mode 100644 index 00000000000..f479a911d38 --- /dev/null +++ b/quest/m2/anchor-oldest.md @@ -0,0 +1,13 @@ +# [S] Subscriptions name the oldest group without a u64::MAX sentinel + +## Goal + +`Anchor` has an explicit variant for "the oldest group", and `Relative(n)` always means n groups before the latest. Today `Range::oldest` is `Anchor::Relative(u64::MAX)` (`rs/moq-net/src/model/subscription.rs`), against the repository's rule never to use a huge value as a marker. A peer on lite-07 or IETF can send `u64::MAX` or `u64::MAX - 1`, which clamp to the same group but differ in window start, demand shape and `is_wire`, and the lite encoder treats any `back > MAX_QUIC` as oldest, which the model does not. + +## Plan + +Found by the 2026-11-07 invariant audit (model-4). Add the variant, decode and encode it consistently on every wire (lite-07, lite-06 and earlier, IETF), and mirror it in JS and the bindings. m2 because `Anchor` is public API. + +## Related + +- [Subscribe ranges](/quest/m2/subscribe-ranges/README.md) - owns the range model this anchor lives in diff --git a/quest/m2/auth-serve-policy.md b/quest/m2/auth-serve-policy.md new file mode 100644 index 00000000000..f459f13278d --- /dev/null +++ b/quest/m2/auth-serve-policy.md @@ -0,0 +1,14 @@ +# [S] moq auth serve bounds what a leaked token or public caller can do + +## Goal + +`moq auth serve` stops relying on operator discipline for two invariants: + +- Admission eventually ends. Today `exp` is never required (`required_spec_claims` is emptied, `moq auth sign` adds none by default) and `Policy.expires` and revalidation are off by default, so a leaked token without `exp` admits forever and admitted sessions never re-check. The server refuses a token without `exp` unless the operator passes an explicit opt-out flag, and `moq auth sign` writes an `exp` by default. +- Only relays drive the session table. Today `POST /` is unauthenticated and `--listen-public` only lifts the loopback bind, so anyone can record sessions with a victim's `remote` (exhausting its `RemoteLimit`) or grow `slots` with random ids. A public listener requires a shared secret or mTLS from relays. + +## Plan + +Found by the 2026-11-07 invariant audit (auth-3, auth-5). + +Decided 2026-11-07 (maintainer, invariant-audit planning): m2, since both change CLI behaviour a deployed operator must adapt to. The opt-out keeps unbounded tokens possible for deployments that revoke by key rotation. diff --git a/quest/m2/sequence-reuse.md b/quest/m2/sequence-reuse.md new file mode 100644 index 00000000000..adf56b73720 --- /dev/null +++ b/quest/m2/sequence-reuse.md @@ -0,0 +1,22 @@ +# [S] A recreated or restarted track cannot reuse group sequences + +## Goal + +moq-net refuses to give new content an identity it already used, in Rust and JS, instead of relying on the documented contract: + +- Recreating a track name in a live broadcast (`create_track` after the previous producer dropped, `rs/moq-net/src/model/broadcast.rs`) no longer restarts `append_group` at 0 under a fresh `TrackState`. The broadcast remembers each name's highest sequence, and a group at or below it on the replacement is an error. +- A publisher restarting under the same instance at a higher epoch, which `js/net/src/origin.ts` splices onto the existing logical front (and Rust's origin likewise continues), is refused loudly when its sequences go backwards, instead of resume silently dropping its groups as already delivered or a recovering reader stitching frames from two streams into one group. +- An application that really wants to reuse a name seeds it explicitly with a sequence past the predecessor's highest; the library never does it silently. +- Datagrams are documented as outside the identity rule: on the datagram API in Rust and JS and in the moq-lite draft, a datagram sequence names no cached content and repeats are delivered. + +## Plan + +Found by the 2026-11-07 invariant audit (model-2, js-3, model-7, js-10). + +Decided 2026-11-07 (maintainer, invariant-audit planning): reuse is misuse that produces unintended behaviour, so the library prevents it and an application that really wants it seeds from the high-water mark itself; the library does not seed automatically. Datagrams get no duplicate detection: spending resources to catch application bugs there is not worth it, so they are documented as exempt instead. + +m2 because `append_group`/`create_group` and the origin splice start refusing calls that succeed today, which callers recreating tracks must adapt to (the questline's breaking-change test). The API shape for the explicit seed is the implementer's call; prefer reusing `create_group` with an explicit sequence over a new method. [moq-dev/moq#8063](https://github.com/moq-dev/moq/pull/8063) changes how a job's route continues its claim's instance; build on whichever lands first. + +## Related + +- [A job's exact route continues its claim's readers](/quest/m2/announce-takeover.md) - instance continuity across a claim's jobs diff --git a/quest/m3/mesh/README.md b/quest/m3/mesh/README.md index 797e4282a40..13a97522f32 100644 --- a/quest/m3/mesh/README.md +++ b/quest/m3/mesh/README.md @@ -96,6 +96,7 @@ the third, and survives a relay restart. - [Byte streams](/quest/m3/stream/README.md) - lossless TCP-level streams over MoQ - [Endpoint API](/quest/m3/mesh/endpoint.md) - an iroh-shaped `Endpoint` that connects to an endpoint ID and service and accepts byte streams - [Mesh relay node](/quest/m3/mesh/node.md) - a relay node enrolls into a mesh, dials its relays, and admits only enrolled LAN peers +- [Mesh enrollment is bounded and revocation takes effect](/quest/m3/mesh/device-bounds.md) - a reusable key enrolls a bounded number of devices and a revoked device loses access within a bounded time - [Address hints](/quest/m3/mesh/addr.md) - nodes publish their addresses on mesh tracks and dial each other directly where mDNS cannot find them - [Sparse overlay](/quest/m3/mesh/overlay.md) - each node keeps about log N deterministic direct links, forwards for the rest, and falls back to relays across a partition - [JS mesh enrollment client](/quest/m3/mesh/js-enroll.md) - `@moq/auth` enrolls and refreshes from JS like `moq_auth::mesh::Client` diff --git a/quest/m3/mesh/device-bounds.md b/quest/m3/mesh/device-bounds.md new file mode 100644 index 00000000000..6dffe8c0ccc --- /dev/null +++ b/quest/m3/mesh/device-bounds.md @@ -0,0 +1,12 @@ +# [S] Mesh enrollment is bounded and revocation takes effect + +## Goal + +The mesh coordinator (`rs/moq-auth/src/mesh/coordinator.rs`) stops assuming its device store stays small and its revocations wait for token expiry: + +- A reusable enrollment key enrolls a bounded number of devices, and `/enroll` is rate limited; today each enroll clones the whole store, rewrites the state file and returns every member under one mutex, so a leaked key can mint thousands of endpoints. +- A revoked device loses access within a bounded time, not only at its token's `exp` (1h by default): either `decide` checks revocation for mesh tokens, or mesh tokens are short-lived with revalidation on. + +## Plan + +Found by the 2026-11-07 invariant audit (auth-7, auth-8). diff --git a/quest/m4/auth-session-index.md b/quest/m4/auth-session-index.md index 62b739a70fe..be3b54eb334 100644 --- a/quest/m4/auth-session-index.md +++ b/quest/m4/auth-session-index.md @@ -13,6 +13,7 @@ Decided 2026-11-01 (maintainer, follow-up planning after the 2026-11-01 /quest-a - Keep `HashMap` and `HashMap` beside the slots, updated on connect, end, a new token attaching to a known session, and expiry. `Sessions::revalidate` updates them too, since it re-inserts an aged-out or restart-lost slot and appends a token the slot hadn't seen, and it keeps today's rule of enforcing no cap. - Age slots from a queue ordered by `seen`, refreshed on each sighting (a re-push with a generation, or an ordered map keyed by `(seen, id)`), so a sweep pops only expired entries. Keep today's rule: a session that missed two cadences is dropped. - Keep the semantics the doc comment on the limits describes, including a known id attaching another credential counting only against the new JWT's cap. +- Key the per-token count on the token's signing input (header and payload) or its decoded claims, not the whole compact JWS: an ECDSA signature can be malleated to a second valid string, which today doubles `limits.token` for an ES256 or ES384 holder (found by the 2026-11-07 invariant audit, auth-6). - Measure with #7512's `verify/sessions` bench before and after; the slope should be flat. Public API: none. Wire: none.