CVE-2026-40217 - BerriAI LiteLLM Unprotected Alternate Channel Vulnerability

CVE-2026-40217

LiteLLM - Guardrail Sandbox Escape to Root RCE on the AI Proxy

What is LiteLLM?

LiteLLM, from BerriAI, is an open source proxy that puts one OpenAI-compatible API in front of a hundred or more model providers. An organization points its applications at the LiteLLM gateway instead of at OpenAI, Anthropic, Bedrock, or Vertex directly, and the proxy handles provider routing, retries and fallbacks, per-team budgets and rate limits, key issuance, request logging, and "guardrails" that inspect prompts and responses before they are passed on. It is one of the most widely deployed pieces of AI infrastructure in enterprises, and it ships embedded in other vendors' products.

That position makes the gateway a concentrated store of secrets. Every provider API key the organization owns is in its environment or configuration, every virtual key it has issued to internal teams is in its database, and every prompt and completion flowing through it is visible in the process. Compromising the proxy is not like compromising one application; it is compromising the credential set and the traffic of every application that uses it.

Overview

CVE-2026-40217 is a sandbox escape in LiteLLM's custom-code guardrail tester. The endpoint POST /guardrails/test_custom_code is a developer convenience: it accepts a Python snippet, runs it, and shows what the guardrail would do. The code is supposed to be confined by a sandbox. That sandbox was a hand-rolled deny-list of dangerous keywords, and a deny-list is not a sandbox. An attacker who can reach the endpoint escapes it and runs arbitrary Python inside the proxy process.

Two facts turn an awkward bug into a serious one. The official LiteLLM Docker image runs the proxy as root, so the escape yields root-level code execution rather than an unprivileged shell. And reaching the endpoint requires a proxy-admin credential, which in practice means the master key: a large share of real deployments keep a default or guessable value such as sk-1234, so attackers simply pair the exploit with a short list of guessed bearer tokens.

Scores disagree because the raters disagree about how hard the escape is. NVD assigns 8.8 High under CVSS v3.1 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H). The GitHub Security Advisory assigns CVSS v4.0 7.5 with high attack complexity and high privileges required, and X41 D-Sec rated its own finding 8.7 under CVSS v4.0 with low privileges required. CISA added the CVE to the KEV catalog on 2026-11-18 with a BOD 26-04 deadline of 2026-12-02, the longest of the four entries in that batch.

Affected Versions

Product Vulnerable Fixed
BerriAI LiteLLM (pip litellm) 1.81.8 up to 1.83.10 1.83.10-stable (released 2026-04-15)
LiteLLM Docker image main-latest Builds through 2026-04-08 Rebuild on 1.83.10-stable or later

The GitHub advisory is internally inconsistent: its machine-readable metadata gives 1.83.10 as the patched version while its Patches section names 1.83.11. The vendor release that contains the RestrictedPython rewrite is tagged v1.83.10-stable. Upgrading to 1.83.11 or later removes the ambiguity. Red Hat has also issued errata (reported as RHSA-2026:24866 and RHSA-2026:30056) for products that embed LiteLLM, including Ansible Automation Platform and OpenShift AI, so check downstream packaging rather than assuming a direct pip install is the only exposure.

Technical Details

The CVE record assigns CWE-420 (unprotected alternate channel); the GitHub advisory adds CWE-913 (improper control of dynamically-managed code resources), and X41 classified it as CWE-94 code injection. All three describe the same shape: a debug facility that executes caller-supplied code is reachable over the network, and the guard around it is cosmetic.

The sandbox filtered dangerous identifiers with a regular expression deny-list. Because Python resolves attribute names at runtime, an attacker never has to write a blocked name literally: assembling __globals__ or __import__ from string fragments and concatenating them at execution time defeats the filter entirely. The snippet is run through exec() with a globals dictionary stripped of builtins, but Python re-injects builtins into any execution frame that lacks them, so the restriction is not load-bearing. From there the published escapes walk generator and coroutine internals, gi_code, cr_frame, and f_builtins, to reach the real __import__ and from there os and subprocess.

The attack is a single authenticated HTTP POST. There is no race, no memory corruption, and no chaining requirement, though chaining is available: Obsidian Security published a path combining CVE-2026-47101 and CVE-2026-47102 with this flaw that takes a low-privilege LiteLLM user all the way to admin and then to code execution, which removes the proxy-admin precondition that the CVSS vectors lean on.

The fix in 1.83.10-stable abandons the deny-list and executes guardrail code under RestrictedPython instead.

Discovery

The vulnerability was found by Markus Vervier of X41 D-Sec GmbH and published as advisory X41-2026-001. The embargo ended on 2026-04-08 and the advisory went to the oss-security mailing list shortly after, with the CVE published on 2026-04-10 and the GitHub Security Advisory following on 2026-05-11.

Follow-on research came from two directions. Zenity Labs instrumented honeypots and documented the attack traffic against the endpoint. Obsidian Security audited LiteLLM's authorization model and found the privilege escalation chain that pairs with this bug, reporting that guardrail CRUD endpoints also called exec() while leaving __builtins__ reachable.

Exploitation Context

Zenity Labs recorded 569 POST requests to /guardrails/test_custom_code across its honeypots between 2026-04-15 and 2026-05-24. The first wave, 520 identical capability probes carrying {'probe':1}, arrived on 2026-04-15, the same day the fix shipped. The requests cycled through 47 distinct guessed bearer values including sk-1234, sk-admin, and sk-changeme, and 64 arrived with an empty Authorization header. Zenity assessed this as targeted exploitation rather than untargeted internet scanning, and reproduced the escape in a lab on version 1.83.0, where the payloads both leaked a planted canary secret and executed shell commands.

The payloads seen in May were unambiguously malicious rather than exploratory: one dumped dict(os.environ) to exfiltrate provider keys, the master key, and cloud credentials in one shot, and another executed commands through subprocess.Popen(..., shell=True). Source addresses reported by Zenity include 173.249.198.201, 108.78.4.10, 216.26.226.182, 5.34.179.24, and 164.52.192.134, with six of the eight observed addresses also appearing in the same team's separate LiteLLM control-plane findings. One address is given inconsistently in the write-up as 125.81.162.48 and 125.81.162.148, so verify before blocking either.

CISA has named no actor, and the KEV entry records no known ransomware use. The practical loss model is credential theft: a successful request returns every API key the gateway holds.

Remediation

  1. Upgrade LiteLLM to 1.83.11 or later (the RestrictedPython rewrite landed in v1.83.10-stable). Rebuild container images rather than relying on a cached main-latest tag, and apply the relevant Red Hat errata for products that bundle LiteLLM.
  2. If you cannot upgrade immediately, block POST /guardrails/test_custom_code at the reverse proxy or API gateway. This is the vendor-stated workaround and it is effective.
  3. Rotate the master key away from any default or guessable value, and rotate it again after upgrading if the proxy was exposed. sk-1234 and its relatives are being tried at scale.
  4. Stop running the proxy as root. Override the user in the official Docker image so that a future escape lands in an unprivileged account.
  5. Take the LiteLLM control plane off the public internet. Admin endpoints should be reachable only from an internal network or through a VPN; applications can still reach the completion endpoints without that exposure.
  6. Review access logs for any POST to /guardrails/test_custom_code, for repeated requests cycling through default sk- bearer values, and for request bodies containing runtime dunder reconstruction, gi_code, cr_frame, f_builtins, dict(os.environ), or subprocess.Popen. Check for connections from the addresses listed above.
  7. If exploitation is confirmed or cannot be ruled out, treat every secret the proxy could read as compromised: all upstream provider API keys, every virtual key issued to teams, database credentials, and any cloud instance credentials available from the host. Revoke and reissue rather than rotating in place.
  8. Federal civilian agencies must remediate by 2026-12-02 under BOD 26-04, or discontinue use of the product if mitigations are unavailable.

Key Details

PropertyValue
CVE ID CVE-2026-40217
Vendor / Product BerriAI - LiteLLM
NVD Published2026-04-10
NVD Last Modified2026-11-18
CVSS 3.1 Score8.8
CVSS 3.1 VectorCVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
SeverityHIGH
CWE CWE-420 find similar ↗
CISA KEV Added2026-11-18
CISA KEV Deadline2026-12-02
Known Ransomware Use No

CVSS 3.1 Breakdown

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

Required Action

CISA BOD 26-04 Deadline: 2026-12-02. Apply mitigations in accordance with vendor instructions, ensuring compliance with CISA's BOD 26-04 Prioritizing Security Updates Based on Risk (see URL in Notes) guidance and CISA's "Forensics Triage Requirements" (see URL in Notes). Follow applicable BOD 26-04 guidance for cloud services or discontinue use of the product if mitigations are unavailable. Stakeholders are responsible for evaluating each asset's internet exposure and ensuring adherence to BOD 26-04 patching guidelines.

Timeline

DateEvent
2026-04-08X41 D-Sec embargo ends; advisory X41-2026-001 released
2026-04-10CVE-2026-40217 published
2026-04-15LiteLLM v1.83.10-stable ships the RestrictedPython fix; Zenity honeypots log the first mass probes the same day
2026-05-11GitHub Security Advisory GHSA-wxxx-gvqv-xp7p published to the advisory database
2026-05-24End of the observed honeypot exploitation window (569 POST requests in total)
2026-11-18Added to CISA Known Exploited Vulnerabilities catalog
2026-12-02CISA BOD 26-04 remediation deadline