feat(security): 为私有LLM端点添加LLM_ALLOWED_HOSTS白名单 - #56
Open
kksty wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为私有/本地 LLM 端点增加
LLM_ALLOWED_HOSTS白名单配置,解决 AutoHunter 无法使用内网 LLM 部署(vLLM / Ollama / llama.cpp / Xinference 等)的问题。问题背景
netguard.py的 SSRF 防护会拦截携带 LLM API Key 的请求发往内网/云元数据地址,防止密钥外泄和内网探测。但这也导致私有 LLM 部署(base_url 为内网 IP 或域名)无法使用——默认策略直接拒绝,且没有配置项可放行。FOFA 已有
FOFA_ALLOWED_HOSTS白名单先例,LLM 端却缺少同等机制。改动内容
app/tools/netguard.py_env_llm_allowed_hosts()(读取 env)、_ip_in_allowed()(单 IP / CIDR / 域名匹配);assert_safe_outbound_url()的 IP 校验循环增加白名单短路app/api/settings.pyapp/settings_service.py.env.exampleLLM_ALLOWED_HOSTS配置说明用法
# .env 中配置,支持单 IP / CIDR 网段 / 域名,逗号分隔 LLM_ALLOWED_HOSTS=192.168.141.3,10.0.0.0/8,llm.lan