Skip to content

refactor(moq-webrtc): run on upstream str0m instead of a vendored copy - #8963

Merged
kixelated merged 10 commits into
mainfrom
quest/m2/str0m-upstream
Nov 16, 2026
Merged

kixelated merged 10 commits into
mainfrom
quest/m2/str0m-upstream

Conversation

@kixelated

@kixelated kixelated commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

moq-webrtc runs on crates.io str0m 0.25 with rind as its crypto through rind-str0m 0.25.2 (and rind-dimpl 0.9.3 under it), and rs/moq-webrtc/src/vendor/ is gone: 100,590 deleted lines across 258 files, the 1.6 MB of packet captures included. Finishes quest/m2/str0m-upstream.md.

What differed between the vendored copy and 0.25

The quest asked for this report before the deletion. The first commit (25df4e88c2) builds against 0.25 with vendor/ still in place. Nothing the gateway needs is missing upstream, but three patches the vendored copy carried over str0m (found by review round 1) had to move to moq-webrtc's boundary, as did the data channel refusal.

  • API: one rename. RtcConfig::enable_opus takes a second use_red argument (RFC 2198 RED). It is passed false, which keeps today's offer. The 13 files only had their imports switched.
  • Crypto provider: with default-features = false, str0m has no provider of its own and panics in Rtc::build without one. session::rtc_config now sets rind-str0m's provider on every config. Two tests built an Rtc with Rtc::builder(), and they now use rtc_config too.
  • Data channels: 0.25 has no feature or setting that refuses one. accept_offer answers an offered m=application section accepted (port 9, in BUNDLE) and starts SCTP. To keep the decided behavior, sdp.rs takes each such section and its BUNDLE mid out of the offer text before str0m parses it, then puts each back into the answer at its index as m=application 0 <proto> <fmts> with c= and a=mid. That is the answer the vendored copy gave. sctp-proto is still compiled in.
  • ICE's first timeout: the vendored poll_timeout (added in moq-dev/moq#8163) asked for an immediate timeout once ICE had a remote candidate. Upstream ICE has no clock and asks for no timeout until its first one. So an answerer that hears no checks and has no DTLS or media timer, such as one facing an ICE-lite peer, never sent a check. ice::Agent::new now feeds Input::Timeout(now) before draining.
  • Candidates on a rejected first section: str0m writes the answer's candidates only on the first section (src/change/sdp.rs:825), even when that section is rejected and out of BUNDLE. An example is WHEP audio offered first against a video-only broadcast. The vendored copy moved them (moq-dev/moq#8771). sdp::render_answer now moves them to the first accepted section.
  • A data channel carrying the BUNDLE transport: a max-bundle offer may put the shared ICE credentials, fingerprint, setup, and candidates only on its first section, with the media a=bundle-only. When that section is the data channel being refused, sdp::refuse_channels moves each of those attributes the rest of the offer lacks, and every candidate, to the session level, where str0m reads them.
  • DTLS 1.2: 0.25 defaults to DtlsVersion::Dtls12, and rind-str0m builds dimpl with new_12 for it. rtc_config now pins 1.2 explicitly, so a later default of Auto or 1.3 can't change the wire unnoticed. Chrome negotiated DTLS 1.2 (FEFD) in the run below.
  • Typed DTLS timeout: 0.25 still flattens every dimpl error into CryptoError::Other(format!("DTLS error: {e}")) (src/dtls.rs:164, :182, :200, :207), though str0m-proto 0.8 has CryptoError::DtlsImpl. moq-webrtc's handling (RtcError::Dtls(_) before ICE connects reads as a timeout) works the same. quest/m3/webrtc/dtls-timeout.md now records this.
  • One b= per section: 0.25 still parses bw: Option<Bandwidth>, so the b=TIAS splice stays. quest/m4/webrtc-sdp-bandwidth.md records this.
  • Hostile-input fixes on str0m main after 0.25: these include zero-length TWCC chunks panicking (algesten/str0m#1143) and ICE candidates with port 0 (algesten/str0m#1148). The vendored copy (dc317173) lacked them too, so this is no regression. They arrive with the next str0m release through a plain cargo update.

Changes

  • Cargo.toml: adds str0m 0.25 (default features off, so aws-lc-rs stays out) and rind-str0m 0.25.2. Drops the workspace entries only the vendored copy used: aes, ccm, combine, fastrand, nom, once_cell, pcap-file, spki, subtle, and x509-cert. workspace-hack and nix/Cargo.nix are regenerated.
  • rs/moq-webrtc/Cargo.toml: depends on str0m and rind-str0m in place of the vendored stack's own dependencies. rind becomes a dev-dependency, used for the STUN signing in a mux test. The exclude of the captures and the cargo-shear ignored-paths are gone.
  • rs/moq-webrtc/src/vendor/ is deleted with its LICENSE-* files and its module lint allows.
  • rs/moq-webrtc/src/sdp.rs: parse_offer returns (SdpOffer, Refused), and render_answer takes the Refused back and moves candidates off a rejected first section. Five tests cover this:
    • A str0m offerer with a data channel accepts our answer.
    • An offer with LF line endings puts its data channel first.
    • A max-bundle offer's data channel carries the only transport.
    • Audio offered first is rejected, so the candidates land on the video section.
    • An offer carries only a data channel.
  • refuse_channels stays linear in the offer: the carried transport keys are decided once, BUNDLE mids are checked against sets, and every candidate moves (str0m dedupes them). a_flood_of_refused_transport_stays_linear feeds it 100k each of transport lines, candidates, and data channel sections. The workspace's now-unused arrayvec and crc entries are dropped too.
  • rs/moq-webrtc/src/ice/agent.rs: Agent::new starts ICE's clock. Covered by an ICE-lite test.
  • Docs: doc/bin/rtc.md no longer says the stack is vendored. .oss-scanner/threat_model.md, pyproject.toml's sdist exclude of the captures, and nix/crates.nix's filter for dimpl's validation data are updated to match.
  • Quests:
    • Deleted with the vendored copy: the vendor-sync child for it (and its paragraph in the vendor-sync README), the kio clock quest, the dead-API trim, the browser-only trim, and the #[path] bullet in test-inventory-followups.md.
    • Updated with what 0.25 does: DTLS waits for ICE, the typed DTLS timeout, several bandwidth lines, gateway fuzzing, and the WebRTC epic's "No SCTP" and "DTLS 1.2" lines.
    • quest/m0/rind-adapters.md now says rind 0.4 needs patch releases of rind-str0m and rind-dimpl too. Its vendored-file sites are gone.

Public API and wire

Public API: none. The vendor module was private.

Dependencies: str0m, str0m-proto, is, dimpl, sctp-proto, rind-str0m, and rind-dimpl join moq-webrtc's published graph, so cargo deny sees their advisories again. cargo deny check reports bans, licenses, and sources ok, and advisories fail only on zbus's unmaintained crates. That failure is already on main and is handled by moq-dev/moq#8966.

Wire: none toward browsers. An offered data channel is still answered rejected and left out of BUNDLE, and DTLS stays 1.2.

Decisions

Taken while the maintainer was away. A review can undo each one.

  • Refusing data channels in moq-webrtc's SDP text (rejected alternatives: answering them accepted, which leaves an SCTP association nobody reads, as the last release did; answering an offer that carries one with 400, which breaks clients that add a channel they never use; waiting for a str0m setting). The WebRTC epic expected "a configuration, not a deletion", and 0.25 has none. The boundary is where the epic puts what str0m does not fit. The str0m change that would retire this is drafted below.
  • Landing before rind 0.4 (rejected: carrying the adapter bump here). rind 0.4 isn't published. The crates.io rind-str0m and rind-dimpl require rind 0.3, the same as the workspace (Cargo.lock stays on rind 0.3.2). fix!: build against rind 0.4 and its corrected adapters #8432 now has to raise rind-str0m as well, and its quest says so. The rind 0.4 release needs rind-str0m and rind-dimpl patch releases.
  • Keeping moq_crypto::cpu::check() ahead of rind-str0m's own check, with an .expect on the second because it can't fail. The alternative was to add a rind_str0m::MissingFeature variant to the public Error. fix!: build against rind 0.4 and its corrected adapters #8432 removes both checks.
  • Pinning DTLS 1.2 rather than relying on str0m's default.

Upstream draft for the maintainer

Not filed. str0m is outside the orgs, and its reports wait on your approval (upstream reports). Draft:

Title: Option to answer an offered data channel rejected

A media-only server (a WHIP or WHEP endpoint, for example) has no use for data channels, but SdpApi::accept_offer always accepts an offered m=application section and starts SCTP over DTLS, which then runs for a peer nobody reads. Could RtcConfig get a switch (say set_data_channels(false)) under which accept_offer answers such a section rejected (port 0, left out of the BUNDLE group), never calls try_init_sctp, and refuses SdpApi::add_channel? Today we take the section out of the offer text before parsing it and splice a rejected section back into the answer.

Validation

  • cargo test -p moq-webrtc --all-features passes 88 tests. The three review-round tests each fail with their fix removed. The ICE-lite test ends with Timeout after the 30 s establish deadline, and the two SDP tests fail their asserts. whip_and_whep_round_trip_opus and the other gateway tests run a real DTLS handshake over str0m 0.25 with rind.
  • cargo clippy -p moq-webrtc -p moq-cli --all-targets --all-features -- -D warnings is clean.
  • just check passes on 206b3daf16. Earlier, the first run passed every module, all 12,655 Rust tests included, except a stale nix/Cargo.nix, which is now regenerated. On the rerun every module passed except test rs: four moq-net route::tests::handoff::path tests hit nextest's 60 s timeout on the loaded host (outside moq-webrtc, and they passed in the first run). They pass alone (35/35 of that group).
  • Manual Chrome run: the built moq-relay and moq binaries served import rtc --listen (WHIP) and export rtc --listen (WHEP) over Tailscale to Chrome 157 on another host. A page published a canvas track over WHIP, then played it back over WHEP, once with a data channel added to both offers and once without:
    • Both sessions reached connected.
    • The publisher encoded 90 frames in 3 s.
    • The player decoded 245 to 249 VP8 frames in about 8 s.
    • The transport was DTLS FEFD (1.2), TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, with SRTP AEAD_AES_256_GCM.
    • Each answer to a data-channel offer carried m=application 0 UDP/DTLS/SCTP webrtc-datachannel with a=group:BUNDLE 0, and Chrome accepted it.
    • After the review fixes, a rerun offered WHEP audio before video. The answer rejected the audio (m=audio 0, a=group:BUNDLE 1) with the candidate on the video section, and the player decoded 247 frames.
  • As a second, independent check of the refusal, a str0m offerer accepts the rejected answer in an_offered_data_channel_is_answered_rejected.
  • The quest also asked for moq-cli's WHIP and WHEP tests, but moq-cli has none (rs/moq-cli/src/rtc.rs has no tests). The binary run above stands in for them.

Follow-ups

  • No new quests. quest/m4/upstream-reports.md gains two candidates under the same approval rule as the other str0m candidates: the data channel switch drafted above, and the two str0m bugs moq-webrtc now works around (candidates on a rejected first section, and no ICE timeout before the first).
  • moq-dev/moq#8935 edits quest/m2/str0m-upstream.md, which this PR deletes, and both PRs touch session.rs and the server modules. moq-dev/moq#8949 touches rs/moq-webrtc/Cargo.toml and server/whip.rs. Whichever PR lands second merges the other and resolves the conflicts.

Models

Size: L
Implementer: Claude Code, claude-opus-5-5, high effort
Iterated: Claude Code, claude-opus-5-5 (iterate, S)

🤖 Generated with Claude Code

(Written by Opus 5.5 with high effort)

Review

Rewritten by quest review after each round.

  • Head: 71b993a

  • Base: origin/main at fc38289

  • Risk: high, The overall replacement changes SDP/ICE wire behavior relied on by WHIP senders and WHEP browsers, so interoperability failures could prevent connections until fixed or reverted.

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, xhigh effort

  • Session: 01a1e55e-d6d2-7212-8cf6-d55d6eead26c, round 4

  • Score: 10/10, The follow-up removes unused workspace dependencies and eliminates quadratic SDP filtering without introducing issues found by code inspection.

  • Raised the risk to high: The overall replacement changes SDP/ICE wire behavior relied on by WHIP senders and WHEP browsers, so interoperability failures could prevent connections until fixed or reverted.

  • Rounds: 4; first round 3 (high 1, medium 2); findings 3 (high 1, medium 2): fixed 3, refuted 0, open 0

  • Findings: none

kixelated and others added 6 commits November 16, 2026 08:42
Quest-Claim: d0ea5f783f48cb5b
The vendored copy stays in place for comparison; the next commit deletes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
About 98,600 lines and 1.6 MB of packet captures, with the workspace
dependencies only that copy used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
str0m 0.25 has no setting that refuses one: it accepts the m=application
section and runs SCTP nobody reads. The gateway takes those sections out
of the offer and puts each back rejected in the answer, as the vendored
copy answered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title moq-webrtc runs on upstream str0m feat(webrtc): moq-webrtc runs on upstream str0m Nov 16, 2026
@kixelated kixelated changed the title feat(webrtc): moq-webrtc runs on upstream str0m refactor(moq-webrtc): run on upstream str0m instead of a vendored copy Nov 16, 2026
kixelated and others added 3 commits November 16, 2026 09:31
Review round 1: the vendored copy started ICE's clock at once, put the
answer's candidates on the first accepted section, and (as a dropped data
channel's section) kept a max-bundle offer's shared transport. Upstream
does none of these, so the gateway does them at its boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…SRCs

Without that, a DTLS or media timer starts ICE's clock and the test passes
without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…idates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 16, 2026 17:40

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by review (OpenAI)

Reviewed 206b3daf1644a03f513040eb46dc4693c7b362fa. Moving back to upstream is worthwhile. P2, rs/moq-webrtc/src/sdp.rs:90–100: validate rejected application m-lines before stripping them. Append an application section such as m=application 9 UDP/DTLS/SCTP (missing its format) to an otherwise valid media offer. The shim removes the malformed section before str0m can reject it, then emits an equally malformed m=application 0 UDP/DTLS/SCTP in an otherwise successful answer. Reject malformed input as InvalidSdp instead of opening a session with an answer the peer cannot apply. Add this case and check that removed sections can't hide a duplicate MID shared with a retained section.

The first ICE timeout and accepted-section candidate moves address the observed integration gaps. Keep the real browser WHIP/WHEP check at the pin bump; I did not rerun it.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new data channel refusal in sdp.rs rewrites an untrusted offer before str0m sees it, and its transport hoisting does quadratic work in the number of offer lines.

Reviewed changes

Reviewed the switch from the vendored WebRTC stack to crates.io str0m 0.25 with rind-str0m, and the three behaviors that moved to moq-webrtc's boundary.

  • Upstream str0m + rind crypto: session::rtc_config installs rind_str0m::default_provider() (its CPU check is the same rind::cpu::check that moq_crypto::cpu::check runs, so the expect holds) and pins DTLS 1.2. enable_opus gains use_red = false.
  • ICE's first timeout: Agent::new feeds Input::Timeout(now) through the draining rtc_mut() guard, so an answerer facing an ICE-lite peer starts its checks. A new test covers this.
  • Data channel refusal: parse_offer takes m=application sections and their BUNDLE mids out of the offer text and hoists a bundled section's transport to session level. render_answer puts each section back as m=application 0 at its index. I checked the hoist against str0m 0.25: it reads creds, fingerprint, and setup from the session or any media line, and dedupes candidates with a HashSet (src/sdp/data.rs:62-104).
  • Candidates on a rejected first section: candidates_on_accepted moves them to the first accepted section.
  • Deletion and cleanup: removes vendor/, its workspace deps, the nix source filter, and the sdist exclude, and prunes the quests that only existed for the vendored copy.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread rs/moq-webrtc/src/sdp.rs Resolved
Comment thread Cargo.toml Resolved
Decide the carried transport keys once and check mids against sets, so a
flood of transport lines or data channel sections in one request costs
linear work. Every candidate moves to the session: str0m dedupes them.
Drop the workspace's arrayvec and crc entries, which nothing uses now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. Both earlier findings are fixed cleanly.

Reviewed changes

Reviewed 71b993a, which fixes the two findings from the prior Pullfrog review.

  • Linear refuse_channels: the carried transport keys are now worked out once into taken, which has at most 7 entries. Every candidate is hoisted without dedupe, since str0m already dedupes them. The BUNDLE group and the refused mids are now HashSets, so lookups per section and in the group rewrite are O(1). a_flood_of_refused_transport_stays_linear sends 100k each of transport lines, candidates, and sections, and checks that each non-candidate key is hoisted only once.
  • Workspace deps: removed the unused arrayvec and crc entries from root [workspace.dependencies].

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by review (OpenAI)
Head: 71b993a910e939063f95bf85eff4e949a4ab4a50

The latest delta removes the repeated scans in refuse_channels and preserves candidate order. The new test is a shim-only check, not a bound on offer handling: str0m 0.25 deduplicates parsed candidates, but ICE still scans its accumulated candidates and pairs as it adds distinct entries. Keep the linear claim scoped to the shim; if bounding request cost is a goal, add a candidate budget and test it through the offer/answer entry point.

The prior malformed application m-line and duplicate-MID validation finding is still open: those sections are still stripped before str0m parses the offer. Static review only.

@kixelated
kixelated added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 2443d20 Nov 16, 2026
5 checks passed
@kixelated
kixelated deleted the quest/m2/str0m-upstream branch November 16, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant