Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/radio-source-plan.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,24 @@ test("never forwards signed query credentials to a third-party proxy", () => {
"https://cors.example/https://radio.example/live.mp3?quality=high",
]);
});

test("never forwards cloud-provider signed stream query parameters to a third-party proxy", () => {
const signed = [
"https://radio.example/live.mp3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=test&X-Amz-Signature=test",
"https://radio.example/live.aac?X-Amz-Security-Token=test",
"https://radio.example/live.mp3?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Signature=test",
"https://radio.example/live.mp3?AWSAccessKeyId=test",
"https://radio.example/live.mp3?GoogleAccessId=test",
];
const ordinary = "https://radio.example/live.mp3?quality=high";
const result = buildPlaybackSources(
[...signed, ordinary].map(src => ({ src })),
"https://cors.example/",
);
assert.deepEqual(result.map(item => item.src), [
...signed,
ordinary,
`https://cors.example/${ordinary}`,
]);
assert.equal(result.filter(item => item.proxied).length, 1);
});
4 changes: 2 additions & 2 deletions utils/radio-source-plan.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export const buildPlaybackSources = (sources, corsServer) => {
let hasCredentials = false;
try {
const parsed = new URL(src);
// Signed stream URLs must not be forwarded to third-party CORS proxies.
// Signed stream URLs (including AWS/GCS provider-specific query fields) must not reach third-party proxies.
const sensitiveQuery = [...parsed.searchParams.keys()].some(key =>
/^(?:token|access[_-]?key|api[_-]?key|auth(?:orization)?|signature|sig|secret|password|jwt|expires?|policy|key[_-]?pair[_-]?id)$/i.test(key));
/^(?:x-amz-.+|x-goog-.+|awsaccesskeyid|googleaccessid|token|access[_-]?key|api[_-]?key|auth(?:orization)?|signature|sig|secret|password|jwt|expires?|policy|key[_-]?pair[_-]?id)$/i.test(key));
hasCredentials = Boolean(parsed.username || parsed.password || sensitiveQuery);
} catch { /* Invalid URLs are not eligible for proxy fallback. */
hasCredentials = true;
Expand Down
Loading