From 9a09ab8f7f52b940c98990aaa2bfe78aa845692c Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 19 Nov 2026 12:05:05 +0700 Subject: [PATCH 1/7] fix(playback): avoid forwarding signed stream URLs to CORS proxy --- utils/radio-source-plan.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/radio-source-plan.mjs b/utils/radio-source-plan.mjs index 4cdc43e6..c29833fa 100644 --- a/utils/radio-source-plan.mjs +++ b/utils/radio-source-plan.mjs @@ -43,7 +43,10 @@ export const buildPlaybackSources = (sources, corsServer) => { let hasCredentials = false; try { const parsed = new URL(src); - hasCredentials = Boolean(parsed.username || parsed.password); + // Signed stream URLs must not be forwarded to third-party CORS 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)); + hasCredentials = Boolean(parsed.username || parsed.password || sensitiveQuery); } catch { /* Invalid URLs are not eligible for proxy fallback. */ hasCredentials = true; } From 22db8531c04e194688b1aaccb7ccfe31c9801103 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 19 Nov 2026 12:05:10 +0700 Subject: [PATCH 2/7] test(playback): cover signed query proxy suppression --- tests/radio-source-plan.test.mjs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/radio-source-plan.test.mjs b/tests/radio-source-plan.test.mjs index 1c00af0d..bba4bcfe 100644 --- a/tests/radio-source-plan.test.mjs +++ b/tests/radio-source-plan.test.mjs @@ -148,3 +148,19 @@ test("does not disclose embedded stream credentials through a CORS proxy", () => ]); assert.equal(result.filter(item => item.proxied).length, 1); }); + + +test("never forwards signed query credentials to a third-party proxy", () => { + const sources = [ + { src: "https://radio.example/live.mp3?token=private-test-value" }, + { src: "https://radio.example/live.aac?accessKey=private-test-value" }, + { src: "https://radio.example/live.mp3?Signature=private-test-value" }, + { src: "https://radio.example/live.mp3?quality=high" }, + ]; + const result = buildPlaybackSources(sources, "https://cors.example/"); + assert.deepEqual(result.map(item => item.src), [ + ...sources.slice(0, 3).map(item => item.src), + "https://radio.example/live.mp3?quality=high", + "https://cors.example/https://radio.example/live.mp3?quality=high", + ]); +}); From 88288fc9602e23b01d9811687d1a1cc787bcfe12 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 19 Nov 2026 18:12:18 +0700 Subject: [PATCH 3/7] fix(playback): keep cloud-signed stream URLs out of proxy fallback --- utils/radio-source-plan.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/radio-source-plan.mjs b/utils/radio-source-plan.mjs index c29833fa..bfc5f461 100644 --- a/utils/radio-source-plan.mjs +++ b/utils/radio-source-plan.mjs @@ -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; From 94b8a999f11785f6b2cc03b64e755eb361164737 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 19 Nov 2026 18:12:24 +0700 Subject: [PATCH 4/7] test(playback): guard AWS and GCS signed URL proxy leakage --- tests/radio-source-plan.test.mjs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/radio-source-plan.test.mjs b/tests/radio-source-plan.test.mjs index bba4bcfe..9ee20b65 100644 --- a/tests/radio-source-plan.test.mjs +++ b/tests/radio-source-plan.test.mjs @@ -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); +}); From 109f82cb7b3d6541bf5cbe8bb99ce230f49be43e Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 19 Nov 2026 20:13:50 +0700 Subject: [PATCH 5/7] fix(report): expand partial email template placeholders --- utils/station-sharing.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/station-sharing.mjs b/utils/station-sharing.mjs index ab892a92..b049a28c 100644 --- a/utils/station-sharing.mjs +++ b/utils/station-sharing.mjs @@ -49,9 +49,11 @@ export function stationReportEmailUrl(path, title, subject, description) { const message = String(description || 'I cannot hear this station.').slice(0, 1000); // Localized templates may place the station name and public URL directly in // the email. Preserve the previous plain-text fallback for older callers. - const hasPlaceholders = message.includes('{station}') && message.includes('{url}'); + const hasPlaceholders = /\{(?:station|url)\}/.test(message); const body = hasPlaceholders ? message.replace(/\{(station|url)\}/g, (_match, key) => key === 'station' ? safeTitle : stationPage) + + (message.includes('{station}') ? '' : '\n' + safeTitle) + + (message.includes('{url}') ? '' : '\n' + stationPage) : message + '\n\n' + safeTitle + '\n' + stationPage; // mailto URLs follow RFC 6068, not HTML form encoding. URLSearchParams From a3be63af8bd8377ec42e391759be57d06bb7ea37 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 19 Nov 2026 20:13:53 +0700 Subject: [PATCH 6/7] test(report): cover partial mailto placeholders --- .../station-sharing-mailto-line-endings.test.mjs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/station-sharing-mailto-line-endings.test.mjs b/tests/station-sharing-mailto-line-endings.test.mjs index e6852fb8..a40cd52a 100644 --- a/tests/station-sharing-mailto-line-endings.test.mjs +++ b/tests/station-sharing-mailto-line-endings.test.mjs @@ -19,3 +19,18 @@ test('mailto body normalizes mixed CRLF, CR and LF to single CRLF', () => { assert.equal((body.match(/\r\n/g) || []).length, 6); assert.equal(body.replace(/\r\n/g, '').includes('\r'), false); }); + + +test('mailto expands a single localized placeholder without leaking literal braces or duplicating station details', () => { + const stationOnly = new URL(stationReportEmailUrl( + '/vn/ho-chi-minh/test-radio', 'Test Radio', 'Playback problem', 'Station: {station}', + )); + const urlOnly = new URL(stationReportEmailUrl( + '/vn/ho-chi-minh/test-radio', 'Test Radio', 'Playback problem', 'Station page: {url}', + )); + const stationBody = stationOnly.searchParams.get('body'); + const urlBody = urlOnly.searchParams.get('body'); + assert.equal(stationBody, 'Station: Test Radio\r\nhttps://radio.eplus.dev/vn/ho-chi-minh/test-radio'); + assert.equal(urlBody, 'Station page: https://radio.eplus.dev/vn/ho-chi-minh/test-radio\r\nTest Radio'); + assert.doesNotMatch(stationBody + urlBody, /\\{(?:station|url)\\}/); +}); From ca818dc166f4188404f34d1cc2ca87254efe72fd Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 19 Nov 2026 20:14:06 +0700 Subject: [PATCH 7/7] test(report): correctly assert no literal placeholders remain --- tests/station-sharing-mailto-line-endings.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/station-sharing-mailto-line-endings.test.mjs b/tests/station-sharing-mailto-line-endings.test.mjs index a40cd52a..028d6440 100644 --- a/tests/station-sharing-mailto-line-endings.test.mjs +++ b/tests/station-sharing-mailto-line-endings.test.mjs @@ -32,5 +32,5 @@ test('mailto expands a single localized placeholder without leaking literal brac const urlBody = urlOnly.searchParams.get('body'); assert.equal(stationBody, 'Station: Test Radio\r\nhttps://radio.eplus.dev/vn/ho-chi-minh/test-radio'); assert.equal(urlBody, 'Station page: https://radio.eplus.dev/vn/ho-chi-minh/test-radio\r\nTest Radio'); - assert.doesNotMatch(stationBody + urlBody, /\\{(?:station|url)\\}/); + assert.doesNotMatch(stationBody + urlBody, /\{(?:station|url)\}/); });