[Feature]: 非ssrf白名单的域名还是会做dns解析
Author: hereischCreated Sep 18, 2026Updated Sep 18, 2026
Labelsenhancement
Affected Component
Other
Problem Description
企业内部私有化部署的时候,安全渗透测试发现非ssrf白名单的域名还是会做dns解析的请求,可能会导致安全问题。能否在新版本增加判断的开关SSRF_DNS_WHITELIST_ONLY=true 时,非白名单 host(含非白名单 IP 直连)在发起 DNS 查询之前直接报错——白名单即全部出口,默认拒绝。
Proposed Solution
| # | 文件 | 改动 |
|---|---|---|
| 1 | internal/utils/security.go | ① 新增 dnsWhitelistOnlyEnabled()(读 SSRF_DNS_WHITELIST_ONLY)② SSRFSafeDialContext 在白名单/代理快路(:808)之后插入:严格模式开启即 return "DNS resolution blocked: host not in SSRF whitelist"(此处必然非白名单,3 行)③ 抽公共判定函数供其他调用点复用 |
| 2 | internal/infrastructure/web_fetch/fetcher.go | pinnedDialContext(:230) 与 resolvePinnedTarget 同位置插入同一检查 |
| 3 | internal/im/yunzhijia/url.go | safeDialContext(:66) 同样插入(IM 出站) |
| 4 | 测试 | security_test.go + fetcher 测试:严格开/关 × 白名单内/外 × 域名/IP 字面量;回归 go test ./internal/utils ./internal/infrastructure/web_fetch -count=1 |
| 5 | 文档 | .env.example 加注释说明(生产离线环境建议 true) |
Alternatives
No response
Impact
Many users would benefit
Use Case
No response
Additional Information
No response
Confirmation
- I have searched existing issues and confirmed this is a new request
- I understand this request may need discussion and evaluation
Source: Tencent/WeKnora