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.

By 0xScorPionSon

8 min read

CISA Adds LiteLLM Guardrail RCE (CVE-2026-40217) to KEV as Attackers Hijack AI Gateways

CVE-2026-40217 BerriAI LiteLLM custom-code guardrail RCE and CISA KEV telemetry infographic

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 a FORBIDDEN_PATTERNS regular-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's exec(compile(...), exec_globals) using a globals dictionary that omitted __builtins__. In Python, omitting __builtins__ causes exec() to silently inject the full built-in module, exposing __import__, open, and eval.

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:

  1. CVE-2026-47101 (Route Gate Bypass): Calling /key/generate with allowed_routes: ["/*"] persisted wildcard route access in the database without validating the caller's role, allowing an internal_user to reach admin-only endpoints.
  2. CVE-2026-47102 (Role Escalation): Calling /user/update or /user/bulk_update with user_role: "proxy_admin" succeeded because the handler lacked field-level authorization.
  3. CVE-2026-40217 (Guardrail RCE): With proxy_admin access, the attacker compiled malicious guardrail code or escaped the test sandbox, gaining root code 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), and DATABASE_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.callbacks in config.yaml that 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:

  1. Upgrade to LiteLLM v1.83.14-stable or Later: While 1.83.10 / 1.83.11 introduced RestrictedPython for CVE-2026-40217, upgrading to v1.83.14-stable or newer closes the entire authorization-bypass and role-escalation chain (CVE-2026-47101 and CVE-2026-47102).
  2. Block Guardrail Compilation Endpoints at the Reverse Proxy: If you cannot upgrade immediately, explicitly deny external and non-admin access to /guardrails/test_custom_code and /guardrails at your API gateway or Nginx/Envoy ingress:
    location ~* ^/guardrails(/test_custom_code)? {
        deny all;
        return 403;
    }
    
  3. Drop Root Privileges in Container Deployments: Override the default Docker root user 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"]).
  4. Audit proxy_admin Accounts, Virtual Keys, and Guardrails: Query your LiteLLM database for any internal_user accounts recently promoted to proxy_admin, any virtual keys containing wildcard allowed_routes (["/*"]), and any unrecognized Custom Code Guardrails.
  5. Verify config.yaml and Code Integrity for Hidden Callbacks: Inspect litellm_settings.callbacks in config.yaml and compare deployed Python files against upstream container digests to ensure no persistent "Man-in-the-Gateway" callback was planted prior to patching.
  6. 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 below v1.83.14-stable if 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.

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

More on Vulnerability

Vulnerability

CVE-2026-90817: How One Public REDCap Survey Link Exposes Servers to XMRig Attacks

On November 18, 2026, CISA added CVE-2026-90817—a CVSS 9.8 code injection flaw in Vanderbilt University's REDCap—to its Known Exploited Vulnerabilities (KEV) catalog with a November 21 federal deadline. Attackers only need a valid public survey hash to reach an internal data-import controller route, drop transient web shells, and deploy XMRig miners masquerading as syslog-ng. This defensive breakdown covers the routing flaw, unaffected releases (16.0.49, 17.3.10, 17.4.4), and persistence-hunting commands.

6 min read

Vulnerability

CVE-2024-10441: Why CISA Added Synology DSM and BeeStation OS to KEV Amid C3RB3R Attacks

On November 18, 2026, CISA added CVE-2024-10441—a CVSS 9.8 output-escaping flaw in Synology DiskStation Manager (DSM) and BeeStation OS—to its Known Exploited Vulnerabilities (KEV) catalog with a November 21 federal deadline. Linked to C3RB3R ransomware attacks targeting internet-exposed NAS appliances, the flaw requires immediate patching and network isolation. This defensive guide covers all five fixed builds, the ongoing advisory attribution discrepancy, and immutable backup hardening.

7 min read

Vulnerability

CVE-2026-90436: How an End-of-Life Apache Axis SOAP Bug Exposes Confluence and N-central

On November 18, 2026, CISA added CVE-2026-90436—an unsafe reflection vulnerability in end-of-life Apache Axis 1.x—to its Known Exploited Vulnerabilities (KEV) catalog with a three-day federal deadline of November 21. Rapid7 MDR observed active exploitation against Atlassian Confluence Data Center on November 13, alongside confirmed attacks against N-able N-central. This defensive breakdown covers the pre-handler SOAP fault reflection mechanism, affected versions, verified network IOCs, and immediate mitigation steps.

7 min read

Tell us what is not working

A thirty-minute call, no deck and no obligation. You will leave with a straight answer about whether this is worth building - including if that answer is no.

Start a project

Direct line

hello@codebumble.net
Dhaka, Bangladesh  :   local timeCalls in English or Bangla