From 052f7b68b5eea5c078287045223f58eadda8943b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 19 Oct 2026 18:59:52 -0700 Subject: [PATCH 1/8] chore: add an OSS Scanner build image Co-Authored-By: Claude Opus 5.5 --- .oss-scanner/Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .oss-scanner/Dockerfile diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile new file mode 100644 index 00000000000..309b7cacbfb --- /dev/null +++ b/.oss-scanner/Dockerfile @@ -0,0 +1,25 @@ +# Image for Anthropic's OSS Scanner (https://github.com/anthropics/oss-scanner). +# +# The audit runs offline on 2 CPUs, so this build fetches every crate and prebuilds the network-facing Rust crates, +# their tests, and the moq-relay and moq CLI binaries. threat_model.md, next to this file, says what to attack and how. +# The rest of the workspace (capture, encode, FFI and bindings) needs system media libraries and is out of scope. +FROM rust:1-trixie +ENV DEBIAN_FRONTEND=noninteractive +# aws-lc-sys (rustls' crypto provider) builds with clang and cmake. +RUN apt-get update && apt-get install -y --no-install-recommends clang cmake pkg-config \ + && rm -rf /var/lib/apt/lists/* + +# scanner contract: the checkout lives inside the image, at /src +COPY . /src +WORKDIR /src + +# rust-toolchain.toml pins the toolchain; rustup installs it on first use. +RUN rustup show active-toolchain || rustup toolchain install + +ARG CRATES="kio hang moq-auth moq-clock moq-flate moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-cli" + +RUN cargo fetch --locked \ + && cargo build --locked $(printf -- '-p %s ' $CRATES) --bins \ + && cargo test --locked --no-run $(printf -- '-p %s ' $CRATES) + +ENV CARGO_NET_OFFLINE=true From e9c18a86a352211255ff230df36f0a308ba0e67e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 19 Oct 2026 19:01:48 -0700 Subject: [PATCH 2/8] chore: build OSS Scanner crates by path, add a threat model Co-Authored-By: Claude Opus 5.5 --- .oss-scanner/Dockerfile | 6 ++-- .oss-scanner/threat_model.md | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 .oss-scanner/threat_model.md diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile index 309b7cacbfb..64d4db41509 100644 --- a/.oss-scanner/Dockerfile +++ b/.oss-scanner/Dockerfile @@ -18,8 +18,10 @@ RUN rustup show active-toolchain || rustup toolchain install ARG CRATES="kio hang moq-auth moq-clock moq-flate moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-cli" +# Path specs, because the lockfile also has published copies of some workspace crates. RUN cargo fetch --locked \ - && cargo build --locked $(printf -- '-p %s ' $CRATES) --bins \ - && cargo test --locked --no-run $(printf -- '-p %s ' $CRATES) + && specs=$(printf -- '-p path+file:///src/rs/%s ' $CRATES) \ + && cargo build --locked $specs --bins \ + && cargo test --locked --no-run $specs ENV CARGO_NET_OFFLINE=true diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md new file mode 100644 index 00000000000..deb26a86027 --- /dev/null +++ b/.oss-scanner/threat_model.md @@ -0,0 +1,53 @@ +# Threat model: moq + +## What this project does and where untrusted input enters + +moq (Media over QUIC) is a live media pub/sub protocol stack. `moq-relay` is a public server: clients connect over QUIC (WebTransport or raw QUIC) or WebSocket, publish broadcasts made of tracks, groups and frames, and subscribe to other clients' broadcasts through the relay's cache and fan-out. Relays also connect to each other to form a cluster. The `moq` CLI (`moq-cli`) publishes and consumes media and runs ingest gateways (RTMP, RTSP, SRT, WebRTC WHIP/WHEP, HLS/DASH) that translate other protocols into MoQ. + +Treat everything a peer sends as hostile, before and after authentication: + +- **QUIC**: `moq-quic` is our sans-IO QUIC state machine (forked from quinn-proto). Packets, frames, transport parameters, stream and flow-control state, and handshake data all arrive before any authorization. +- **The MoQ wire protocol** in `moq-net`: SETUP and version negotiation, then control and data messages for both moq-lite (`src/lite`) and the IETF moq-transport drafts (`src/ietf`). This covers varints, paths and path patterns, announce, subscribe, fetch, group and object headers, priorities, and the timing and ordering of all of them. +- **WebSocket and HTTP** on the relay's `[web]` listeners: the upgrade, the public `/announced`, `/fetch` and `/certificate.sha256` endpoints, and query strings. +- **Authorization inputs**: the JWT (`moq-auth`), the SETUP token, the dialed path and query, and the relay's handling of grants (root, publish and subscribe pattern unions, mounts, expiry, revalidation). +- **Media payloads**: catalogs (`hang`, `moq-msf`, JSON in `moq-json`) and containers and codecs parsed by `moq-mux` (fMP4, MPEG-TS, FLV, MKV, LOC, and the H.264, H.265, AV1, VP8, VP9, AAC, Opus and FLAC bitstream parsers). A publisher controls these bytes, and the relay or a subscriber may parse them. +- **Ingest gateways**: RTMP (`moq-rtmp`), RTSP (`moq-rtsp`), SRT (`moq-srt`), WebRTC and ICE/STUN (`moq-rtc`, `moq-ice`), and HLS playlists and segments (`moq-hls`). +- **Peer relays** in a cluster are authenticated but should not be able to break a node beyond what their grant allows. + +A design rule of the project: whatever a peer sends, the memory, CPU, and state it makes the other side hold must be bounded. A peer that can grow relay memory or CPU without bound, past the configured per-session limits (`rs/moq-relay/src/limits.rs`), is a bug even when it takes many messages to do. + +## Components that matter most / least + +Most important, in this order: + +1. `rs/moq-relay` and the crates it serves the network with: `rs/moq-net`, `rs/moq-quic`, `rs/moq-tokio`, `rs/moq-sock`, `rs/moq-auth`, `rs/moq-pattern`. +2. Authorization: a session publishing, subscribing, or seeing announcements outside its grant, or reaching another root (tenant) through path tricks, revalidation, mounts, or cluster links. +3. `rs/moq-mux` and `rs/hang`: container, codec, and catalog parsing of publisher-controlled bytes. +4. The ingest gateways: `rs/moq-rtmp`, `rs/moq-rtsp`, `rs/moq-srt`, `rs/moq-rtc`, `rs/moq-ice`, `rs/moq-hls`. +5. `rs/moq-cli`, `rs/moq-flate`, `rs/moq-json`, `rs/moq-stats`, `rs/kio`, `rs/moq-clock`. + +`unsafe` is rare and worth reading closely where it appears: `rs/moq-quic`, `rs/moq-net/src/model`, `rs/moq-net/src/util/cell.rs`, `rs/moq-net/src/transport.rs`, and `rs/moq-relay/src/uring.rs`. + +Out of scope: `js/` and the other language bindings (`py/`, `swift/`, `kt/`, `go/`, `dart/`, `cpp/`, `rs/moq-ffi`, `rs/moq-c`, `rs/moq-wasm`), capture and encode crates that read local devices (`moq-video`, `moq-v4l`, `moq-nvenc`, `moq-audio`, `moq-transcode`, `moq-gst`, `moq-boy`), `demo/`, `bench/`, `test/`, `infra/`, `doc/`, `drafts/`, and CI configuration. A flaw that lies wholly inside a dependency (quinn, rustls, aws-lc, tokio, hyper, str0m) belongs upstream unless our use of it makes it reachable. + +## How to exercise it + +The image is offline, with every crate fetched and `CARGO_NET_OFFLINE` set. The debug build of the in-scope crates, their test binaries, and the `moq-relay` and `moq` binaries are already built in `/src/target/debug`. Debug builds keep overflow checks on. + +- **Tests**: `cargo test -p moq-net` (or any in-scope crate). Unit tests use the deterministic clock in `moq-clock` rather than wall time, so they are fast and reproducible. +- **A relay to attack**: `./target/debug/moq-relay demo/relay/localhost.toml` listens on UDP and TCP `[::]:4443` with a self-signed certificate and anonymous access to every path. For authorization testing, grant a narrow anonymous pattern with `[auth] public_subscribe` / `public_publish`, or run the reference auth server (`moq auth generate`, `moq auth sign`, `moq auth serve`, then `[auth] url`; see `doc/bin/cli.md`) and try to escape a signed token's root and patterns. `doc/bin/relay/` documents the config, auth, cluster, and HTTP endpoints. +- **A client**: `./target/debug/moq --help` publishes, subscribes, fetches, and lists announcements against a relay. `curl http://localhost:4443/announced/` and `curl http://localhost:4443/fetch//` hit the HTTP endpoints. +- **Fuzz harnesses**: `rs/moq-net/fuzz` and `rs/moq-quic/fuzz` hold cargo-fuzz targets for the wire codecs and the QUIC state machine. cargo-fuzz and a nightly toolchain are not in the image, but the targets show the parser entry points. + +## How you rate severity + +- **Critical**: memory corruption or code execution reachable by an unauthenticated peer; any way to publish to, subscribe to, or enumerate paths outside a session's grant, including reaching another root. +- **High**: memory corruption that needs an authenticated session; a panic, abort, deadlock, or unbounded memory or CPU growth in `moq-relay` that one unauthenticated peer can trigger, since it takes down every session on the node. +- **Medium**: the same relay denial of service when it needs an authenticated session; resource use that exceeds the configured limits by a large constant factor; a panic in a gateway or parser on publisher-controlled media. +- **Low**: a crash or hang in a client (`moq` CLI, a subscriber) caused by a malicious relay or publisher; leaking non-secret metadata. + +Not a vulnerability: bandwidth exhaustion by simply sending a lot of data within limits, generous defaults an operator can lower, the anonymous `**` grant in `demo/relay/localhost.toml`, and plain-HTTP token exposure (documented as dev-only). + +## How reports and patches should look + +Give the smallest reproducer: a Rust test against the in-crate API or a sequence of wire bytes, plus the command that triggers it. Patches should fix the root cause and add a regression test, rather than add a retry, sleep, or timeout. From 9f86b035c125b994b5a632b1a3f01067b597ec65 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 19 Oct 2026 19:16:54 -0700 Subject: [PATCH 3/8] chore: run OSS Scanner tests with nextest, as CI does Co-Authored-By: Claude Opus 5.5 --- .oss-scanner/Dockerfile | 5 ++++- .oss-scanner/threat_model.md | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile index 64d4db41509..b59795c77fd 100644 --- a/.oss-scanner/Dockerfile +++ b/.oss-scanner/Dockerfile @@ -14,7 +14,10 @@ COPY . /src WORKDIR /src # rust-toolchain.toml pins the toolchain; rustup installs it on first use. -RUN rustup show active-toolchain || rustup toolchain install +# CI runs tests with nextest, one process per test, and some tests rely on that isolation. +RUN rustup show active-toolchain || rustup toolchain install \ + && curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C "$CARGO_HOME/bin" \ + && cargo nextest --version ARG CRATES="kio hang moq-auth moq-clock moq-flate moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-cli" diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md index deb26a86027..2dc1774fdd6 100644 --- a/.oss-scanner/threat_model.md +++ b/.oss-scanner/threat_model.md @@ -34,7 +34,7 @@ Out of scope: `js/` and the other language bindings (`py/`, `swift/`, `kt/`, `go The image is offline, with every crate fetched and `CARGO_NET_OFFLINE` set. The debug build of the in-scope crates, their test binaries, and the `moq-relay` and `moq` binaries are already built in `/src/target/debug`. Debug builds keep overflow checks on. -- **Tests**: `cargo test -p moq-net` (or any in-scope crate). Unit tests use the deterministic clock in `moq-clock` rather than wall time, so they are fast and reproducible. +- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. Unit tests use the deterministic clock in `moq-clock` rather than wall time, so they are fast and reproducible. - **A relay to attack**: `./target/debug/moq-relay demo/relay/localhost.toml` listens on UDP and TCP `[::]:4443` with a self-signed certificate and anonymous access to every path. For authorization testing, grant a narrow anonymous pattern with `[auth] public_subscribe` / `public_publish`, or run the reference auth server (`moq auth generate`, `moq auth sign`, `moq auth serve`, then `[auth] url`; see `doc/bin/cli.md`) and try to escape a signed token's root and patterns. `doc/bin/relay/` documents the config, auth, cluster, and HTTP endpoints. - **A client**: `./target/debug/moq --help` publishes, subscribes, fetches, and lists announcements against a relay. `curl http://localhost:4443/announced/` and `curl http://localhost:4443/fetch//` hit the HTTP endpoints. - **Fuzz harnesses**: `rs/moq-net/fuzz` and `rs/moq-quic/fuzz` hold cargo-fuzz targets for the wire codecs and the QUIC state machine. cargo-fuzz and a nightly toolchain are not in the image, but the targets show the parser entry points. From 85777dcc26b10eecbd3ed216c20627bf764bc478 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 19 Oct 2026 19:31:38 -0700 Subject: [PATCH 4/8] chore: prebuild the relay's io_uring backend for the OSS Scanner Co-Authored-By: Claude Opus 5.5 --- .oss-scanner/Dockerfile | 7 ++++--- .oss-scanner/threat_model.md | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile index b59795c77fd..b4bae2d8939 100644 --- a/.oss-scanner/Dockerfile +++ b/.oss-scanner/Dockerfile @@ -19,12 +19,13 @@ RUN rustup show active-toolchain || rustup toolchain install \ && curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C "$CARGO_HOME/bin" \ && cargo nextest --version -ARG CRATES="kio hang moq-auth moq-clock moq-flate moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-cli" +ARG CRATES="kio hang moq-auth moq-clock moq-flate moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-cli" # Path specs, because the lockfile also has published copies of some workspace crates. +# io-uring compiles the relay's io_uring QUIC workers (`--runtime-io-uring`), which the default features leave out. RUN cargo fetch --locked \ && specs=$(printf -- '-p path+file:///src/rs/%s ' $CRATES) \ - && cargo build --locked $specs --bins \ - && cargo test --locked --no-run $specs + && cargo build --locked $specs --features moq-relay/io-uring --bins \ + && cargo test --locked --no-run $specs --features moq-relay/io-uring ENV CARGO_NET_OFFLINE=true diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md index 2dc1774fdd6..c9786f3cf2d 100644 --- a/.oss-scanner/threat_model.md +++ b/.oss-scanner/threat_model.md @@ -20,7 +20,7 @@ A design rule of the project: whatever a peer sends, the memory, CPU, and state Most important, in this order: -1. `rs/moq-relay` and the crates it serves the network with: `rs/moq-net`, `rs/moq-quic`, `rs/moq-tokio`, `rs/moq-sock`, `rs/moq-auth`, `rs/moq-pattern`. +1. `rs/moq-relay` and the crates it serves the network with: `rs/moq-net`, `rs/moq-quic`, `rs/moq-tokio`, `rs/moq-uring`, `rs/moq-sock`, `rs/moq-auth`, `rs/moq-pattern`. 2. Authorization: a session publishing, subscribing, or seeing announcements outside its grant, or reaching another root (tenant) through path tricks, revalidation, mounts, or cluster links. 3. `rs/moq-mux` and `rs/hang`: container, codec, and catalog parsing of publisher-controlled bytes. 4. The ingest gateways: `rs/moq-rtmp`, `rs/moq-rtsp`, `rs/moq-srt`, `rs/moq-rtc`, `rs/moq-ice`, `rs/moq-hls`. @@ -34,8 +34,8 @@ Out of scope: `js/` and the other language bindings (`py/`, `swift/`, `kt/`, `go The image is offline, with every crate fetched and `CARGO_NET_OFFLINE` set. The debug build of the in-scope crates, their test binaries, and the `moq-relay` and `moq` binaries are already built in `/src/target/debug`. Debug builds keep overflow checks on. -- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. Unit tests use the deterministic clock in `moq-clock` rather than wall time, so they are fast and reproducible. -- **A relay to attack**: `./target/debug/moq-relay demo/relay/localhost.toml` listens on UDP and TCP `[::]:4443` with a self-signed certificate and anonymous access to every path. For authorization testing, grant a narrow anonymous pattern with `[auth] public_subscribe` / `public_publish`, or run the reference auth server (`moq auth generate`, `moq auth sign`, `moq auth serve`, then `[auth] url`; see `doc/bin/cli.md`) and try to escape a signed token's root and patterns. `doc/bin/relay/` documents the config, auth, cluster, and HTTP endpoints. +- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. Add `--features moq-relay/io-uring` for the relay and `moq-uring` so the io_uring backend's tests run (they skip on a kernel without io_uring support). Unit tests use the deterministic clock in `moq-clock` rather than wall time, so they are fast and reproducible. +- **A relay to attack**: `./target/debug/moq-relay demo/relay/localhost.toml` listens on UDP and TCP `[::]:4443` with a self-signed certificate and anonymous access to every path. The binary is built with io_uring support; pass `--runtime-io-uring` to serve QUIC from the io_uring workers in `rs/moq-uring` and `rs/moq-relay/src/uring.rs` instead of tokio. For authorization testing, grant a narrow anonymous pattern with `[auth] public_subscribe` / `public_publish`, or run the reference auth server (`moq auth generate`, `moq auth sign`, `moq auth serve`, then `[auth] url`; see `doc/bin/cli.md`) and try to escape a signed token's root and patterns. `doc/bin/relay/` documents the config, auth, cluster, and HTTP endpoints. - **A client**: `./target/debug/moq --help` publishes, subscribes, fetches, and lists announcements against a relay. `curl http://localhost:4443/announced/` and `curl http://localhost:4443/fetch//` hit the HTTP endpoints. - **Fuzz harnesses**: `rs/moq-net/fuzz` and `rs/moq-quic/fuzz` hold cargo-fuzz targets for the wire codecs and the QUIC state machine. cargo-fuzz and a nightly toolchain are not in the image, but the targets show the parser entry points. From 006923daca55c182e5a315e97fd3ccd44945b547 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 19 Oct 2026 19:40:25 -0700 Subject: [PATCH 5/8] chore: format the OSS Scanner threat model Co-Authored-By: Claude Opus 5.5 --- .oss-scanner/threat_model.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md index c9786f3cf2d..4b56e49ccae 100644 --- a/.oss-scanner/threat_model.md +++ b/.oss-scanner/threat_model.md @@ -34,8 +34,8 @@ Out of scope: `js/` and the other language bindings (`py/`, `swift/`, `kt/`, `go The image is offline, with every crate fetched and `CARGO_NET_OFFLINE` set. The debug build of the in-scope crates, their test binaries, and the `moq-relay` and `moq` binaries are already built in `/src/target/debug`. Debug builds keep overflow checks on. -- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. Add `--features moq-relay/io-uring` for the relay and `moq-uring` so the io_uring backend's tests run (they skip on a kernel without io_uring support). Unit tests use the deterministic clock in `moq-clock` rather than wall time, so they are fast and reproducible. -- **A relay to attack**: `./target/debug/moq-relay demo/relay/localhost.toml` listens on UDP and TCP `[::]:4443` with a self-signed certificate and anonymous access to every path. The binary is built with io_uring support; pass `--runtime-io-uring` to serve QUIC from the io_uring workers in `rs/moq-uring` and `rs/moq-relay/src/uring.rs` instead of tokio. For authorization testing, grant a narrow anonymous pattern with `[auth] public_subscribe` / `public_publish`, or run the reference auth server (`moq auth generate`, `moq auth sign`, `moq auth serve`, then `[auth] url`; see `doc/bin/cli.md`) and try to escape a signed token's root and patterns. `doc/bin/relay/` documents the config, auth, cluster, and HTTP endpoints. +- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. Add `--features moq-relay/io-uring` for the relay and `moq-uring` so the io\_uring backend's tests run (they skip on a kernel without io\_uring support). Unit tests use the deterministic clock in `moq-clock` rather than wall time, so they are fast and reproducible. +- **A relay to attack**: `./target/debug/moq-relay demo/relay/localhost.toml` listens on UDP and TCP `[::]:4443` with a self-signed certificate and anonymous access to every path. The binary is built with io\_uring support; pass `--runtime-io-uring` to serve QUIC from the io\_uring workers in `rs/moq-uring` and `rs/moq-relay/src/uring.rs` instead of tokio. For authorization testing, grant a narrow anonymous pattern with `[auth] public_subscribe` / `public_publish`, or run the reference auth server (`moq auth generate`, `moq auth sign`, `moq auth serve`, then `[auth] url`; see `doc/bin/cli.md`) and try to escape a signed token's root and patterns. `doc/bin/relay/` documents the config, auth, cluster, and HTTP endpoints. - **A client**: `./target/debug/moq --help` publishes, subscribes, fetches, and lists announcements against a relay. `curl http://localhost:4443/announced/` and `curl http://localhost:4443/fetch//` hit the HTTP endpoints. - **Fuzz harnesses**: `rs/moq-net/fuzz` and `rs/moq-quic/fuzz` hold cargo-fuzz targets for the wire codecs and the QUIC state machine. cargo-fuzz and a nightly toolchain are not in the image, but the targets show the parser entry points. From 0b2ce3745dba5fcafdcfb16bcb0b6112de00a272 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 19 Oct 2026 19:46:43 -0700 Subject: [PATCH 6/8] chore: pick the nextest archive for the build architecture Co-Authored-By: Claude Opus 5.5 --- .oss-scanner/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile index b4bae2d8939..efb678063c9 100644 --- a/.oss-scanner/Dockerfile +++ b/.oss-scanner/Dockerfile @@ -16,7 +16,8 @@ WORKDIR /src # rust-toolchain.toml pins the toolchain; rustup installs it on first use. # CI runs tests with nextest, one process per test, and some tests rely on that isolation. RUN rustup show active-toolchain || rustup toolchain install \ - && curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C "$CARGO_HOME/bin" \ + && case "$(uname -m)" in aarch64) nextest=linux-arm ;; *) nextest=linux ;; esac \ + && curl -LsSf "https://get.nexte.st/latest/$nextest" | tar zxf - -C "$CARGO_HOME/bin" \ && cargo nextest --version ARG CRATES="kio hang moq-auth moq-clock moq-flate moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-cli" From c2501dd209783269781243f28bc98ef4f2764d92 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 19 Oct 2026 21:32:27 -0700 Subject: [PATCH 7/8] chore: run the OSS Scanner check nightly and spell out the security model Add `just oss-scanner`, which runs Anthropic's tools/check against a pushed ref, and an OSS Scanner workflow that nightly calls and pull requests run when the scanner files change. The threat model now lists the properties the relay must hold: bounded cost for untrusted input, encryption, authentication, multi-tenancy, cache integrity, cluster trust, and amplification. moq-e2ee joins the build set. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/nightly.yml | 3 ++ .github/workflows/oss-scanner.yml | 48 +++++++++++++++++++++++++++++++ .oss-scanner/Dockerfile | 2 +- .oss-scanner/threat_model.md | 21 ++++++++++---- justfile | 5 ++++ sh/oss-scanner.sh | 34 ++++++++++++++++++++++ 6 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/oss-scanner.yml create mode 100755 sh/oss-scanner.sh diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 39f0f083cae..e13cc43224c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -46,6 +46,9 @@ jobs: x11: uses: ./.github/workflows/x11.yml + oss-scanner: + uses: ./.github/workflows/oss-scanner.yml + # Each independent workload gets its own hour. Each benchmark group keeps one # build environment, so a benchmark reuses the dependencies its group already # compiled. The Rust benchmarks outgrew one hour, so they split by harness: diff --git a/.github/workflows/oss-scanner.yml b/.github/workflows/oss-scanner.yml new file mode 100644 index 00000000000..26ab6d575d8 --- /dev/null +++ b/.github/workflows/oss-scanner.yml @@ -0,0 +1,48 @@ +name: OSS Scanner + +# Builds .oss-scanner/ with Anthropic's own tools/check, so the image the +# scanner builds from main keeps working. Nightly, because a new native +# dependency in any in-scope crate or a rule change upstream breaks it without +# touching these files; on pull requests only when the files themselves change. +# +# Outside Nix, like android.yml: the dev shell's store would compete for the +# disk the ~20 GB scanner image needs, and the image brings its own toolchain. +on: + workflow_call: + pull_request: + paths: + - ".oss-scanner/**" + - "sh/oss-scanner.sh" + - ".github/workflows/oss-scanner.yml" + +permissions: + contents: read + +concurrency: + group: oss-scanner-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + name: Build + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/just + + - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21 + with: + tool: uv + + # tools/check clones the repository anonymously, so point it at the pushed + # head: the PR's own repository and branch, or this branch on a schedule. + - name: tools/check + run: just oss-scanner "$REF" "$REPO" + env: + REF: ${{ github.head_ref || github.ref_name }} + REPO: ${{ github.event.pull_request.head.repo.html_url || format('{0}/{1}', github.server_url, github.repository) }} diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile index efb678063c9..5b368eed864 100644 --- a/.oss-scanner/Dockerfile +++ b/.oss-scanner/Dockerfile @@ -20,7 +20,7 @@ RUN rustup show active-toolchain || rustup toolchain install \ && curl -LsSf "https://get.nexte.st/latest/$nextest" | tar zxf - -C "$CARGO_HOME/bin" \ && cargo nextest --version -ARG CRATES="kio hang moq-auth moq-clock moq-flate moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-cli" +ARG CRATES="kio hang moq-auth moq-clock moq-e2ee moq-flate moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-cli" # Path specs, because the lockfile also has published copies of some workspace crates. # io-uring compiles the relay's io_uring QUIC workers (`--runtime-io-uring`), which the default features leave out. diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md index 4b56e49ccae..ffadfcecf18 100644 --- a/.oss-scanner/threat_model.md +++ b/.oss-scanner/threat_model.md @@ -14,7 +14,18 @@ Treat everything a peer sends as hostile, before and after authentication: - **Ingest gateways**: RTMP (`moq-rtmp`), RTSP (`moq-rtsp`), SRT (`moq-srt`), WebRTC and ICE/STUN (`moq-rtc`, `moq-ice`), and HLS playlists and segments (`moq-hls`). - **Peer relays** in a cluster are authenticated but should not be able to break a node beyond what their grant allows. -A design rule of the project: whatever a peer sends, the memory, CPU, and state it makes the other side hold must be bounded. A peer that can grow relay memory or CPU without bound, past the configured per-session limits (`rs/moq-relay/src/limits.rs`), is a bug even when it takes many messages to do. +## Security properties the relay must hold + +The relay is deployed on the public internet as shared infrastructure: one process serves many unrelated tenants, most of them anonymous or holding a token from a third party's auth server. Attack these properties: + +- **Untrusted network input, bounded cost.** Whatever a peer sends, the memory, CPU, and state it makes the other side hold must be bounded. A peer that can grow relay memory or CPU without bound, past the configured per-session limits (`rs/moq-relay/src/limits.rs`), is a bug even when it takes many messages to do. Fan-out is the multiplier to look for: one publisher's bytes, or one subscriber's request, reaching many sessions or pinning cache. +- **Encryption.** Every transport is TLS 1.3 via rustls with aws-lc: QUIC and WebTransport, and WebSocket over `[web.https]`. Certificates are loaded from disk, issued by ACME (`rs/moq-relay/src/acme.rs`, TLS-ALPN-01), or self-signed and pinned by the fingerprint at `/certificate.sha256`. Check whether the relay accepts 0-RTT, and if it does, whether early data can be replayed. Plain `[web.http]` is a documented development option, not a finding. +- **Authentication.** Sessions are admitted by a JWT (`moq-auth`, which accepts HMAC, RSA, ECDSA and EdDSA keys, so algorithm confusion and key selection are in scope), by an external auth server over HTTP (`doc/bin/relay/auth.md`), by a verified client certificate weighed by that server, or by a static anonymous grant. Expiry, revalidation, and in-band renewal must never extend a grant past what the server issued, and a failure to reach the auth server must refuse rather than admit. +- **Multi-tenancy.** A grant's `root` scopes a session to one subtree; `mounts` add read-only views. A session must never publish, subscribe, receive announcements, fetch, or see stats outside its grant, whether through path normalization, pattern matching (`moq-pattern`), the HTTP endpoints, cluster forwarding, or a revalidation that changes the grant mid-session. One tenant must not be able to degrade another beyond its fair share, for example by exhausting a shared cache or a shared connection limit. +- **Cache integrity.** The relay caches and forwards groups by broadcast, track, and group. A publisher must not be able to overwrite or inject into a broadcast it was not granted, and a subscriber must never receive one tenant's data under another tenant's name. +- **Cluster trust.** Peer relays authenticate with tokens or mTLS and get broader rights than clients. A relay dials only configured or discovered peers, never a URL learned from an announcement. LAN discovery over mDNS (`[cluster.lan]`) is open to anyone on the network unless `secret` is set, which is documented; with `secret` set, an unkeyed host must not be able to join. +- **Amplification and reflection.** QUIC's anti-amplification limit and address validation, the opt-in public STUN responder (`rs/moq-relay/src/stun.rs`), and ICE in the WebRTC gateway all answer unauthenticated UDP. A response larger than the request toward a spoofed source is a finding. +- **End-to-end encryption.** `moq-e2ee` encrypts groups, datagrams, and track names so a relay cannot read them. A flaw in its construction (nonce reuse, a key or name leaking to the relay, a forgeable group) is in scope. ## Components that matter most / least @@ -24,7 +35,7 @@ Most important, in this order: 2. Authorization: a session publishing, subscribing, or seeing announcements outside its grant, or reaching another root (tenant) through path tricks, revalidation, mounts, or cluster links. 3. `rs/moq-mux` and `rs/hang`: container, codec, and catalog parsing of publisher-controlled bytes. 4. The ingest gateways: `rs/moq-rtmp`, `rs/moq-rtsp`, `rs/moq-srt`, `rs/moq-rtc`, `rs/moq-ice`, `rs/moq-hls`. -5. `rs/moq-cli`, `rs/moq-flate`, `rs/moq-json`, `rs/moq-stats`, `rs/kio`, `rs/moq-clock`. +5. `rs/moq-e2ee`, `rs/moq-cli`, `rs/moq-flate`, `rs/moq-json`, `rs/moq-stats`, `rs/kio`, `rs/moq-clock`. `unsafe` is rare and worth reading closely where it appears: `rs/moq-quic`, `rs/moq-net/src/model`, `rs/moq-net/src/util/cell.rs`, `rs/moq-net/src/transport.rs`, and `rs/moq-relay/src/uring.rs`. @@ -41,9 +52,9 @@ The image is offline, with every crate fetched and `CARGO_NET_OFFLINE` set. The ## How you rate severity -- **Critical**: memory corruption or code execution reachable by an unauthenticated peer; any way to publish to, subscribe to, or enumerate paths outside a session's grant, including reaching another root. -- **High**: memory corruption that needs an authenticated session; a panic, abort, deadlock, or unbounded memory or CPU growth in `moq-relay` that one unauthenticated peer can trigger, since it takes down every session on the node. -- **Medium**: the same relay denial of service when it needs an authenticated session; resource use that exceeds the configured limits by a large constant factor; a panic in a gateway or parser on publisher-controlled media. +- **Critical**: memory corruption or code execution reachable by an unauthenticated peer; any way to publish to, subscribe to, or enumerate paths outside a session's grant, including reaching another root; accepting a forged, tampered, or expired credential; reading or altering another session's traffic, or `moq-e2ee` plaintext, without its keys. +- **High**: memory corruption that needs an authenticated session; a panic, abort, deadlock, or unbounded memory or CPU growth in `moq-relay` that one unauthenticated peer can trigger, since it takes down every session on the node; one tenant serving data under another tenant's broadcast name. +- **Medium**: the same relay denial of service when it needs an authenticated session; resource use that exceeds the configured limits by a large constant factor; a panic in a gateway or parser on publisher-controlled media; UDP amplification toward a spoofed address; an unkeyed host joining a `secret`-protected LAN cluster. - **Low**: a crash or hang in a client (`moq` CLI, a subscriber) caused by a malicious relay or publisher; leaking non-secret metadata. Not a vulnerability: bandwidth exhaustion by simply sending a lot of data within limits, generous defaults an operator can lower, the anonymous `**` grant in `demo/relay/localhost.toml`, and plain-HTTP token exposure (documented as dev-only). diff --git a/justfile b/justfile index 0a5b1309523..62f0c3f5789 100644 --- a/justfile +++ b/justfile @@ -111,6 +111,11 @@ ci-select $JOB $BASE="": fix $BASE="": sh/dispatch.sh fix "$BASE" +# Build .oss-scanner/ with Anthropic's OSS Scanner tools/check: `just oss-scanner [REF] [REPO]`. REF must be pushed. +[positional-arguments] +oss-scanner *args: + sh/oss-scanner.sh "$@" + # Build the packages. build: just js build diff --git a/sh/oss-scanner.sh b/sh/oss-scanner.sh new file mode 100755 index 00000000000..ac62dafd61d --- /dev/null +++ b/sh/oss-scanner.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Build .oss-scanner/ the way Anthropic's OSS Scanner does: sh/oss-scanner.sh [REF] [REPO] +# +# Runs the scanner's own tools/check from its main branch, so a change on +# either side (a new native dependency here, a new rule there) fails here +# instead of in an email to security@moq.dev. tools/check clones REPO +# anonymously at REF, so REF must be pushed; it defaults to this branch. +set -euo pipefail + +ref=${1:-$(git rev-parse --abbrev-ref HEAD)} +repo=${2:-https://github.com/moq-dev/moq} + +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT + +git clone --quiet --depth 1 https://github.com/anthropics/oss-scanner "$work/oss-scanner" + +# The enrolment's project.yaml lives in anthropics/oss-scanner; this mirrors it +# with the ref under test. +mkdir -p "$work/project/moq" +cat >"$work/project/moq/project.yaml" </dev/null 2>&1 || true +exit "$status" From db63cb0582e082008faa88dc0b67d81885b3eb1d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 19 Oct 2026 23:03:00 -0700 Subject: [PATCH 8/8] fix(oss-scanner): remove every check stage image on exit tools/check removes its target and tools images only after a successful build, so a failed run left up to ~20 GB behind. The EXIT trap now removes all three stages, which also covers an interrupted run. Co-Authored-By: Claude Opus 5.5 --- sh/oss-scanner.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sh/oss-scanner.sh b/sh/oss-scanner.sh index ac62dafd61d..9af839920d2 100755 --- a/sh/oss-scanner.sh +++ b/sh/oss-scanner.sh @@ -11,7 +11,9 @@ ref=${1:-$(git rev-parse --abbrev-ref HEAD)} repo=${2:-https://github.com/moq-dev/moq} work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT +# tools/check keeps the finished image for its shell, and a failed build skips +# its own cleanup of the stages before it; at ~20 GB they would fill the disk. +trap 'docker image rm --force oss-scanner-check/{target,tools,built}:moq >/dev/null 2>&1 || true; rm -rf "$work"' EXIT git clone --quiet --depth 1 https://github.com/anthropics/oss-scanner "$work/oss-scanner" @@ -26,9 +28,4 @@ dockerfile: .oss-scanner/Dockerfile threat_model: .oss-scanner/threat_model.md EOF -status=0 -uv run --no-project --with pyyaml python3 "$work/oss-scanner/tools/check" --no-shell --dir "$work/check" "$work/project/moq" || status=$? - -# tools/check keeps the finished image for its shell; at ~20 GB it would fill the disk. -docker image rm --force oss-scanner-check/built:moq >/dev/null 2>&1 || true -exit "$status" +uv run --no-project --with pyyaml python3 "$work/oss-scanner/tools/check" --no-shell --dir "$work/check" "$work/project/moq"