Skip to content

fix(net): refuse chained and wildcard origin mounts in any order - #4362

Merged
kixelated merged 2 commits into
mainfrom
fix/origin-mount-validation
Sep 28, 2026
Merged

kixelated merged 2 commits into
mainfrom
fix/origin-mount-validation

Conversation

@kixelated

@kixelated kixelated commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Two gaps in origin::Producer::mount from #4271, both raised by Codex after merge:

  • P1: the overlap check compared a new mount's at and target only against existing mount points, never a new at against existing targets. So a -> z then z -> secret was accepted (reads of a/foo resolve to raw z/foo, the subtree the second mount shadows), while the reverse order was refused. Grant mounts apply from a BTreeMap, so whether a relay accepted a grant depended on key sort order.
  • P2: a mount point holding * (e.g. a grant key "*") was accepted, though no pattern can spell it, so it could never be announced downstream or authorized.

Fix

  • The overlap check is now symmetric: a new mount is Duplicate when its at overlaps an existing mount point or target, or its target overlaps an existing mount point. A mount whose own at and target overlap (a -> a/b, a/b -> a, a -> a) is Duplicate too. Acceptance no longer depends on insertion order. Mounts may still share a target (the aliasing case feat(net): read a subtree through an origin mount #4271 benchmarks).
  • at is validated with Pattern::literal, returning Error::InvalidPath like any other unspellable path.
  • The relay already applies all of a grant's mounts or none (Cluster::mounted logs grant mount refused with the error and admits nothing), so such grants are now refused outright rather than partially applied. Added a relay regression for both shapes.
  • Docs: doc/concept/moq-lite.md and doc/bin/relay/auth.md state the rule.

Tests: mount_never_widens_a_scope gains the reverse-order chain cases, a shared-target case, and self-overlap cases; new mount_refuses_a_wildcard_mount_point and session_handles_refuse_invalid_grant_mounts (the relay test fails on main with the key-ordered chain {".a": "pid/.z", ".z": "secret"}). just check passes.

Impact

  • Public API: nothing added. origin::Producer::mount refuses more inputs (Duplicate for a mount point overlapping an existing target or its own, InvalidPath for a wildcard mount point).
  • Wire: none.
  • Auth: a grant whose mounts chain or use a wildcard key is now refused by moq-relay (previously accepted depending on key order). Grant::validate is unchanged, since overlap depends on the session root.

Maintainer decisions

  • Refuse self-overlapping mounts.
  • Route claims over a read-only mount stay allowed (a mount is a view, not a reservation); see the declined P1.

Open decisions

(Written by Opus 5.5)

🤖 Generated with Claude Code

origin::Producer::mount compared a new mount only against existing mount
points, so a -> z then z -> secret chained while the reverse was refused,
making a grant's acceptance depend on its key order. The overlap check is
now symmetric, and a mount point holding a wildcard is InvalidPath.

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

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 509a8762-ab77-4806-bd45-c75fa6af35e2

📥 Commits

Reviewing files that changed from the base of the PR and between ca47661 and 72c49dd.

📒 Files selected for processing (4)
  • doc/bin/relay/auth.md
  • doc/concept/moq-lite.md
  • rs/moq-net/src/model/origin.rs
  • rs/moq-relay/src/cluster.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.


Walkthrough

Producer.mount now rejects wildcard mount points and mount paths that overlap existing mount points or targets under the documented rules. Tests cover these constraints and verify that relay subscriber and publisher session-handle creation rejects grants with chained mounts or wildcard mount points. Documentation for relay grants and origin.mount describes the restrictions.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 72c49

No concrete merge-blocking issue remains; the mount-validation change is ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 72c49

The change tightens mount validation and rejects invalid grants before creating session handles. The reviewed paths show no new access-expansion route, although previously accepted mounts may now be refused.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The affected exposure is grant-derived access through relay subscriber and publisher handles; the reviewed mount rule does not grant access outside the producer’s allowed target scope.

Security Findings and Attack Paths

  • inferred — The described chained-mount and wildcard-grant paths are rejected by the reviewed validation and relay admission flow. No introduced security finding is established on those paths.

Trust Boundaries and Controls

  • observed — Grant-supplied mount paths cross into the origin model’s validation boundary; the relay refuses the complete handle when any supplied mount fails.

Resilience and Maintainability Implications

  • inferred — Retrying an invalid grant starts from a fresh origin clone and cannot expose a partially accumulated set of mounts from the failed attempt.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (2 skipped: 2 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main changes: rejecting chained and wildcard origin mounts in any order.
Description check ✅ Passed The description directly explains the mount validation gaps, implementation changes, tests, documentation updates, and impact.
✨ Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T17:11:08.222883Z 72c49dd 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

Positive improvement: closes two real post-merge gaps from #4271. The asymmetric overlap check made grant acceptance depend on BTreeMap key order (a → z then z → secret slipped through while the reverse was refused), so a relay could silently admit a chained mount that reads the subtree the second mount shadows. Refusing unspellable wildcard mount points (*, p1/*, etc.) is also right: those could never be announced or authorized. Both belong in the library before more callers depend on the old behavior.

Worth the complexity: the change is small and local. Symmetrizing the overlap predicate (at/target vs existing mount points, plus at vs existing targets, while still allowing shared targets) plus Pattern::literal on at is the minimal fix. The unit cases for reverse-order chains, shared targets, and wildcard mount points, plus the relay regression that fails on main for the key-ordered chain, give confidence without new abstraction.

Different approach: nothing better jumps out. Leaving self-overlap (a → a/b) accepted for now is fine; it does not chain through another mount and can be a one-line follow-up if you want to tighten. Docs are slightly looser than the code (moq-lite.md emphasizes mount-point overlap; the check also refuses a new target that overlaps an existing mount point), but they state the rule well enough for grant authors. No need to block on that.

Ship it.

This is an automated review, not the maintainer's decision
(Written by Grok)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96ed01968a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread doc/bin/relay/auth.md Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary

  • Changes: symmetric overlap check in origin::Producer::mount (order-independent; self-overlap refused; shared targets allowed), Pattern::literal validation on the mount point (InvalidPath for wildcards), relay regression for chained and wildcard grant mounts, and docs in doc/concept/moq-lite.md and doc/bin/relay/auth.md.
  • Reviews: the Codex P2 (describe self-overlapping mount values accurately) was fixed in 72c49dd by refusing self-overlaps in code, so the docs now match; replied and resolved. Codex gave a thumbs up on 72c49dd. CodeRabbit had no actionable comments.
  • Main: merges cleanly with current main (including fix(auth): admit a SETUP token equal to the jwt query #4359's auth.md edit and fix(net): keep an aborted track's finished groups, expire ended tracks #4378's moq-net changes); the ruleset does not require an up-to-date branch, so no merge commit was added.
  • CI: Check, Test, WASM, and Android pass on 72c49dd.
  • Decisions: self-overlapping mounts are refused; route claims over a read-only mount stay allowed. js/net has no mount counterpart yet (out of scope, as in feat(net): read a subtree through an origin mount #4271).

Enabling squash auto-merge pinned to 72c49dd.

(Written by Opus 5.5)

@kixelated
kixelated merged commit b4cc44b into main Sep 28, 2026
5 checks passed
@kixelated
kixelated deleted the fix/origin-mount-validation branch September 28, 2026 18:30
@moq-bot moq-bot Bot mentioned this pull request Sep 28, 2026
@moq-bot moq-bot Bot mentioned this pull request Sep 30, 2026
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