From eee71ff9a1c41007a15647d3b83b8ff71ca7b668 Mon Sep 17 00:00:00 2001 From: sunkinux Date: Mon, 16 Mar 2026 13:52:19 +0800 Subject: [PATCH] fix(web-fetch): scope RFC2544 bypass to proxied fetches only Only enable allowRfc2544BenchmarkRange when proxy environment variables are configured. This prevents widening SSRF protections for non-proxied environments while still supporting fake-ip proxy clients like Clash and Surge. Addresses review feedback from Codex and Greptile. --- src/agents/tools/web-fetch.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/agents/tools/web-fetch.ts b/src/agents/tools/web-fetch.ts index 0da9108591f..60bcf5326ab 100644 --- a/src/agents/tools/web-fetch.ts +++ b/src/agents/tools/web-fetch.ts @@ -32,6 +32,25 @@ import { export { extractReadableContent } from "./web-fetch-utils.js"; +const PROXY_ENV_KEYS = [ + "HTTPS_PROXY", + "HTTP_PROXY", + "ALL_PROXY", + "https_proxy", + "http_proxy", + "all_proxy", +] as const; + +function hasProxyEnvConfigured(): boolean { + for (const key of PROXY_ENV_KEYS) { + const value = process.env[key]; + if (typeof value === "string" && value.trim().length > 0) { + return true; + } + } + return false; +} + const EXTRACT_MODES = ["markdown", "text"] as const; const DEFAULT_FETCH_MAX_CHARS = 50_000; @@ -539,9 +558,11 @@ async function runWebFetch(params: WebFetchRuntimeParams): Promise