Skip to content

fix(relay)!: refuse connect.url and connect.tokens, and keep template tokens off cluster dials - #8927

Merged
moq-bot[bot] merged 3 commits into
mainfrom
quest/m2/relay-connect-keys
Nov 16, 2026
Merged

moq-bot[bot] merged 3 commits into
mainfrom
quest/m2/relay-connect-keys

Conversation

@kixelated

@kixelated kixelated commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m2/relay-connect-keys.md: the relay refuses the two [connect] keys it has no use for, and a cluster dial never carries the dial template's tokens.

Summary

  • The leak was real. connect.tokens (--connect-token, MOQ_CONNECT_TOKEN) rode every cluster dial: the first token in SETUP (or the URL query before lite-07), the rest on AUTH streams, to static peers and LAN peers alike. That contradicted doc/bin/relay/cluster.md's "a LAN peer is never handed cluster.token" in spirit: an undocumented second cluster credential went to every peer. Reproduced first by the new cluster::tests::cluster_dials_present_no_template_tokens, which failed on main for the static peer (SETUP token template-setup) and, with that assertion skipped, for the LAN peer too.
  • peer_client clears the template's tokens, so every cluster dial (and an embedder's Cluster::with_connect, including moq --cluster-*) presents only cluster.token or a peer's own token. Cluster::with_connect's doc says so.
  • Config::resolve refuses connect.url and connect.tokens by every spelling, naming the replacement:
    Error: moq-relay does not read these settings; remove them and try again:
      --connect / MOQ_CONNECT / connect.url: name the peers to dial with --cluster-connect / MOQ_CLUSTER_CONNECT / cluster.connect
      --connect-token / MOQ_CONNECT_TOKEN / connect.tokens: give peers a credential with --cluster-token / MOQ_CLUSTER_TOKEN / cluster.token, or a `token` on a cluster.connect peer
    
  • moq-relay --help no longer lists --connect or --connect-token: moq_relay::spec() now returns the derived spec with those two flags marked hidden (they still parse, so the refusal can name them). Every other [connect] key keeps working as the cluster dial template.
  • Docs: doc/bin/relay/config.md's [connect] section says where peers and credentials come from instead; doc/bin/cli.md says --connect-token goes only to --connect, never to a cluster peer.

Decisions

Taken unattended; each is reversible in review.

  • Hide the flags by patching the spec at runtime. usage-rs has no per-field hide on a #[usage(flatten)] site, and the quest rejected splitting moq_tokio::connect::Config. So spec() builds a copy of the root CommandMeta with hide set on the two flags, leaked once behind a OnceLock (about 20 lines). Its catch: it builds usage_rs metadata structs whose fields are public but #[doc(hidden)], so a usage-rs layout change could break it at compile time. Shell completion (Cli::completion_request) still uses the derived spec and may still offer the two flags. The alternative is to keep them in --help with the refusal as the only signal.
  • One message for both keys, in the resolve style rather than Deprecated. Deprecated renders old -> new under "renamed or removed", which reads wrong for a key that still exists for clients. The custom message names the flag, the variable, and the TOML key of each, plus the replacement.
  • A two-step migration for --client-connect is left alone. The released --client-connect is already refused with "-> --connect", which the relay now refuses in turn. Fixing it would mean special-casing moq-tokio's shared Deprecated entry for the relay. That flag configured nothing on the relay in the first place.

Validation

  • just check: passes (moq-relay and moq-cli tests, clippy, fmt, docs, quest).
  • Reproduction before the fix: cluster_dials_present_no_template_tokens failed with left: ("/static", None, Some(b"template-setup")), and the LAN-only run failed with LAN peer at /.cluster/lan-proof ... Some(b"template-setup"). After the fix it passes against a real lite-07 QUIC listener for both, and the same dial keeps the template's version and TLS settings.
  • New tests: connect_url_and_tokens_refuse_to_boot (flag, TOML, and the rest of [connect] still resolving), connect_env_refuses_to_boot (both env vars), and help_omits_the_refused_connect_flags.
  • On the built binary: moq-relay --connect https://peer.example/ exits 1 with the message above, MOQ_CONNECT_TOKEN=secret moq-relay does the same, a TOML with both prints both lines, and moq-relay --help lists --connect-bind but not --connect < or --connect-token. A relay with --connect-bind '[::]:0' --connect-timeout 5s still boots and serves.

Impact

  • Public API: none in signatures. Cluster::with_connect keeps its type and now ignores the template's tokens. moq_relay::spec() keeps its signature and returns the spec with the two flags hidden.
  • Config and CLI (breaking, moq-relay only): connect.url / --connect / MOQ_CONNECT and connect.tokens / --connect-token / MOQ_CONNECT_TOKEN stop startup. Migration: replace a peer URL with cluster.connect (--cluster-connect, MOQ_CLUSTER_CONNECT). Replace a credential with cluster.token (--cluster-token, a file read on every dial) or a token on a cluster.connect peer object.
  • Behavior (moq-cli and embedders): moq --connect-token no longer reaches cluster peers (--cluster-connect, --cluster-api-url, --cluster-lan). Give those --cluster-token.
  • Wire: none.

Caused by

  • moq-dev/moq#6177 - added connect.tokens as "credentials to present on every dial" without keeping them off the relay's cluster dial template, so they reached every cluster peer (found by person; pre-cut config audit).

Follow-ups

None.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, medium effort (arm A)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5 with medium effort)

Review

mechanical fix by codex, gpt-6.1-sol, medium effort: Merged base and re·solved quest/m2/README.md conflict preserving base's CPU link and PR's completed dial-keys removal; ran nix develop --command just ci base and git diff --check base HEAD; all passed. (head 98d498a)

Rewritten by quest review after each round.

  • Head: 941e841

  • Base: origin/main at 6488ce6

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

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

  • Session: 01a1e49b-efc8-7bf3-ac55-00be340f0f69, round 1

  • Score: 9/10, The changes are focused and include regression coverage, with no actionable regressions found, though tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 2 commits November 16, 2026 05:26
… tokens off cluster dials

The relay flattened the whole client fragment as its cluster dial template,
so connect.tokens rode SETUP and AUTH on every cluster dial, LAN peers
included, and connect.url was read by nothing. Config::resolve now refuses
both by every spelling, naming cluster.connect and cluster.token, and
peer_client clears the template's tokens so an embedder's Cluster gets the
same guarantee. --help stops listing the two flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title The relay refuses the two dial keys it has no use for fix(relay)!: refuse connect.url and connect.tokens, and keep template tokens off cluster dials Nov 16, 2026
@kixelated
kixelated marked this pull request as ready for review November 16, 2026 13:47
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 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: 9bf5b5fc-68c1-4cc8-98a5-5e82e47b2e3c
Commits

Reviewing files that changed from the base of the PR and between fc38289 and 98d498a.

Files selected for processing: 7

  • doc/bin/cli.md
  • doc/bin/relay/config.md
  • quest/m2/README.md
  • quest/m2/relay-config-names.md
  • quest/m2/relay-connect-keys.md
  • rs/moq-relay/src/cluster.rs
  • rs/moq-relay/src/config.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

pullfrog[bot]
pullfrog Bot previously approved these changes Nov 16, 2026

@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.

Reviewed changes

I reviewed the whole PR: the cluster dial token fix, the new config refusal and the hidden help flags, the tests, and the doc and quest updates.

  • Template tokens off cluster dials — peer_client clears connect.tokens on its cloned template. A static, API, or LAN peer now receives only cluster.token or that peer's own token, and the new cluster_dials_present_no_template_tokens test checks this against a real lite-07 listener.
  • Refuse connect.url / connect.tokens — Config::resolve calls check_connect(), which stops startup with one message that names the flag, the env var, and the TOML key, along with each replacement. The other [connect] keys still resolve.
  • Hidden help flags — moq_relay::spec() returns a cached copy of the spec with --connect and --connect-token marked hidden. Both flags still parse, so released_cli.rs still finds them and the refusal can name them.
  • Docs — doc/bin/relay/config.md explains where peers and credentials come from. doc/bin/cli.md says --connect-token never reaches a cluster peer.

I checked the relay's other reads of config.connect. The auth API reads only .tls, so clearing the tokens changes nothing there. No deployment config, nix module, or script in the repo sets either refused key; the --connect in bench/relay.sh belongs to moq-bench.

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

@kixelated
kixelated added this pull request to the merge queue Nov 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 16, 2026
@moq-bot

moq-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

quest land watch: the merge queue removed this pull request at 941e841 because it conflicts with main (merge_conflict).

The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs.

(written by quest land watch)

@moq-bot

moq-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

quest land watch: armed auto-merge on this pull request at 98d498a, so it joins the back of the merge queue once its required checks pass, with the land fixer's fix (codex, gpt-6.1-sol, medium effort): Merged base and re·solved quest/m2/README.md conflict preserving base's CPU link and PR's completed dial-keys removal; ran nix develop --command just ci base and git diff --check base HEAD; all passed..

(written by quest land watch)

@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: 98d498abf03daf5fddde3409701124bf28f55388

No blocker found. Clearing the template before building the peer client protects embedded callers as well as the relay binary, and the startup error names the replacement without printing the credential. I'd add a positive assertion that an authenticated static peer still receives its own configured token, while LAN receives neither it nor the template tokens.

At rollout, check for these two keys before replacing the binary: an old config with either populated now fails to start. If a deployment used template tokens while dialing peers that weren't meant to receive them, removing the setting doesn't revoke the old token; rotate it separately. Static review; I did not run the dial tests.

@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.

Reviewed changes

The only change since the last Pullfrog review is a merge from main. It touches no code.

  • Resolved the quest index conflict. quest/m2/README.md keeps main's new CPU quest link and drops the link to the finished relay-connect-keys.md quest. The relay code, tests, and docs are the same as in the commit approved earlier.

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

@moq-bot
moq-bot Bot added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 27b46ef Nov 16, 2026
8 checks passed
@moq-bot
moq-bot Bot deleted the quest/m2/relay-connect-keys branch November 16, 2026 22:26
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