LiteLLM CVE-2026-40217: guardrail sandbox escape
LiteLLM /guardrails/test_custom_code endpoint, bytecode-based sandbox escape, the GHSA and X41 technical reports, NVD scores and CISA KEV records.

As of November 30, 2026, CVE-2026-40217 is a CISA KEV entry added on November 18 with a federal due date of December 2. It is a LiteLLM flaw in which the hand-rolled sandbox on /guardrails/test_custom_code is bypassed by manipulating Python bytecode rather than only source text. X41 D-Sec published the finding on April 8, 2026; the GitHub advisory followed on May 7; the NVD entry opened on April 10 and was updated on November 19. The critical boundary condition is that the endpoint requires a proxy-admin credential in default configurations.
Quick summary
| Field | Value |
|---|---|
| CVE | CVE-2026-40217 |
| Product | LiteLLM proxy, pip litellm package |
| Vendor advisory | GHSA-wxxx-gvqv-xp7p, May 7, 2026, Moderate 5.9 CVSS 4.0 |
| Research advisory | X41-2026-001, April 8, 2026, High 8.7 CVSS 4.0, CVE TBD at publication |
| Affected | >= 1.81.8 and < 1.83.10; X41 also confirmed the main-latest Docker image |
| Fixed | GHSA patched versions >= 1.83.10; its Patches section says 1.83.11; reference v1.83.10-stable |
| Weakness | KEV/NVD CWE-420; GHSA CWE-913; X41 and a NVD secondary source CWE-94 |
| CVSS 3.1 | 8.8 HIGH, [email protected] and Red Hat secondary metrics, PR:L |
| Condition | A proxy-admin or master key credential is required in default configurations |
| Impact | Arbitrary code in the proxy process; the default Docker image runs it as root |
| KEV | Added November 18, due December 2, forensicTriage: No, ransomware Unknown |
| SSVC | exploitation active, automatable no, technicalImpact total |
| Actor / IOC | Absent from the records |
Technical view
LiteLLM’s guardrail feature allows administrators to define custom Python code for input and output filtering. The /guardrails/test_custom_code endpoint takes the custom_code field from a JSON body and runs it as a test function. The hand-rolled sandbox tries to block dangerous attributes and built-ins with regex rules over the source text. X41’s analysis shows that those filters operate only at source level and can be bypassed through CPython bytecode manipulation.
The bypass works by constructing blocked names at runtime through string concatenation, obtaining the object class through str.mro(), rewriting a generator function’s code object with code.replace() and swapping __code__ so the rewritten bytecode reaches the real __builtins__ and __import__. The result is arbitrary command execution with the privileges of the proxy process. In the default Docker image that process runs as root. The source includes a detailed proof of concept; this article does not copy the command or request payload.
The authentication boundary matters. GHSA explicitly says that reaching the endpoint requires a proxy-admin credential in default configurations. X41 describes the vector as an “Authenticated HTTP API request” and advises keeping the master key away from ordinary API consumers. A title claiming unauthenticated RCE would therefore be wrong. The KEV short description mentions remote code execution without repeating the credential condition; the vendor advisory is the source for that detail.
There are three distinct score origins. GHSA assigns 5.9 CVSS 4.0 with PR:H, AC:H, VC:L, VI:L and VA:H. X41 published 8.7 CVSS 4.0 with PR:L at disclosure time. NVD carries two 8.8 CVSS 3.1 metrics, from [email protected] and Red Hat, both with PR:L. NVD also carries CISA Coordinator SSVC options exploitation active, automatable no and technicalImpact total. The automatable no value is consistent with the admin-credential requirement.
Version data has a small conflict. GHSA lists >= 1.81.8, < 1.83.10 as affected and >= 1.83.10 as patched, while the same page’s Patches section says the fix is in 1.83.11 and links v1.83.10-stable. The NVD CPE range marks 1.81.8 up to 1.83.10 as affected. The safest operational target is 1.83.11 or later; a claim that 1.83.10 is exactly sufficient is not unambiguous in the advisory.
NVD’s configuration data also names Red Hat products: Ansible Automation Platform before 2.6-9, OpenShift AI before 3.3.4 and OpenShift Lightspeed. NVD references RHSA-2026:24866, RHSA-2026:30056 and the Red Hat CVE page. Organizations using those distributions rather than direct pip installs can miss the flaw by checking only the pip package version.
What to do
- Upgrade. Move LiteLLM to 1.83.11 or later, or at least verify that the vendor’s patched version range is satisfied.
- Block the endpoint. If patching cannot happen immediately, deny
/guardrails/test_custom_codeat the reverse proxy or API gateway. - Protect the admin key. Keep the master key with trusted administrators only, do not share it with ordinary API consumers, and rotate it if exposure is suspected.
- Avoid a root container. The default Docker image runs as root; running as an unprivileged user limits post-exploitation impact.
- Check downstream products. Organizations using Red Hat Ansible Automation Platform, OpenShift AI or OpenShift Lightspeed should review the relevant RHSA records.
- Review logs. The KEV field says
forensicTriage: No, but exploitation is marked active. Reviewing admin API requests and master key use is still a reasonable local action. - Use the December 2 deadline. It is the federal due date and a useful prioritization reference for other organizations.
What not to claim
- Do not call this unauthenticated RCE. A proxy-admin or master key credential is required by default.
- Do not say NVD assigned 5.9. That value is GHSA’s CVSS 4.0 score; NVD carries two 8.8 CVSS 3.1 metrics.
- Do not claim root RCE is identical in every deployment. Root is tied to the default Docker image, and the admin credential condition remains.
- Do not claim ransomware was verified. The KEV field is
Unknown, with no actor or IOC. - Do not say forensic triage is mandatory. This entry has
forensicTriage: No. - Do not state that 1.83.10 is definitively sufficient. GHSA’s patched field and Patches section do not fully agree.
- Do not name an actor. The sources give no actor, victim or campaign name.
Status
As of November 30, 2026, CVE-2026-40217 is verified through the LiteLLM GHSA advisory, X41-2026-001, the NVD API record and the CISA KEV JSON. The sandbox escape mechanism and the admin-credential condition come from GHSA and X41; scores and SSVC data come from NVD; KEV fields come from CISA. CISA added the CVE on November 18 based on evidence of active exploitation and set a December 2 due date.
The open questions are clear: no actor, victim, IOC or campaign is named; GHSA’s patched-version information is internally inconsistent between 1.83.10 and 1.83.11; X41 published before a CVE was assigned and before a vendor patch existed; and the KEV short description does not repeat the credential requirement. This article limits its exploitation claim to the KEV and SSVC fields and makes no unauthenticated-access or ransomware claim.
From this series
- AutoGPT MCP CVE-2026-133462: permission confusion on an agent surface
- CISA BOD 26-04: SSVC and deadlines over CVSS labels
- Puppet Enterprise CVE-2026-115731: deserialization of untrusted data