LiteLLM CVE-2026-40217 Sandbox Escape Added to CISA KEV
CISA added LiteLLM CVE-2026-40217, a guardrail sandbox escape in the AI gateway admin API, to the KEV catalog on November 18, 2026. Patch to 1.83.11.
CISA added LiteLLM CVE-2026-40217 to the Known Exploited Vulnerabilities catalog on November 18, 2026. The flaw lets anyone holding a LiteLLM proxy admin credential run arbitrary code on the gateway host through the guardrail testing endpoint, and the default Docker image runs that process as root. BerriAI fixed it in LiteLLM 1.83.11. If you run a self-hosted LiteLLM proxy, confirm the version today, block the endpoint at your reverse proxy until you are patched, and review who holds the master key.
What CVE-2026-40217 is
The LiteLLM proxy, which BerriAI markets as an AI gateway, exposes an admin API endpoint at POST /guardrails/test_custom_code. It exists so an operator can submit Python guardrail code together with a sample request and see what the guardrail does before deploying it. Guardrails in LiteLLM are code that inspects, blocks or rewrites prompts and model responses on their way through the proxy; the documented pattern is a class with a single apply_guardrail method.
The test endpoint ran the submitted code inside a hand-built sandbox. That sandbox relied on pattern matching against the source text to block dangerous attributes and built-in functions. Markus Vervier of X41 D-Sec showed that a filter which only reads source text can be bypassed by techniques that operate below that level, and that the result is full code execution as the user the proxy runs as. In the default Docker image that user is root. This article does not reproduce the technique. The X41 advisory contains it for defenders who need to build detections, and the concept is explained in what a sandbox escape is and why application-level sandboxes fail.
The three records that describe the flaw do not agree on how to classify or score it:
- The CVE record and CISA file it as CWE-420, unprotected alternate channel. X41 calls it CWE-94, code injection. BerriAI's GitHub advisory uses CWE-913, improper control of dynamically managed code resources.
- The CVE record carries a CVSS 3.1 score of 8.8 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H). X41 scored it 8.7 on CVSS 4.0. BerriAI's own advisory rates it Moderate, 5.9 on CVSS 4.0, by setting Privileges Required to High and Attack Complexity to High.
The gap comes down to how much protection you credit to the admin credential requirement. CISA's listing answers the practical question: someone has used it in the wild.
Timeline: two months to a fix, seven months to KEV
X41's published timeline shows a slow disclosure. The researcher identified the issue and built a proof of concept on February 13, 2026. LiteLLM acknowledged it on February 18 and gave an estimated fix date of the end of the following week. X41 sent follow-ups on March 20 and March 24; the second bounced because the technical contact's mailbox no longer existed. X41 looped in the distros mailing list on March 25. BerriAI acknowledged receipt again on March 26 and on April 6 asked for the report to be resubmitted through its GitHub security page. The distros embargo expired on April 8 and X41 published with no patch available.
The CVE record was published on April 10, 2026. BerriAI's GitHub advisory, GHSA-wxxx-gvqv-xp7p, followed on May 7, 2026. It lists affected versions as 1.81.8 and later but before 1.83.10, states in its text that the fix shipped in 1.83.11, and says the hand-rolled sandbox was replaced with RestrictedPython. The advisory's metadata and its text therefore disagree by one patch release; heise's reporting also names 1.83.11. Treat 1.83.11 as the minimum.
CISA added the CVE on November 18, 2026 with a federal due date of December 2, 2026. The entry marks ransomware campaign use as Unknown and does not require forensic triage under BOD 26-04. The three other additions that day (Synology DSM, Apache Axis and REDCap) received a three-day deadline of November 21 and a forensic triage requirement, so CISA judged the LiteLLM activity as less urgent than those, but real.
Who is affected
Any self-hosted LiteLLM proxy running 1.81.8 through 1.83.10 is affected. X41 confirmed the bug against the ghcr.io/berriai/litellm:main-latest image as of early April 2026. Organizations that only use the LiteLLM Python SDK, without the proxy server, do not expose the endpoint.
Reaching the endpoint requires a proxy-admin credential in default configurations, which in practice means the master key. That narrows the attacker population to people who hold the key or have already stolen it. LiteLLM master keys have leaked before: the October 1.107.0 supply-chain compromise traced back to a committed master key, and virtual keys and provider credentials stored in the proxy database were the target in earlier incidents. Attackers also scan for LiteLLM gateways specifically, as the September CVE-2026-59822 MCP authentication bypass showed. This is at least the third LiteLLM flaw to enter the KEV catalog in 2026, after CVE-2026-42208 in May and CVE-2026-59822 in September.
The compounding factor is privilege. Because the default image runs the proxy as root, a successful call gives root inside the container: every file, every environment variable (which is where provider API keys usually live) and every mounted secret.
What to do now
- Inventory every LiteLLM proxy. Check containers, Kubernetes deployments and bare installs. Record the installed package version or image tag for each.
- Upgrade to 1.83.11 or later. BerriAI signs its container images with cosign and publishes the public key in the repository; verify the signature of the image you pull.
- Block the endpoint until you are patched. Both X41 and BerriAI recommend denying
/guardrails/test_custom_codeat the reverse proxy. X41's nginx example:
location /guardrails/test_custom_code { deny all; return 403; }
The full procedure, including the Caddy equivalent and how to verify it, is in how to block a URL path in nginx or Caddy.
- Rotate the master key and audit admin access. The key is the only control standing between an attacker and this endpoint. Issue a new one, store it in a secrets manager, and confirm regular API consumers hold virtual keys, not the master key.
- Stop running the proxy as root. X41 recommends the Docker
--userflag to run the container as an unprivileged user. The reasons and the Kubernetes equivalents are in why containers should not run as root. - Restrict the admin port. Firewall rules or security groups should limit the management interface to trusted hosts. Never expose it to the internet.
How to detect abuse
Start with the reverse proxy and application access logs. Legitimate use of POST /guardrails/test_custom_code is rare: an administrator testing a new guardrail during a change window. Any request to that path from an unexpected source address, outside a change window, or in volume, is a compromise indicator. Pull every hit since February 2026 if you have the retention.
Inside the container, look for child processes of the proxy that are not Python, outbound connections to hosts you do not recognize, and changes to files under the application directory. If you find any of these, assume every secret the proxy could read is exposed: the master key, all virtual keys, and every upstream provider API key configured in the proxy. Rotate them all, and check provider billing dashboards for unexplained usage.
CISA did not require forensic triage for this entry. Do it anyway if your gateway was reachable from outside the admin network, and preserve the container image and logs before you redeploy.
What to watch next
BerriAI's advisory metadata and text still disagree on the fixed version; a corrected advisory would settle whether 1.83.10 is safe. CISA has not published who is exploiting the flaw or how they obtained admin credentials. Sysdig and Wiz have both reported on earlier LiteLLM exploitation this year and are the most likely sources of indicators. The replacement sandbox is RestrictedPython, a mature library, but any feature that executes operator-supplied code remains a target, so keep the reverse proxy block in place even after patching unless you actively use guardrail testing.
Sources
- X41 D-Sec: Advisory X41-2026-001, Guardrail Sandbox Escape in LiteLLM
- BerriAI: GHSA-wxxx-gvqv-xp7p, Sandbox escape in custom-code guardrail
- CISA: Known Exploited Vulnerabilities Catalog
- CVE.org: CVE-2026-40217
- heise online: Angriffe auf Lücken in Apache Axis und Roller, LiteLLM, Synology und mehr
- LiteLLM docs: Build a Custom Guardrail
- Security Affairs: CISA adds a flaw in BerriAI LiteLLM to its KEV catalog (CVE-2026-42208, May 2026)