Skip to content

fix(hls): refuse an opt-in path with a . or .. segment - #609

Merged
okdaichi merged 1 commit into
mainfrom
fix/hls-optin-dot-segments
Nov 17, 2026
Merged

okdaichi merged 1 commit into
mainfrom
fix/hls-optin-dot-segments

Conversation

@okdaichi

Copy link
Copy Markdown
Collaborator

Problem

The relay grants and routes broadcast paths exactly as written, so a publish grant rooted at /.hls/acme/ covers /.hls/acme/../victim/cam. The HLS egress cleaned the opt-in path with path.Clean to find the broadcast, got /victim/cam, and served it. The egress can read every broadcast. So one tenant could put another tenant's broadcast on HLS, either by redirecting to it from the opt-in or by answering NOT_FOUND, which makes the egress fall back to the cleaned path.

Confirmed on main before the fix:

  • the relay routes that announcement under a /.hls/acme/ grant (the new integration test);
  • fetchCatalogWithRetry with that opt-in returns /victim/cam's catalog (checked with a scratch test, not committed).

Fix

  • broadcastPathFromAnnounce reports false for a path with a . or .. segment. handleAnnouncement logs and ignores that opt-in.
  • sameBroadcast no longer matches when either path has such a segment. This closes the reverse case: a redirect to /victim/../acme/cam, which the relay routes under /victim/.
  • Doubled and trailing slashes are still cleaned away, as sameBroadcast's comment intends, so existing publishers keep working.

The same issue in qumo abr (unmerged, #604) is fixed there by requiring the exact spelling of the opt-in path.

Tests

  • Test_broadcastPathFromAnnounce (converted to a map table): ., .. into another tenant's directory, .. out of the prefix, a trailing .., plus trailing-slash, doubled-slash and cam1..hd cases that must still work.
  • TestSameBroadcast: dot-segment cases on either side, and a name containing dots.
  • TestRelay_RoutesOptInDotSegmentsAsGranted (integration): the relay routes the dot-segment opt-in under a /.hls/acme/ grant, which is why the egress has to refuse it.

go test ./internal/hls/, go test -tags integration -run 'TestRelay_RoutesOptInDotSegmentsAsGranted|TestRelay_PatternCredentials' ./internal/integration/ and golangci-lint run ./internal/hls/... ./internal/integration/... pass.

Not in this PR

The relay itself accepts . and .. segments in announced and subscribed paths, while signing keys refuse them in roots. Refusing them at the relay would close this whole class of bug for every egress. That is a wider behaviour change, left for a separate decision.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KPWMJNAzsnsiqRPREa2JqY

The relay grants and routes exact paths, so a grant for /.hls/acme/ announces
/.hls/acme/../victim/cam. The egress cleaned that to /victim/cam and, reading
every broadcast, served it: through the opt-in's redirect, or by reading the
cleaned path directly when the opt-in answers NOT_FOUND. Such paths are now
refused, and sameBroadcast no longer matches a redirect target that has one.
Doubled and trailing slashes are still cleaned away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KPWMJNAzsnsiqRPREa2JqY
@okdaichi
okdaichi merged commit 2001666 into main Nov 17, 2026
12 checks passed
@okdaichi
okdaichi deleted the fix/hls-optin-dot-segments branch November 17, 2026 18:55
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