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

High · 2026-11-19 · By H.A

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

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

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:

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:

To check the installed version:

pip show litellm | grep -i version
docker exec litellm pip show litellm | grep -i version

Recommended Actions

location = /guardrails/test_custom_code { return 403; }

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.

Sources

REEF SENTINEL