refactor(ffmpeg): resolve per-domain request headers from a registry - #168
Merged
Conversation
The MyInstants-specific Referer/Sec-Fetch-* headers were applied by an `if needs_cf_bypass and "myinstants.com" in uri` check buried in the generic streaming path, so every additional host would have meant another special case in shared transport code. Replaced it with a DOMAIN_HEADER_PROFILES registry keyed by domain and a get_domain_headers() lookup, so a new host is a data entry. The lookup matches the URI's hostname (exact or subdomain) instead of substring-matching the whole URI. That is a deliberate behavior change: the old check also fired for URLs that merely contained the string, such as https://evil.com/redirect?to=myinstants.com/x.mp3 or https://notmyinstants.com/x.mp3, leaking a myinstants.com Referer to unrelated hosts. Real MyInstants URLs (apex, www and cdn subdomains) still match. Bumps VERSION to 1.8.21. Closes #156 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Dolly132 <109222243+Dolly132@users.noreply.github.com>
Rushaway
commented
Sep 5, 2026
Rushaway
left a comment
Member
Author
There was a problem hiding this comment.
Self-review: flagging the one non-mechanical bit -- I switched from substring matching the whole URI to hostname matching, which intentionally stops sending the myinstants.com Referer to hosts that merely have the string in their path/query. I think that's a fix rather than a regression, but it is a behavior change so it should be a conscious call, not something you discover later.
This was referenced Sep 5, 2026
Dolly132
approved these changes
Sep 6, 2026
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.
Summary
Referer/Sec-Fetch-*headers were applied byif needs_cf_bypass and "myinstants.com" in uri:buried in the generic streaming path. Every additional Cloudflare-protected host would have meant anotherin urispecial case in shared transport code.DOMAIN_HEADER_PROFILESregistry keyed by domain plus aget_domain_headers()lookup, so adding a host is a data entry at the top of the file rather than a branch in the fetch path.Deliberate behavior change worth reviewing
The lookup now matches the URI's hostname (exact or subdomain) instead of substring-matching the whole URI. The old check also fired for URLs that merely contained the string:
https://www.myinstants.com/media/sounds/x.mp3https://myinstants.com/media/sounds/y.mp3https://cdn.myinstants.com/sounds/z.mp3https://evil.com/redirect?to=myinstants.com/x.mp3https://notmyinstants.com/x.mp3The last two mean the old code would send
Referer: https://www.myinstants.comto an unrelated (potentially attacker-chosen) host. I treated tightening that as part of the fix rather than faithfully preserving it — say the word if you'd rather keep substring semantics.Closes #156
Test plan
www,cdnsubdomain, unrelated hosts, and the two spoofing cases above) — real MyInstants URLs all still match.🤖 Generated with Claude Code