黑客如何一键接管你的大模型:NVIDIA Triton严重漏洞复现和检测(CVE-2025–23316)
NVIDIA Triton Inference Server存在严重漏洞(CVSS 9.8),允许攻击者通过特定请求实现远程代码执行。该漏洞影响25.08之前的版本,可通过构造API请求触发命令注入。开源工具AI-Infra-Guard支持检测此漏洞,更新到最新版本可修复问题。 2025-9-24 13:50:40 Author: www.freebuf.com(查看原文) 阅读量:2 收藏

今天在medium上看到一篇关于使用AI工具发现NVIDIA Triton漏洞的复现文章,联系到作者交流一番后,同意我翻译并转发给业内好友们共享。

原文链接:https://medium.com/@Qubit18/critical-ai-infrastructure-security-threat-reproducing-and-detecting-the-nvidia-triton-critical-d03d927023dc

漏洞简介

NVIDIA Triton是一个开源AI模型推理平台,支持多种深度学习框架,被众多大厂广泛应用于生产环境中的大模型推理与部署。近日,NVIDIA官方披露了Triton Inference Server存在一个CVSS评分为9.8的严重漏洞(Security Bulletin: NVIDIA Triton Inference Server - September 2025 | NVIDIA)。该漏洞允许攻击者在无需身份验证的情况下,通过构造特定请求实现远程代码执行(RCE),可能导致服务器被完全接管、敏感数据被盗、AI模型遭篡改或引发拒绝服务。

经测试验证,该漏洞影响25.08之前的所有版本,AI-Infra-Guard等开源AI基础设施漏洞检测工具(GitHub - Tencent/AI-Infra-Guard: A.I.G (AI-Infra-Guard) is a comprehensive, intelligent, and easy-to-use AI Red Teaming platform developed by Tencent Zhuque Lab.)已支持检测。

TritonPythonBackend漏洞分析

NVIDIATriton的Python后端组件支持用户摆脱对C++语言的依赖,直接使用Python来编写推理模型。我们可以使用Docker容器来快速部署环境。为了方便GDB调试,可以在启动Docker容器时添加一些参数选项来解除限制。

docker run --shm-size=2g --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -p 8000:8000 -p 1234:1234 --name tritonserver25.07 -it -d nvcr.io/nvidia/tritonserver:25.07-py3

NVIDIA Triton Inference Server提供了一个用于加载模型的API接口(server/docs/protocol/extension_model_repository.md at main · triton-inference-server/server · GitHub):

直接构造请求访问该接口会提示如下错误:

为解决了这个问题(Error when load model with http api · Issue #2633 · triton-inference-server/server · GitHub),可以在启动参数中添加 — model-control-mode=explicit 配置,表示系统支持手动加载或卸载模型:

/opt/tritonserver/bin/tritonserver --model-repository=/tmp/models --model-control-mode=explicit

那如何触发命令注入漏洞呢?

我们启用进程监控,并将请求backend为 python,然后重新发出请求。可以观察到处理程序将启动多个子进程以执行命令,其中的命令字符串包含了来自 API 请求可控参数。

启动GDB调试后,可以发现程序加载了Python组件对应的libtriton_python.so的共享链接库。

下面分析一下 API 请求的处理流程。请求URL首先由HTTPAPIServer::Handle处理,对应的处理函数是HandleRepositoryControl。

else if (RE2::FullMatch(
std::string(req->uri->path->full), modelcontrol_regex_, //modelcontrol_regex_( R"(/v2/repository(?:/([^/]+))?/(index|models/([^/]+)/(load|unload)))"),
&repo_name, &kind, &model_name, &action)) {
// model repository
if (kind == "index") {
HandleRepositoryIndex(req, repo_name);
return;
} else if (kind.find("models", 0) == 0) {
HandleRepositoryControl(req, repo_name, model_name, action);
return;
}

在HandleRepositoryControl中将完成POST请求参数的解析,然后后续将调用triton::core::CreateModel来尝试创建模型,并根据指定的 backend 类型选择后台处理组件,比如当 backend 取值为 python 时,将调用 triton::backend::python 组件并进入 StubLauncher::Launch 函数。动态调试获取的调用栈如下:

StubLauncher::Launch函数位于stub_launcher.cc文件中,其创建了字符数组 stub_args 用来存放 execvp 执行命令的参数,而其中拼接而成的 ss 字符串中的部分内容来自于请求参数,因此存在命令注入漏洞 。

const char* stub_args[4];
stub_args[0] = "bash";
stub_args[1] = "-c";
stub_args[3] = nullptr; // Last argument must be nullptr [0]
...
ss << "source " << path_to_activate_
<< " && exec env LD_LIBRARY_PATH=" << path_to_libpython_
<< ":$LD_LIBRARY_PATH " << python_backend_stub << " " << model_path_
<< " " << shm_region_name_ << " " << shm_default_byte_size_ << " "
<< shm_growth_byte_size_ << " " << parent_pid_ << " " << python_lib_
<< " " << ipc_control_handle_ << " " << stub_name << " "
<< runtime_modeldir_;
ipc_control_->uses_env = true;
bash_argument = ss.str(); //[1]
...
stub_args[2] = bash_argument.c_str(); //[2]
...
execvp("bash", (char**)stub_args); //[3]

可以利用这个漏洞来实现RCE。

如何检测这个漏洞

在上一篇文章(https://medium.com/@Qubit18/from-xss-to-rce-critical-vulnerability-chain-in-anthropic-mcp-inspector-cve-2025-58444-7092ba4ac442)中,我发现了一个名为AI-Infra-Guard的开源AI红队安全测试平台(GitHub - Tencent/AI-Infra-Guard: A.I.G (AI-Infra-Guard) is a comprehensive, intelligent, and easy-to-use AI Red Teaming platform developed by Tencent Zhuque Lab.)它不仅可以检测 MCP 服务,还集成了 AI 基础设施的漏洞扫描能力,更新非常频繁。

它的文档显示已经支持了NvidiaTriton的漏洞检测,我试着按说明文档很快完成了部署:

git clone https://github.com/Tencent/AI-Infra-Guard.git
cd AI-Infra-Guard
docker-compose -f docker-compose.images.yml up -d

输入目标URL即可启动检测,输出的检测过程与报告如下:

可以看到,AI-Infra-Guard确实表现不错,一些最新的AI基础设施漏洞也支持检测。

补丁分析

安全补丁对输入参数进行了校验:(fix: Add input validation to model load by mattwittwer · Pull Request #404 · triton-inference-server/python_backend · GitHub)。

更新到最新版本的TritonInferenceServer即可修复漏洞。

参考链接

https://github.com/triton-inference-server

https://nvidia.custhelp.com/app/answers/detail/a_id/5691/~/security-bulletin%3A-nvidia-triton-inference-server---september-2025

https://medium.com/@Qubit18/from-xss-to-rce-critical-vulnerability-chain-in-anthropic-mcp-inspector-cve-2025-58444-7092ba4ac442

https://github.com/Tencent/AI-Infra-Guard


文章来源: https://www.freebuf.com/articles/vuls/450220.html
如有侵权请联系:admin#unsafe.sh