fix(telegram): allowlist api.telegram.org in media SSRF policy

This commit is contained in:
Peter Steinberger
2026-02-24 04:18:43 +00:00
parent ac6cec7677
commit dd14daab15
2 changed files with 7 additions and 1 deletions

View File

@@ -95,7 +95,10 @@ async function expectTransientGetFileRetrySuccess() {
expect(fetchRemoteMedia).toHaveBeenCalledWith(
expect.objectContaining({
url: `https://api.telegram.org/file/bot${BOT_TOKEN}/voice/file_0.oga`,
ssrfPolicy: { allowRfc2544BenchmarkRange: true },
ssrfPolicy: {
allowRfc2544BenchmarkRange: true,
allowedHostnames: ["api.telegram.org"],
},
}),
);
return result;

View File

@@ -36,6 +36,9 @@ const PARSE_ERR_RE = /can't parse entities|parse entities|find end of the entity
const VOICE_FORBIDDEN_RE = /VOICE_MESSAGES_FORBIDDEN/;
const FILE_TOO_BIG_RE = /file is too big/i;
const TELEGRAM_MEDIA_SSRF_POLICY = {
// Telegram file downloads should trust api.telegram.org even when DNS/proxy
// resolution maps to private/internal ranges in restricted networks.
allowedHostnames: ["api.telegram.org"],
allowRfc2544BenchmarkRange: true,
} as const;