Skip to content

fix(hls)!: hold import resources and redirects to the playlist origin - #6374

Merged
kixelated merged 10 commits into
mainfrom
quest/m1/release-audit/hls-admission
Oct 24, 2026
Merged

kixelated merged 10 commits into
mainfrom
quest/m1/release-audit/hls-admission

Conversation

@kixelated

@kixelated kixelated commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

HLS import treats the playlist as untrusted input, but a playlist could still steer the importer to other origins: an absolute or network-path reference to another host, a file: path from an HTTP(S) playlist, or a redirect hop to another origin. A caller-supplied reqwest::Client kept its own redirect policy, which the importer cannot override per request.

Approach

The shared Fetcher owns admission for every resource kind (playlists, init segments, media segments). It keeps the entry playlist URL and refuses any resource whose scheme, host, or port differs, before any I/O. The importer builds its own HTTP client with a redirect policy that checks every hop against the same rule before following it; a stopped hop reaches fetch as a 3xx and is refused there. Error::ResourceRefused ends the import immediately instead of riding the retry budget.

Impact

  • Public API (breaking): import::Config::client is removed. Error::ResourceRefused is added to the non-exhaustive error enum.
  • Migration (moq-hls):
    • import::Import fetches only resources with the entry playlist's scheme, host, and port, and refuses a reference or redirect hop to any other origin with the new Error::ResourceRefused, which ends the import. Serve every playlist, init segment, and media segment from the playlist's origin, rather than referencing a separate CDN host. A file:// playlist reads only local files, and other URL schemes are refused when constructing the import.
    • import::Config::client is removed: the importer builds its own HTTP client so it can hold redirects to the playlist's origin. Drop the field; there is no replacement for a custom client.
  • Behavior: a playlist that references, or redirects to, another origin (such as a separate CDN host) fails the import. A file:// playlist reads only local files. Unsupported entry schemes fail Import::new.
  • No CLI flags or MoQ wire changes. doc/bin/hls.md states the origin rule.

Decisions

  • ✅ Same-origin only: references must resolve to the playlist's scheme, host, and port. Refusing cross-origin CDN references was chosen over keeping them, so a playlist cannot reach internal or third-party hosts.
  • ✅ Every redirect hop is checked before it is followed, not just the final URL, since an intermediate hop is already a request to the other origin.
  • ✅ Drop Config::client rather than narrow it: it has no in-repo consumer, and a caller's client owns a redirect policy the importer cannot override. Dropped: custom TLS roots, proxies, and default headers for authenticated origins; a consumer that needs one can propose a narrowed option.
  • ✅ file: resources only for a file: entry playlist (local fixtures keep working); other schemes are refused.

Validation

  • cargo test -p moq-hls: new tests cover every reference form (relative, root-relative, network-path, absolute, scheme change, port change, file: from HTTP and HTTP from file:), same-origin redirects being followed, and a later cross-origin hop being refused without ever connecting to the other origin. The redirect test fails (times out connecting to the other origin) with the default redirect policy.
  • Nix just check passes: lint, docs, quest, markdown, and Rust tests (405 + 227, including 208 moq-hls tests and the CLI HLS import tests).
  • PR CI green, including CodeQL after the cross-origin test built its HTTP reference from the entry URL instead of a literal (a false positive of rust/non-https-url).
  • just test interop --all not run: interop exercises no HLS path, and this changes no wire, FFI, or CLI surface.

Follow-ups

Consider a release backport after main validation; a port that keeps Config::client should document that the caller's client owns redirect handling.

Addresses the two Codex findings: cross-origin references and redirect hops.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 2 commits October 22, 2026 12:09
Co-Authored-By: GPT-6 <noreply@openai.com>
@kixelated kixelated changed the title Review HLS resource admission boundaries fix(hls): preserve the input resource boundary Oct 22, 2026
@kixelated
kixelated marked this pull request as ready for review October 22, 2026 19:20
@kixelated

Copy link
Copy Markdown
Collaborator Author

Completed the resource-admission fix, regression coverage, migration guidance, and quest removal. HLS checks pass 202 tests; CLI checks pass 193 tests with readiness logging configured; full cross-language interop passes. The required full local CI attempt is limited by the unchanged Nix runner-image user-namespace permission failure documented above. No open implementation decisions remain. Recommend a release-compatible backport after main validation.

(Written by GPT-6)

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
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: 97500fc3-46bd-4022-8d86-e3aaecb99ff4
Commits

Reviewing files that changed from the base of the PR and between 4a16316 and 923166a.

Files selected for processing: 7
  • doc/bin/hls.md
  • quest/m0/hls-admission-backport.md
  • quest/m1/release-audit/README.md
  • quest/m1/release-audit/hls-admission.md
  • quest/m2/hls-variant-area.md
  • rs/moq-hls/src/error.rs
  • rs/moq-hls/src/import.rs
Files with no reviewable changes: 2
  • quest/m2/hls-variant-area.md
  • quest/m1/release-audit/hls-admission.md

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

Walkthrough

The HLS importer now restricts playlist resources and redirect hops to the entry playlist’s scheme, host, and port. It accepts file, http, and https entry schemes and returns Error::ResourceRefused for unsupported schemes or resources outside that origin. Import processing propagates this error immediately. Tests cover origin checks, redirects, local resources, and unsupported schemes. The documentation and planning notes were also updated.

Priority: Normal

Merge Risk: Minimal · up to 92316

No actionable merge-blocking issue is established; the change is ready for normal validation and merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 29.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 2 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: restricting HLS import resources and redirects to the playlist origin.
Description check Passed The description directly explains the HLS origin restrictions, API changes, error behavior, tests, and validation for this changeset.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 29.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 2 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.99.0)

Clippy execution timed out

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 Oct 22, 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-10-24T07:44:30.407263Z 923166a 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.

The maintainer chose same-origin on 2026-10-22: a playlist reference and
every redirect hop must match the playlist's scheme and authority. This PR
settles the filesystem boundary only, so the quest stays with the origin
rule and the Config::client decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as draft October 22, 2026 20:38

@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: 9e0c713291

ℹ️ 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 rs/moq-hls/src/import.rs Resolved
Comment thread rs/moq-hls/src/import.rs Resolved
kixelated and others added 2 commits October 23, 2026 12:45
# Conflicts:
#	quest/m1/release-audit/hls-admission.md
#	rs/moq-hls/MIGRATE.md
Refuse any reference or redirect hop whose scheme, host, or port differs
from the entry playlist, and drop import::Config::client so the importer
owns the redirect policy. Finishes the hls-admission quest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title fix(hls): preserve the input resource boundary fix(hls): hold import resources and redirects to the playlist origin Oct 23, 2026
@kixelated
kixelated marked this pull request as ready for review October 23, 2026 20:01
CodeQL's non-https-url query traced the literal HTTP reference in the
cross-origin test into the request builder, though the test asserts it is
refused. Building it by swapping the entry's scheme states the intent.

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

Copy link
Copy Markdown
Collaborator Author

Merging. HLS import now refuses cross-origin playlists, segments and redirect hops, and drops Config::client, as the maintainer chose. CI is green, the current head has a non-Grok review, and quest check passes against main.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 23, 2026
@kixelated

Copy link
Copy Markdown
Collaborator Author

x

@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

The head adds a test-only commit (d1057f1) after the last Codex pass.

(Written by Claude Sonnet 5.5)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: d1057f155c

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

@kixelated

Copy link
Copy Markdown
Collaborator Author

Enabling auto-merge on d1057f1. CI is green (10/10), the branch is clean against main, quest check passes, and Codex gave a thumbs-up with no findings on this head after the test-only commit.

(Written by Claude Sonnet 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 24, 2026
kixelated and others added 2 commits October 23, 2026 20:17
# Conflicts:
#	doc/bin/hls.md
#	quest/m2/hls-variant-area.md
#	rs/moq-hls/src/import.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated enabled auto-merge October 24, 2026 03:20
@kixelated
kixelated added this pull request to the merge queue Oct 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 24, 2026
# Conflicts:
#	quest/m1/release-audit/README.md
#	quest/m1/release-audit/hls-admission.md
#	rs/moq-hls/MIGRATE.md
@kixelated kixelated changed the title fix(hls): hold import resources and redirects to the playlist origin fix(hls)!: hold import resources and redirects to the playlist origin Oct 24, 2026
@kixelated
kixelated added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit aeed5a4 Oct 24, 2026
11 checks passed
@kixelated
kixelated deleted the quest/m1/release-audit/hls-admission branch October 24, 2026 09:13
kixelated added a commit that referenced this pull request Oct 24, 2026
Drops the history branch #6600 added to the fanout (unbound, the superseded-reader history clause), keeps its catalog-wide fail(None), and restores the futures dev-dependency #6374's import test uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated added a commit that referenced this pull request Oct 24, 2026
fix(hls): hold import resources and redirects to the playlist origin (backport #6374)
This was referenced Oct 24, 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