From 1e2d64e28bf7a7c6832b6bb26c1af049af729988 Mon Sep 17 00:00:00 2001 From: oudecheng <13802883547@139.com> Date: Tue, 4 Aug 2026 08:25:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(web=5Ffetch):=20=E7=A6=81=E7=94=A8=20HTTP?= =?UTF-8?q?=20=E9=87=8D=E5=AE=9A=E5=90=91=EF=BC=8C=E9=98=B2=E6=AD=A2=20SSR?= =?UTF-8?q?F=20=E9=87=8D=E5=AE=9A=E5=90=91=E7=BB=95=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit validate_url 只校验初始 URL 的 host,若跟随 302 跳转,攻击者可用公网 URL 重定向到 169.254.169.254(云元数据)或 127.0.0.1 等内网地址,绕过 is_private_host 的 SSRF 防护。与 http_request 工具保持一致,使用 redirect::Policy::none()。 --- src/tools/web_fetch.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/web_fetch.rs b/src/tools/web_fetch.rs index 113b62d..f78d80a 100644 --- a/src/tools/web_fetch.rs +++ b/src/tools/web_fetch.rs @@ -64,6 +64,11 @@ impl WebFetchTool { async fn fetch_content(&self, url: &str) -> Result { let client = reqwest::Client::builder() .timeout(Duration::from_secs(self.timeout_secs)) + // 禁用重定向:validate_url 只校验初始 URL 的 host, + // 若跟随 302 跳转,攻击者可用公网 URL 重定向到 + // 169.254.169.254(云元数据)或 127.0.0.1 等内网地址, + // 绕过 is_private_host 的 SSRF 防护。 + .redirect(reqwest::redirect::Policy::none()) .build() .map_err(|e| format!("Failed to create HTTP client: {}", e))?;