Skip to main content
CVE-2026-40217 High Patch Available

CVE-2026-40217: LiteLLM Guardrail Sandbox Escape Can Give Root RCE, Now in CISA KEV

CVE Details

CVE ID CVE-2026-40217
CVSS Score 8.8
Severity High
Vendor BerriAI
Product LiteLLM
Patch Status Available
Published November 19, 2026
EPSS Score 20.6%
CISA Patch Deadline December 2, 2026

Background

LiteLLM is an open-source proxy that gives applications a single OpenAI-compatible API in front of more than 100 model providers. Teams run it as a central AI gateway, so the process holds provider API keys, a master key and routing configuration. A foothold there exposes every model credential the gateway manages.

LiteLLM supports custom-code guardrails: Python functions that inspect or modify traffic. The endpoint POST /guardrails/test_custom_code lets an authenticated user submit such a function and run it for testing. CVE-2026-40217 is a way out of the sandbox around that function. CISA added the CVE to KEV on 2026-11-18 with a due date of 2026-12-02.

Technical Mechanism

The CNA record is CWE-420 (Unprotected Alternate Channel); the GitHub advisory also lists CWE-913. The CVE.org text says LiteLLM through 2026-04-08 “allows remote attackers to execute arbitrary code via bytecode rewriting at the /guardrails/test_custom_code URI.”

Two independent write-ups describe the mechanism:

  • X41 D-Sec (advisory X41-2026-001, published 2026-04-08): the endpoint restricts dangerous operations with regex-based source filtering. That filtering works on source text only, so bytecode-level techniques bypass it. X41 rates it CVSS 4.0 8.7 (High) and notes execution as the user running LiteLLM, root in the default Docker image.
  • Zenity Labs (2026-06-30): the sandbox is effectively a text deny-list for words such as import, code and globals. Payloads avoid the forbidden words, then reach Python internals through generator or coroutine attributes (gi_code, cr_frame) to recover the real builtins and call import. Zenity reproduced captured payloads against LiteLLM 1.83.0 in a lab.

Precondition: the GitHub advisory states that reaching the endpoint requires a proxy-admin credential in default configurations. The advisory does not say why the CVSS vector uses PR:L. Zenity’s honeypot data shows attackers guessing default master keys such as sk-1234, so a weak or default master key removes that barrier in practice.

Real-World Exploitation Evidence

  • CISA KEV: added 2026-11-18, due 2026-12-02, ransomware use “Unknown”.
  • CISA-ADP SSVC (timestamp 2026-06-15): Exploitation “active”, Automatable “no”, Technical Impact “total”.
  • Zenity Labs honeypots: between 2026-04-15 and 2026-05-24, sensors recorded 569 POST requests to /guardrails/test_custom_code. The requests carried 47 distinct guessed Authorization: Bearer sk-... master-key values, plus 64 requests with empty headers. On 2026-04-15, 520 identical {'probe':1} capability checks arrived. In May, payloads from different IPs dumped os.environ (filtering for names like key, secret, aws, openai, anthropic, master) and ran shell commands through subprocess.Popen.

Possible privilege-escalation chain (single-source, unverified): a Cloud Security Alliance research note dated 2026-06-17 cites an Obsidian Security chain of CVE-2026-47101, then CVE-2026-47102, then CVE-2026-40217, in which a low-privilege user escalates to proxy admin and then runs code. We have not opened Obsidian’s own post. If accurate, the admin-credential precondition would not require a guessed master key. The same note concerns a different LiteLLM CVE, CVE-2026-42271, which is not covered here.

Zenity describes these as attempts against its honeypots. It does not say they succeeded against real deployments, and we did not find a public report of confirmed victim compromise. Attribution to a named actor is not made in any source we reviewed.

Impact Assessment

Successful exploitation yields code execution in the proxy process. In the default Docker image that is root. Zenity’s captured payloads target environment variables holding provider and master keys, and Zenity notes the database connection string and cloud credentials as exposed. Our assessment (not from the sources): stolen provider keys could also be used to run up spend, and a root process could serve as a pivot into the network it sits in.

Our assessment: exposure is highest for internet-reachable LiteLLM proxies with default or guessable master keys.

Affected Versions

The GitHub advisory GHSA-wxxx-gvqv-xp7p lists affected versions as >= 1.81.8, < 1.83.10 (pip litellm). The CVE.org record itself identifies the affected build only by Docker image digest main-latest (sha256:bb0639...) and “through 2026-04-08”.

Fix version discrepancy: the advisory text says “Fixed in 1.83.11” and the structured field says first patched version 1.83.10; the linked release is v1.83.10-stable. Zenity states a 1.83.10 fix on 2026-04-15, but PyPI shows 1.83.10 uploaded on 2026-04-19 and 1.83.11 on 2026-04-22, and the GitHub release v1.83.10-stable was created 2026-04-22 and published 2026-04-27. We use the registry dates. Upgrade to 1.83.11 or later to satisfy both readings. The fix replaces the hand-rolled sandbox with RestrictedPython.

CVSS: the CNA (MITRE) score and the GitHub advisory CVSS 3.1 score are both 8.8 High, CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H. X41 rates 8.7 under CVSS 4.0 (AC:L/PR:L); the GitHub advisory carries a CVSS 4.0 score of 7.5. NVD also lists a second secondary 8.8 from another source with CWE-94; we have not identified that source.

Remediation Steps

  1. Upgrade litellm to 1.83.11 or later (pull a current Docker image tag, not main-latest from before the fix).
  2. If you cannot upgrade immediately, block POST /guardrails/test_custom_code at the reverse proxy or API gateway (vendor workaround).
  3. Replace any default or documented master key (sk-1234 and similar). Rotate the master key and issue scoped virtual keys.
  4. Run the proxy as a non-root user; LiteLLM ships a non-root image variant.
  5. Do not expose the admin and guardrail endpoints to the internet. Restrict by network policy or allowlist.
  6. If the endpoint was reachable before patching, rotate all provider API keys stored in the proxy environment and review provider billing for anomalies. CISA does not require forensic triage for this entry, but key rotation is prudent.

Detection Guidance

  • Search proxy and reverse-proxy access logs for any request to /guardrails/test_custom_code, especially from external IPs. Legitimate use is rare outside admin testing.
  • Alert on repeated 401 responses on that path followed by a 200, a sign of master-key guessing then success.
  • Request bodies containing gi_code, cr_frame, __import__, os.environ or string-concatenated builtin names match the payload styles Zenity documented.
  • On the host or container, look for child processes spawned by the LiteLLM Python process (shell, curl, wget) and outbound connections not matching provider endpoints.
  • Review provider dashboards for unfamiliar usage or newly created keys.

Timeline

DateEvent
2026-04-08X41 D-Sec publishes advisory X41-2026-001 (CVE “TBD” at that time)
2026-04-10CVE-2026-40217 published (MITRE CNA)
2026-04-15Zenity honeypot probing begins (Zenity also states a fix this day; registry dates conflict, see below)
2026-04-19litellm 1.83.10 uploaded to PyPI
2026-04-22litellm 1.83.11 uploaded to PyPI
2026-05-11GitHub Security Advisory GHSA-wxxx-gvqv-xp7p published
2026-05-24End of Zenity’s reported honeypot observation window
2026-06-15CISA-ADP SSVC records Exploitation “active”
2026-06-30Zenity Labs publishes honeypot analysis
2026-11-18CISA adds the CVE to KEV
2026-12-02CISA KEV remediation due date

Public PoC repositories exist for this CVE (found on GitHub 2026-11-19); we have not vetted them and they should be treated as untrusted.

References