Skip to content

Commit d2a6465

Browse files
committed
fix: reject loopback/localhost mailing list sourceUrl (CM-1318)
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent caa9fc6 commit d2a6465

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

backend/src/api/integration/helpers/mailingListAuthenticate.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ const isSafeListName = (name: string): boolean =>
2020

2121
// public-inbox-clone in the worker fetches this URL as-is; restrict to
2222
// https so a caller can't point the worker at file://, javascript:, or a
23-
// bare non-URL string.
23+
// bare non-URL string. Requiring https already blocks the classic SSRF
24+
// target (cloud-metadata IMDS is http-only, per securityTxt.ts precedent);
25+
// also reject obvious loopback/localhost literals.
26+
const isBlockedHost = (h: string): boolean =>
27+
h === 'localhost' || h === '::1' || h === '0.0.0.0' || h.startsWith('127.')
28+
2429
const isSafeSourceUrl = (sourceUrl: string): boolean => {
2530
try {
26-
return new URL(sourceUrl).protocol === 'https:'
31+
const url = new URL(sourceUrl)
32+
return url.protocol === 'https:' && !isBlockedHost(url.hostname.toLowerCase())
2733
} catch {
2834
return false
2935
}

0 commit comments

Comments
 (0)