diff --git a/tests/radio-source-plan.test.mjs b/tests/radio-source-plan.test.mjs index 9ee20b65..f599b03e 100644 --- a/tests/radio-source-plan.test.mjs +++ b/tests/radio-source-plan.test.mjs @@ -185,3 +185,21 @@ test("never forwards cloud-provider signed stream query parameters to a third-pa ]); assert.equal(result.filter(item => item.proxied).length, 1); }); + +test("never forwards OAuth-style stream credentials to a third-party proxy", () => { + const privateKeys = [ + "access_token", "refresh_token", "id_token", "auth_token", + "session_token", "session_key", "client_secret", + ]; + const sources = privateKeys.map(key => ({ + src: `https://radio.example/live.mp3?${key}=private-test-value`, + })); + const publicSource = { src: "https://radio.example/live.mp3?quality=high" }; + const result = buildPlaybackSources([...sources, publicSource], "https://cors.example/"); + assert.deepEqual(result.map(item => item.src), [ + ...sources.map(item => item.src), + publicSource.src, + `https://cors.example/${publicSource.src}`, + ]); + assert.equal(result.filter(item => item.proxied).length, 1); +}); diff --git a/utils/radio-source-plan.mjs b/utils/radio-source-plan.mjs index bfc5f461..da9c12dc 100644 --- a/utils/radio-source-plan.mjs +++ b/utils/radio-source-plan.mjs @@ -45,7 +45,7 @@ export const buildPlaybackSources = (sources, corsServer) => { const parsed = new URL(src); // Signed stream URLs (including AWS/GCS provider-specific query fields) must not reach third-party proxies. const sensitiveQuery = [...parsed.searchParams.keys()].some(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)); + /^(?:x-amz-.+|x-goog-.+|awsaccesskeyid|googleaccessid|token|(?:access|refresh|id|auth|session)[_-]?token|access[_-]?key|api[_-]?key|client[_-]?secret|session[_-]?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;