An actively exploited vulnerability in BerriAI LiteLLM’s guardrail testing feature allows authenticated attackers to break out of a security sandbox and execute arbitrary code on the proxy server. The flaw, tracked as CVE-2026-40217, was added to CISA’s Known Exploited Vulnerabilities catalog on November 18, 2026, which means the agency has evidence that it is being exploited in the wild.
Quick Take
- What: CVE-2026-40217 is a sandbox escape in LiteLLM’s
/guardrails/test_custom_codeendpoint that allows authenticated attackers to execute arbitrary code via bytecode rewriting. - Who is affected: The LiteLLM GitHub advisory lists litellm versions from 1.81.8 and below 1.83.10 as affected; NVD describes LiteLLM through 2026-04-08. The default Docker image runs the proxy as root, which maximizes the impact.
- Severity: NVD rates it CVSS 8.8 (high); the GitHub advisory rates it medium. CISA lists it as known exploited. Reaching the endpoint requires a proxy-admin credential in default configurations.
- What to do: Upgrade to version 1.83.11 or later immediately. If upgrading is not possible, block
POST /guardrails/test_custom_codeat your reverse proxy or API gateway. - Status: Actively exploited according to CISA. The GitHub advisory, published May 7, 2026, says the flaw is fixed in 1.83.11.
In plain English
LiteLLM is a tool that companies put between their apps and AI services, so one setup can talk to many AI providers. One of its admin features lets people test small pieces of their own code, and that feature was supposed to block anything dangerous. Researchers showed that the protection could be tricked, so someone holding an admin key could run any command on the server. The US cyber agency CISA now says attackers are actively using this flaw. Ordinary users do not need to do anything, but teams that run LiteLLM should update to version 1.83.11 or later right away.
What happened
The vulnerability exists in LiteLLM’s POST /guardrails/test_custom_code endpoint, which allows authenticated users to submit Python code for guardrail testing. According to the GitHub security advisory GHSA-wxxx-gvqv-xp7p, the endpoint runs user-supplied Python inside a hand-rolled sandbox that attempts to restrict dangerous operations using regex-based source code filtering.
Researchers at X41 D-Sec discovered that this filtering operates only at the source code level and can be bypassed through a combination of string concatenation and CPython bytecode manipulation. The X41 advisory X41-2026-001 describes the bypass in six steps.
The researchers built blocked names such as __globals__ and __import__ at runtime from string pieces so the regex filter never saw them, then rewrote a generator function’s bytecode to reach the real Python builtins. With that access they could import os and run shell commands. In the default Docker deployment their test command returned uid=0(root), which confirms code execution as root. X41 published a working proof of concept with its advisory.
The NVD entry assigns CVE-2026-40217 a CVSS 3.1 base score of 8.8 HIGH with vector CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H, indicating network-accessible exploitation requiring low privileges and no user interaction. The vulnerability is classified under CWE-420 (Unprotected Alternate Channel) and CWE-94 (Code Injection).
CISA added CVE-2026-40217 to its Known Exploited Vulnerabilities catalog on November 18, 2026, with a due date of December 2, 2026, for US federal agencies to apply mitigations. The CISA entry confirms that the vulnerability is actively exploited, though no specific ransomware campaign use is noted.
The GitHub advisory states that reaching the endpoint requires a proxy-admin credential in default configurations. However, once authenticated, an attacker gains full code execution in the proxy process.
X41 D-Sec disclosed the vulnerability to BerriAI on February 13, 2026. After multiple follow-ups and coordination challenges, the maximum embargo period expired on April 8, 2026. BerriAI published its GitHub advisory GHSA-wxxx-gvqv-xp7p on May 7, 2026. It says the flaw is fixed in 1.83.11, where the hand-rolled sandbox has been replaced with RestrictedPython; the same advisory lists 1.83.10 as the first patched version and links the v1.83.10-stable release.
What you should do
Upgrade LiteLLM to version 1.83.11 or later, the version the GitHub advisory names as fixed. In that release the hand-rolled sandbox has been replaced with RestrictedPython.
If upgrading is not immediately possible, the advisory recommends blocking POST /guardrails/test_custom_code at your reverse proxy or API gateway. The X41 advisory provides an nginx example:
location /guardrails/test_custom_code {
deny all;
return 403;
}Additional mitigations from the X41 advisory include:
- Restrict access to the admin API by ensuring the master key is only known to trusted administrators.
- Use network-level controls (firewall rules, VPC security groups) to limit access to the LiteLLM admin port to trusted hosts only.
- Avoid running LiteLLM as root by using
--userto run the Docker container as an unprivileged user.
CISA directs US federal agencies to apply mitigations in accordance with vendor instructions, following CISA BOD 26-04 guidance, or discontinue use of the product if mitigations are unavailable.
What it means
CVE-2026-40217 shows the risk of hand-rolled sandboxes for running user code. Filtering the source text with regular expressions did not stop bytecode-level manipulation. The CISA listing means LiteLLM deployments are now a confirmed target.
The impact is amplified by LiteLLM’s default Docker image, which runs the proxy process as root, so successful exploitation gives the attacker root inside the container. Because LiteLLM sits between applications and many LLM providers, the proxy process is where an organization’s gateway configuration lives.
The disclosure timeline was slow. X41 D-Sec identified the issue on February 13, 2026, published its advisory when the embargo ran out on April 8, 2026, and BerriAI’s advisory followed on May 7, 2026. CISA added the flaw to its catalog on November 18, 2026, with a December 2, 2026 deadline for US federal agencies.
For organizations using LiteLLM, the main barrier is the proxy-admin credential. X41 recommends keeping the master key with trusted administrators only and keeping the admin port off untrusted networks, in addition to patching.
The fix replaces the custom sandbox with RestrictedPython, an existing library for running restricted Python code, rather than patching the regex filter.
This is not the first serious LiteLLM flaw this year: see our report on CVE-2026-35029, a LiteLLM gateway authorization bypass that enabled remote code execution. Hand-built sandboxes for running code keep failing in AI tools, as the Beta9 sandbox escapes showed. New cases are tracked in our AI Security hub.
Sources
- CISA Known Exploited Vulnerabilities Catalog
- NVD CVE-2026-40217
- GitHub Security Advisory GHSA-wxxx-gvqv-xp7p
- X41 D-Sec Advisory X41-2026-001



