LiteLLM CVE-2026-40217 Now Exploited and in CISA KEV: Bytecode Tricks Escape the Guardrail Test Sandbox and Run Code as Root on AI Gateways — Update to 1.83.11 or Later by 2 December

CISA confirms attackers are exploiting a LiteLLM sandbox escape in /guardrails/test_custom_code that gives root code execution on AI gateways holding every model-provider key, so upgrade to 1.83.11+ (ideally the current 1.110.x), block the endpoint and replace default master keys.
Overview
CISA added CVE-2026-40217, a sandbox escape in the BerriAI LiteLLM proxy, to its Known Exploited Vulnerabilities (KEV) catalog on 18 November 2026. US federal agencies have until 2 December 2026 to fix it. The flaw sits in the /guardrails/test_custom_code endpoint. That endpoint lets an administrator try out a custom Python "guardrail" before saving it, and the code runs inside a sandbox the project wrote itself. Researchers showed that the sandbox can be escaped by rewriting Python bytecode at runtime. The result is arbitrary code execution in the proxy process, and that process runs as root in the default Docker image.
The bug is not new. It was reported privately in February, disclosed publicly on 8 April and fixed in the spring. What is new is CISA's confirmation that attackers are now using it. LiteLLM is a popular open-source gateway: one service that holds the API keys for OpenAI, Anthropic, Azure, Bedrock and other model providers and hands out "virtual keys" to internal teams. Anyone who controls the gateway gets every provider key behind it, the request logs, and often a route into the cloud account it runs in.
This is the fifth LiteLLM flaw added to KEV in 2026, after CVE-2026-42208 (SQL injection, May), CVE-2026-42271 (MCP test endpoint command injection, June) and CVE-2026-59822 (MCP authentication bypass, September).
The Vulnerability
- CVE: CVE-2026-40217 (GitHub advisory GHSA-wxxx-gvqv-xp7p)
- Component:
POST /guardrails/test_custom_codeon the LiteLLM proxy - Weakness: the vendor lists CWE-913 (improper control of dynamically managed code), CISA lists CWE-420 (unprotected alternate channel), and the researchers list CWE-94 (code injection)
- Scores: CVSS 3.1 8.8 (High) from the CVE assigner. The vendor gives CVSS 4.0 5.9 (Moderate) because it treats proxy-admin access as a high privilege, and the researchers give CVSS 4.0 8.7.
- Affected: the vendor advisory lists versions 1.81.8 up to but not including 1.83.10. NVD describes it as "LiteLLM through 2026-04-08".
- Fixed: the vendor advisory is inconsistent. Its version field says 1.83.10, but the text says the fix (replacing the home-made sandbox with RestrictedPython) shipped in 1.83.11. Treat 1.83.11 as the minimum. The current release on PyPI is 1.110.1.
The researchers found that the sandbox relied on regular-expression filters applied to the submitted source text. It blocked dangerous names and imports by matching strings, not by limiting what the code could actually do when it ran. Code that builds the blocked names at runtime and edits CPython code objects can reach the full built-ins, including the import system. From there the attacker can run operating-system commands as the LiteLLM user.
The endpoint needs authentication. According to the vendor, that means a proxy-admin credential in default configurations, while the researchers' advisory says the master key. That sounds like a high bar, but in practice it often isn't, for reasons covered under Tradecraft.
Timeline
- 13 February 2026: researchers identify the issue and build a proof of concept.
- 18 February 2026: LiteLLM acknowledges the report and promises a fix within about a week.
- 20 to 26 March 2026: the researchers chase a patch. One vendor contact address bounces, so they bring in the distros mailing list.
- 8 April 2026: the maximum embargo expires and the researchers publish with no patch available. Their advisory recommends blocking the endpoint.
- 10 April 2026: the CVE is published on NVD at 18:16 Mauritius time (14:16 UTC).
- 7 May 2026: LiteLLM publishes its GitHub advisory and moves to RestrictedPython in 1.83.11.
- 18 November 2026: CISA adds CVE-2026-40217 to KEV with a 2 December deadline. CISA's own vulnerability assessment on NVD marks exploitation as "active" and technical impact as "total".
CISA has not said who is exploiting the flaw, against which targets, or since when. A public proof of concept has been on GitHub for months.
Tradecraft
Earlier LiteLLM research shows several ways attackers can get the admin access this bug requires:
- Default master key. The LiteLLM master key defaults to
sk-1234in quick-start setups. Researchers report that it is also the secret used to sign session tokens. A February 2026 scan found that 9.6% of 3,074 internet-facing LiteLLM instances accepted the default key, and 6.2% needed no authentication at all. - Chaining with earlier KEV flaws. CVE-2026-42208 (pre-authentication SQL injection) exposes keys stored in the proxy database. CVE-2026-59822 lets any bearer token open an authenticated MCP session on unpatched builds.
- Stolen or leaked keys. Master keys often end up in
.envfiles, CI variables, notebooks and agent traces.
Once they can run code, attackers have predictable goals. They read provider API keys and database credentials from the environment and config, resell or abuse model access, and pivot to the cloud. Researchers have shown that LiteLLM pass-through endpoints do not validate target URLs. An admin can point one at the cloud metadata service (169.254.169[.]254) and pull IAM role credentials, which works even with IMDSv2 because of header forwarding. The vendor does not treat this as a vulnerability, so no fix exists.
Detection
Look for any use of the test endpoint, especially from addresses outside your admin network:
# Reverse proxy / ingress logs
grep -E 'POST /guardrails/test_custom_code' /var/log/nginx/access.log*
# Container logs
docker logs litellm 2>&1 | grep -i 'test_custom_code'
Also watch for:
- Shell,
curl,wget,python -cor package-manager processes spawned by the LiteLLM Python process. - Outbound connections from the gateway to unfamiliar hosts, or to 169.254.169[.]254.
- New or unexpected guardrails, pass-through endpoints, virtual keys or admin users.
- Model-provider bills or usage spikes that no internal team can explain.
To check the installed version:
pip show litellm | grep -i version
docker exec litellm pip show litellm | grep -i version
Recommended Actions
- Upgrade LiteLLM to the current release (1.110.x). At an absolute minimum, run 1.83.11 or later. The current release also closes the other four KEV-listed LiteLLM flaws.
- Block the endpoint at the reverse proxy if you cannot upgrade today:
location = /guardrails/test_custom_code { return 403; }
- Replace the master key if it was ever
sk-1234or has been shared widely, and rotate the virtual keys and session secrets. - Keep the admin UI and API off the internet. Put them behind a VPN or an IP allow-list.
- Run the container as a non-root user (
--user) and restrict outbound traffic so it can reach only the model providers you use. - Enforce IMDSv2 with a hop limit of 1 and give the gateway a least-privilege IAM role.
- If the gateway was exposed and unpatched, assume compromise. Rotate every upstream provider key and cloud credential it held, and review provider usage logs back to April.
Analyst Assessment
The vendor's "Moderate" rating understates the risk. In theory admin-only RCE is a contained problem. In practice LiteLLM is often deployed in a hurry by AI teams, with default keys and the admin API on the internet, and its admin role has already been reachable through two earlier KEV-listed bugs. The disclosure history is also a warning: the researchers waited eight weeks and had to publish with no fix available.
Organisations running AI gateways should treat them like identity providers or secrets vaults, not developer tools. A single LiteLLM instance can hold an organisation's entire paid AI access plus a cloud role, and attackers clearly know it. We rate this High for any exposed instance and urgent where default credentials may still be in place.
