Vulnerability
CISA Adds LiteLLM Guardrail RCE (CVE-2026-40217) to KEV as Attackers Hijack AI Gateways
CISA added CVE-2026-40217 in BerriAI LiteLLM to its Known Exploited Vulnerabilities catalog on November 18, 2026, setting a December 2 federal remediation deadline. The flaw lets attackers escape the custom-code guardrail sandbox via bytecode rewriting, exposing LLM provider keys, MCP tokens, and downstream AI agents to Man-in-the-Gateway hijacking. Here is the technical breakdown, affected versions, and defensive hardening playbook.
8 min read
CISA Adds LiteLLM Guardrail RCE (CVE-2026-40217) to KEV as Attackers Hijack AI Gateways
Executive Summary
On November 18, 2026, the U.S. Cybersecurity and Infrastructure Security Agency (CISA) added CVE-2026-40217—an arbitrary code execution vulnerability in BerriAI's LiteLLM AI proxy gateway—to its Known Exploited Vulnerabilities (KEV) Catalog, confirming active exploitation in the wild. Under CISA Binding Operational Directive (BOD) 26-04, Federal Civilian Executive Branch (FCEB) agencies must remediate affected deployments by December 2, 2026.
Classified under CWE-420 (Unprotected Alternate Channel) and CWE-94 (Code Injection), CVE-2026-40217 allows attackers to escape LiteLLM's custom-code guardrail sandbox via bytecode rewriting at the /guardrails/test_custom_code endpoint—and via unrestricted exec() execution on /guardrails CRUD endpoints—achieving remote code execution in the proxy runtime, which runs as root in the default Docker image. When chained with authorization bypass (CVE-2026-47101) and role-escalation (CVE-2026-47102) bugs fixed alongside it, a low-privilege internal_user can escalate to proxy_admin and compromise the host.
Because LiteLLM sits directly between AI agents and cloud model providers, host compromise exposes LITELLM_MASTER_KEY, LITELLM_SALT_KEY, DATABASE_URL, provider API keys, and Model Context Protocol (MCP) tokens—enabling both "LLMjacking" cost abuse and silent "Man-in-the-Gateway" tool-call injection.
Confidence Assessment:
- High Confidence: CISA KEV addition date (November 18, 2026), BOD 26-04 remediation due date (December 2, 2026), NVD/MITRE CVSS v3.1 score (
8.8 High), GitHub Advisory (GHSA-wxxx-gvqv-xp7p) affected range (>= 1.81.8, < 1.83.10), and full-chain patch version (v1.83.14-stable) are verified across primary advisories from CISA, NIST NVD, and GitHub. - Medium-Low Confidence (Campaign Telemetry): While threat intelligence from Google GTIG/Mandiant and Amazon documents active targeting of LiteLLM and CVE-2026-40217 for API key theft and LLMjacking, exact global victim counts and complete attribution for every exploiting cluster are not publicly itemized.
Technical Mechanics & Architecture
1. Root Cause: Custom-Code Guardrail Sandbox Escape (CWE-420 / CWE-913)
LiteLLM Proxy provides a Custom Code Guardrail feature so administrators can enforce custom Python logic across LLM requests and responses. Two compilation paths shared the same underlying sandbox defect:
- Playground Endpoint (
/guardrails/test_custom_code): Discovered by X41 D-Sec, this endpoint screened submitted Python source code against aFORBIDDEN_PATTERNSregular-expression deny-list. Attackers bypassed the static regex filter by submitting Python code that performs runtime bytecode rewriting, executing arbitrary code without containing blocked strings in the source text. - Production CRUD Endpoints (
POST /guardrails,PUT /guardrails/{id}): Documented by Obsidian Security,_compile_custom_code()invoked Python'sexec(compile(...), exec_globals)using aglobalsdictionary that omitted__builtins__. In Python, omitting__builtins__causesexec()to silently inject the full built-in module, exposing__import__,open, andeval.
BerriAI replaced the hand-rolled sandbox with RestrictedPython in 1.83.10 / 1.83.11 (v1.83.10-stable).
2. Chained Escalation: From internal_user to Host RCE
In default configurations, reaching /guardrails/test_custom_code requires proxy_admin privileges. However, Obsidian Security demonstrated that on versions prior to v1.83.14-stable, an unprivileged internal_user could chain three flaws into a CVSS 9.9 exploit path:
CVE-2026-47101(Route Gate Bypass): Calling/key/generatewithallowed_routes: ["/*"]persisted wildcard route access in the database without validating the caller's role, allowing aninternal_userto reach admin-only endpoints.CVE-2026-47102(Role Escalation): Calling/user/updateor/user/bulk_updatewithuser_role: "proxy_admin"succeeded because the handler lacked field-level authorization.CVE-2026-40217(Guardrail RCE): Withproxy_adminaccess, the attacker compiled malicious guardrail code or escaped the test sandbox, gainingrootcode execution inside the default Docker container.
3. Post-Compromise Impact: "Man-in-the-Gateway" & LLMjacking
Once an attacker executes code on the LiteLLM host, they gain access to:
- Proxy & Database Secrets:
LITELLM_MASTER_KEY,LITELLM_SALT_KEY(used to decrypt database-stored provider keys), andDATABASE_URL. - Provider & Agent Credentials: Plaintext or decryptable API keys for OpenAI, Anthropic, Gemini, AWS Bedrock, Azure OpenAI, plus OAuth tokens and MCP service credentials.
- Silent Callback Injection: LiteLLM supports lifecycle callbacks configured under
litellm_settings.callbacksinconfig.yamlthat do not appear in the admin UI. An attacker with host access can register a hidden callback to log prompts, exfiltrate secrets, or rewrite model responses in transit to inject forged tool calls into downstream coding agents.
Architectural Attack & Trust Boundary Flow
+-----------------------------------------------------------------------------+
| CALLER / AGENT CLIENT LAYER |
| |
| [ Low-Privilege internal_user ] OR [ Compromised proxy_admin Credential ]|
+------------------------------------+----------------------------------------+
|
v
+-----------------------------------------------------------------------------+
| LITELLM PROXY GATEWAY (TCP 4000) |
| |
| (Pre-1.83.14) CVE-2026-47101: /key/generate allowed_routes: ["/*"] |
| +------> CVE-2026-47102: /user/update user_role: "proxy_admin" |
| | |
| v |
| CVE-2026-40217: POST /guardrails/test_custom_code (Bytecode Rewrite) |
| or /guardrails CRUD (exec() with __builtins__ exposed) |
| | |
| v |
| [ Host Execution as 'root' (Default Docker) ] |
| - Reads LITELLM_MASTER_KEY / LITELLM_SALT_KEY / DATABASE_URL |
| - Harvests Cloud LLM Keys & MCP Tokens (LLMjacking) |
| - Plants hidden config.yaml callbacks (Man-in-the-Gateway) |
+------------------------------------+----------------------------------------+
|
v
+-----------------------------------------------------------------------------+
| CLOUD LLM PROVIDERS & DOWNSTREAM TOOLS |
| |
| [ OpenAI / Anthropic / Gemini / Bedrock ] [ Coding Agents / MCP Tools ] |
+-----------------------------------------------------------------------------+
Defensive Version & Configuration Audit Commands
Run the following read-only commands on your LiteLLM host or container to verify your installed version, execution privileges, and whether custom-code guardrails or unauthorized callbacks are configured:
# 1. Check installed LiteLLM Python package version (must be >= 1.83.14-stable)
python3 -c "import importlib.metadata; print(importlib.metadata.version('litellm'))"
# 2. Check if the running LiteLLM container executes as root (UID 0)
id
# 3. Inspect config.yaml for unexpected callbacks or custom_code guardrails
grep -nE "callbacks:|custom_code|guardrails:" /app/config.yaml 2>/dev/null || true
# 4. Verify if /guardrails/test_custom_code is reachable on your local proxy
curl -s -o /dev/null -w "%{http_code}\n" -X POST http://127.0.0.1:4000/guardrails/test_custom_code
If litellm reports a version between 1.81.8 and 1.83.9, it is directly vulnerable to CVE-2026-40217; if below 1.83.14, it remains exposed to the full CVE-2026-47101 / CVE-2026-47102 escalation chain.
Evidence & Production Impact
Severity & Scoring Comparison Across Advisories
Security databases score CVE-2026-40217 differently depending on whether they evaluate the standalone endpoint (PR:H or PR:L) or the full escalation chain:
| Source / Advisory | Score & Rating | Vector / Metric | Scope & Notes |
|---|---|---|---|
| NIST NVD (MITRE CNA & Red Hat SADP) | 8.8 (High) | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
Evaluates network exploitation with low privileges required. |
GitHub Advisory (GHSA-wxxx-gvqv-xp7p) |
7.5 (High) | CVSS:4.0/AV:N/AC:H/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
Assumes default proxy_admin requirement; notes 17.02% EPSS (97th percentile). |
| Obsidian Security (Chained Analysis) | 9.9 (Critical) | Chained (CVE-2026-47101 + 47102 + 40217) |
Reflects unprivileged internal_user escalating to root RCE on pre-1.83.14 builds. |
| CISA KEV Catalog | Active Exploitation | Added Nov 18, 2026; Due Dec 2, 2026 | Mandatory BOD 26-04 remediation and forensic triage for FCEB agencies. |
Active Exploitation & AI Infrastructure Targeting
In November 2026, Google's Threat Intelligence Group (GTIG) and Mandiant reported that threat actors exploited CVE-2026-40217 in LiteLLM to execute arbitrary code, deploy reverse proxies, and harvest cloud AI credentials for "LLMjacking" proxy resale—with one documented campaign generating nearly $1 million in fraudulent token charges against a victim organization (SecurityAffairs, Aviatrix). Separately, on November 16, 2026, Amazon disclosed an automated AI-agent scanning campaign targeting self-hosted LiteLLM, Dify, and One API instances to harvest and pool LLM provider keys.
Hardening Playbook
Execute the following six steps to remediate CVE-2026-40217 and harden LiteLLM deployments against gateway hijacking:
- Upgrade to LiteLLM
v1.83.14-stableor Later: While1.83.10/1.83.11introducedRestrictedPythonfor CVE-2026-40217, upgrading tov1.83.14-stableor newer closes the entire authorization-bypass and role-escalation chain (CVE-2026-47101andCVE-2026-47102). - Block Guardrail Compilation Endpoints at the Reverse Proxy: If you cannot upgrade immediately, explicitly deny external and non-admin access to
/guardrails/test_custom_codeand/guardrailsat your API gateway or Nginx/Envoy ingress:location ~* ^/guardrails(/test_custom_code)? { deny all; return 403; } - Drop Root Privileges in Container Deployments: Override the default Docker
rootuser by running the LiteLLM container with a dedicated non-root UID/GID (user: "10001:10001"), a read-only root filesystem, and dropped Linux capabilities (cap_drop: ["ALL"]). - Audit
proxy_adminAccounts, Virtual Keys, and Guardrails: Query your LiteLLM database for anyinternal_useraccounts recently promoted toproxy_admin, any virtual keys containing wildcardallowed_routes(["/*"]), and any unrecognized Custom Code Guardrails. - Verify
config.yamland Code Integrity for Hidden Callbacks: Inspectlitellm_settings.callbacksinconfig.yamland compare deployed Python files against upstream container digests to ensure no persistent "Man-in-the-Gateway" callback was planted prior to patching. - Rotate Secrets and Enforce Provider Spend Caps (Rollback Note): Under BOD 26-04, treat any internet-exposed unpatched LiteLLM instance as potentially compromised. Rotate
LITELLM_MASTER_KEY,LITELLM_SALT_KEY,DATABASE_URL, and all upstream LLM provider/MCP keys, and configure provider-level billing alerts. Back up your PostgreSQL database before upgrading; do not roll back belowv1.83.14-stableif regressions occur.
Defensive Detection Queries
1. Reverse Proxy / Ingress Log Hunt (Bash):
# Search Nginx/Ingress logs for guardrail compilation or key-escalation probes
sudo grep -E "(/guardrails/test_custom_code|/guardrails|/key/generate|/user/update)" /var/log/nginx/access.log | tail -n 100
2. Microsoft Sentinel / Defender KQL (Suspicious Child Processes from LiteLLM):
DeviceProcessEvents
| where Timestamp > ago(14d)
| where InitiatingProcessCommandLine has_any ("litellm", "uvicorn", "gunicorn")
| where FileName in~ ("sh", "bash", "dash", "curl", "wget", "nc", "socat", "python", "python3")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessCommandLine
| order by Timestamp desc
Frequently Asked Questions (FAQ)
1. Is CVE-2026-40217 actively exploited in the wild?
Yes. CISA added CVE-2026-40217 to its Known Exploited Vulnerabilities (KEV) Catalog on November 18, 2026, with a federal remediation deadline of December 2, 2026.
2. Why is v1.83.14-stable recommended instead of 1.83.10?
GitHub Advisory GHSA-wxxx-gvqv-xp7p notes the guardrail sandbox fix landed in 1.83.10 / 1.83.11, but Obsidian Security's disclosure confirms that v1.83.14-stable is the first release containing the complete fix set for the companion CVE-2026-47101 and CVE-2026-47102 escalation chain.
3. Does blocking /guardrails/test_custom_code alone stop all exploitation?
Blocking /guardrails/test_custom_code mitigates the specific bytecode-rewriting path cited in NVD and CISA KEV, but organizations should also restrict POST /guardrails and PUT /guardrails/{id} and upgrade to v1.83.14-stable or later.
4. What happens if an attacker compromises a LiteLLM proxy?
Beyond host RCE (often as root in default Docker deployments), attackers can decrypt stored LLM provider API keys using LITELLM_SALT_KEY, run up fraudulent cloud AI bills (LLMjacking), read conversation logs, and plant hidden config.yaml callbacks to manipulate downstream AI agents.
5. Which Red Hat products are affected according to NVD?
NVD's redhat-SADP data lists Red Hat Lightspeed Core as affected, while Red Hat Ansible Automation Platform 2.6 and Red Hat OpenShift AI (RHOAI) 3.3 have unaffected RPM builds documented in RHSA-2026:24866 and RHSA-2026:30056.
Sources
- CISA Alert (Primary): CISA Adds Four Known Exploited Vulnerabilities to Catalog — Published November 18, 2026.
- CISA KEV Catalog (Primary): Known Exploited Vulnerabilities Catalog — Updated November 18, 2026 (
Due Date: 2026-12-02). - NIST NVD (Primary): NVD - CVE-2026-40217 Detail — Published April 10, 2026; Last Modified October 26, 2026.
- GitHub Advisory Database (Primary): GHSA-wxxx-gvqv-xp7p: LiteLLM has a sandbox escape in custom-code guardrail — Published May 6, 2026; Reviewed May 11, 2026.
- Obsidian Security (Secondary Technical): Breaking LiteLLM: From Low-Privilege User to Admin and RCE (CVE-2026-47101, CVE-2026-47102, CVE-2026-40217) — Published June 11, 2026; Updated September 7, 2026.
- SecurityAffairs / Google GTIG (Secondary Threat Intel): Google GTIG Warns AI Agents Automate Exploits, Steal Credentials and Scale Cybercrime — Published November 17, 2026.