Repository navigation
fix(hls): refuse an opt-in path with a . or .. segment - #609
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withpath.Cleanto 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:
/.hls/acme/grant (the new integration test);fetchCatalogWithRetrywith that opt-in returns/victim/cam's catalog (checked with a scratch test, not committed).Fix
broadcastPathFromAnnouncereportsfalsefor a path with a.or..segment.handleAnnouncementlogs and ignores that opt-in.sameBroadcastno 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/.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 andcam1..hdcases 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/andgolangci-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