安全漏洞 / 严重 / 工具系统
electron/harness/tools/built-in/http-request.ts
HttpRequestTool 接受任意 URL,未做 SSRF 防护。LLM 可调用:
http://169.254.169.254/latest/meta-data/
http://localhost:port/
http://10.0.0.0/8
http://192.168.0.0/16
http://[::1]/
这违反了 OWASP SSRF 防御最佳实践。
import { lookup } from 'dns/promises'; import { isIP } from 'net'; async function isPrivateIP(ip: string): Promise<boolean> { // 检查 IPv4 私有段 / 回环 / 链路本地 / 元数据 const privateRanges = [ /^127\./, /^10\./, /^192\.168\./, /^172\.(1[6-9]|2[0-9]|3[0-1])\./, /^169\.254\./, /^0\./, /^224\./, /^240\./, ]; if (privateRanges.some(re => re.test(ip))) return true; // IPv6 if (ip === '::1' || ip.startsWith('fe80::') || ip.startsWith('fc00::')) return true; return false; } // 解析域名后校验 IP const ips = await lookup(hostname, { all: true }); for (const { address } of ips) { if (await isPrivateIP(address)) { throw new Error(`Blocked SSRF: ${hostname} resolves to private IP ${address}`); } }
No dependencies set.
The note is not visible to the blocked user.
问题类型
安全漏洞 / 严重 / 工具系统
文件位置
electron/harness/tools/built-in/http-request.ts问题描述
HttpRequestTool 接受任意 URL,未做 SSRF 防护。LLM 可调用:
http://169.254.169.254/latest/meta-data/(AWS / GCP / Azure 元数据,可获取云凭证)http://localhost:port/(访问本机内部服务,如数据库、Redis、管理 API)http://10.0.0.0/8/http://192.168.0.0/16(内网扫描)http://[::1]/(IPv6 回环)这违反了 OWASP SSRF 防御最佳实践。
影响
建议修复