Skip to content

fix(qmux): reject send controls for unopened local streams - #484

Merged
kixelated merged 4 commits into
mainfrom
quest/a0/qmux-stream-state
Nov 8, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/a0/qmux-stream-state

Conversation

@kixelated

@kixelated kixelated commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Rust and TypeScript QMux silently ignored MAX_STREAM_DATA and STOP_SENDING for locally initiated stream IDs that had never been allocated. Both implementations now reject those IDs against the next allocation index for the stream direction, as required by RFC 9000 §19.5 and §19.10. TypeScript also rejects STOP_SENDING on receive-only streams.

Both handlers share private validation. TypeScript ignores late input after session closure, including controls trailing APPLICATION_CLOSE in a record. Rust reads the allocation counter before taking the streams lock. Controls on retired local streams remain ignored, and peer-initiated stream handling is preserved. The completed quest and all links to it are removed.

Compatibility and choices

  • No public API, error variants, wire encoding, dependencies, or package versions change. Well-behaved peers retain their behavior.
  • Reused Rust Error::InvalidStreamId and TypeScript's existing protocol-violation path. CONNECTION_CLOSE continues to carry code 1002; per-error RFC wire codes remain out of scope.
  • Defined unopened IDs using the existing independent uni/bidi allocation counters, including before the first allocation and after previous streams retire.
  • Scripted-peer coverage spans QMux drafts 00, 01, and 02, plus legacy WebTransport STOP_SENDING, both endpoint roles, both directions, the next and higher unopened IDs, active credit updates and STOP_SENDING, retired streams, and preserved peer-initiated behavior. Rust uses paused time; the new TypeScript waits observe output directly without sleeps.
  • The shared STOP_SENDING validation also covers legacy WebTransport. Legacy MAX_STREAM_DATA is already rejected by its decoder because that frame is unsupported.
  • Kept draft-02 receive-offset and terminal-size tolerance separate. No backport or merge.
  • No open decisions.

Validation

  • Before the fix, the Rust unopened-stream regression failed because QMux00 accepted MAX_STREAM_DATA for an unopened local uni stream. TypeScript regressions timed out because unopened MAX_STREAM_DATA and receive-only STOP_SENDING left the session open.
  • Focused Rust QMux suite: 165 unit tests, 41 integration tests, and 3 doctests passed.
  • Focused TypeScript QMux suite: 309 tests passed.
  • Final pinned Nix-shell just fix, just check, and just test passed, covering native/WASM builds, feature combinations, documentation tests, TypeScript tests, the Node binding, and both JS/Rust interop directions.
  • The final focused Rust stream-control regressions passed with wakeup-based output waits and paused-time failure bounds.
  • The post-close regression fails without the TypeScript guards with an unexpected protocol-error log, then passes with them.
  • quest check --base origin/main and git diff --check passed.

Review

Round 2: Claude Code (claude-opus-5-5, medium effort) reviewed head 160ce1b016225af001ccd7aa45bb950383976890 against origin/main. No findings remain.

All five low-severity round-1 findings are addressed:

  • Fixed paused-clock test spin waits with writer notifications and a RESET_STREAM output barrier.
  • Fixed post-close frame processing, with a regression proving stable closure, no misleading protocol log, and no extra close timer.
  • Added legacy WebTransport STOP_SENDING coverage across roles, directions, and stream states. MAX_STREAM_DATA is unsupported in that wire format and already fails in the decoder.
  • Added receive-only MAX_STREAM_DATA coverage in both endpoint roles.
  • Fixed FakePeer's legacy framing support.

Follow-ups

None identified.

(Written by GPT-6.1 Sol with xhigh)

@kixelated kixelated changed the title Refuse QMux control frames for unopened local streams fix(qmux): reject send controls for unopened local streams Nov 7, 2026
kixelated and others added 2 commits November 7, 2026 00:32
Validate send-control stream IDs against direction-specific allocation counters before looking up active state. Preserve retired and peer-initiated stream behavior, and apply the missing TypeScript STOP_SENDING direction check.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Ignore late TypeScript input after session closure. Replace paused-time spin waits with output notifications and cover legacy STOP_SENDING plus server receive-only MAX_STREAM_DATA.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
@kixelated
kixelated marked this pull request as ready for review November 7, 2026 08:46
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0e310ed-f0d7-4d96-a0da-14959dc9ab7d
Commits

Reviewing files that changed from the base of the PR and between 9686334 and 09c8e8d.

Files selected for processing: 9

  • js/qmux/README.md
  • js/qmux/src/session.test.ts
  • js/qmux/src/session.ts
  • quest/a0/README.md
  • quest/a0/qmux-max-streams-param.md
  • quest/a0/qmux-stream-state.md
  • rs/qmux/README.md
  • rs/qmux/src/credit.rs
  • rs/qmux/src/session.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T17:21:59.396285Z 09c8e8d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary:

(Written by Claude Opus 5.5)

@kixelated
kixelated merged commit 8b752de into main Nov 8, 2026
6 checks passed
@kixelated
kixelated deleted the quest/a0/qmux-stream-state branch November 8, 2026 17:46
@moq-bot moq-bot Bot mentioned this pull request Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant