LiteLLM CVE-2026-40217: Guardrail Escape, 4th KEV of 2026

By 11 min read
LiteLLM CVE-2026-40217: a guardrail test endpoint that runs Python escapes its sandbox as root

LiteLLM ships a feature that lets administrators test safety guardrails by sending Python code to the proxy, and that code was supposed to run in a sandbox. It did not stay there: a text filter was the only barrier, and the process behind it runs as root in the default Docker image.

In short: LiteLLM CVE-2026-40217 is a guardrail sandbox escape that gives an authenticated caller code execution on the LiteLLM proxy host. It was public in April 2026, fixed in late April, and added to CISA’s Known Exploited Vulnerabilities catalog on 18 November 2026, which makes it the fourth LiteLLM flaw in that catalog this year. If your gateway was reachable and unpatched, assume its keys are exposed.

What is LiteLLM CVE-2026-40217?

CVE-2026-40217 is a code-execution flaw in the custom-code guardrail feature of the LiteLLM proxy, published by BerriAI as GitHub advisory GHSA-wxxx-gvqv-xp7p. The vulnerable endpoint, POST /guardrails/test_custom_code, runs user-supplied Python inside what BerriAI calls a hand-rolled sandbox.

LiteLLM is an open-source gateway made by BerriAI that puts one API in front of many model providers, such as OpenAI, Anthropic, Azure and Bedrock. The GitHub repository had 64,160 stars and 13,678 forks when we checked on 30 November 2026.

A guardrail, in LiteLLM’s sense, is a check that inspects prompts or responses before they pass through the gateway, for example to block secrets or unsafe content. Custom-code guardrails let an administrator write that check in Python.

A sandbox is an environment meant to let untrusted code run without touching the rest of the system. X41 D-Sec, the German security firm that found the bug, describes this one as a regex filter on the source text, not a real isolation boundary.

Four figures for LiteLLM CVE-2026-40217: 4 KEV entries, 195 days, root user, 14-day deadline
The flaw waited 195 days between its GitHub advisory and the exploited list, and lands as root by default. Data: CISA KEV, BerriAI, X41 D-Sec.

Why is it in the CISA KEV catalog?

CISA’s KEV catalog lists vulnerabilities it has evidence are being exploited. CISA added CVE-2026-40217 on 18 November 2026 under the name “Unprotected Alternate Channel” and gave US federal civilian agencies until 2 December 2026 to fix it. The entry marks known ransomware use as unknown and names no victims.

How does the guardrail sandbox escape work?

This is a conceptual summary of the X41 advisory, not a procedure.

The filter only reads text

The test endpoint accepts Python source and checks it with regular expressions that look for dangerous names, such as the internal attributes that reach Python’s built-in functions and its import system. If the text passes, the code runs.

Python can build what the filter cannot see

According to X41, a caller can assemble blocked names at run time and use Python’s own internals, such as code objects and function attributes, to get back to the real built-in functions. CISA’s entry summarises the route as bytecode rewriting. Once the import machinery is reachable, the caller can run operating system commands.

The process is root

BerriAI’s advisory says the proxy runs as root in the default Docker image, and X41’s proof of concept output showed a root user ID. So a breakout is not limited to the LiteLLM application: it is code execution as the most privileged user in the container.

What changed in the fix?

BerriAI replaced the hand-rolled sandbox with RestrictedPython, a library that compiles Python with restrictions. The Cloud Security Alliance (CSA) points out that the RestrictedPython maintainers themselves say it is not a security boundary, so it should not be the only control.

How did attackers use CVE-2026-40217?

Google Threat Intelligence Group (GTIG) and Mandiant name the CVE in their 3 November 2026 report on LLMjacking. LLMjacking is the theft of paid access to AI models, usually by stealing API keys, cloud credentials or the gateway that holds them.

In Google’s account, one group gained initial access and a follow-on group obtained Virtual Keys that had already been checked to work. That second group exploited the victim’s LiteLLM gateway to raise standard Virtual Keys to full PROXY_ADMIN credentials. A Virtual Key is a key LiteLLM issues to users and apps so they never see the real provider keys.

Google’s 17 November AI Threat Tracker adds that privileged service accounts were enough for persistence without any malware. Google gives no cluster name or confidence level for the LiteLLM step.

Five-stage LLMjacking chain from obtaining Virtual Keys to proxy admin and resold model access
The gateway was the step that turned limited keys into control of every model behind it. Data: Google GTIG and Mandiant.

How much money is involved?

Google reports that some LLMjacking intrusions produced more than 100,000 US dollars of fraudulent model charges in one day, and that the worst cases reached 1 million dollars before access was cut. Those figures cover LLMjacking as a whole, not LiteLLM incidents alone, and Google does not split them out.

Victims in Google’s reporting were in financial services, retail, technology and transportation, across North America, South America and Asia Pacific. Stolen access was resold through what Google calls LLM Mixers, illicit gateways that resell model access cheaply.

Google describes the bug two ways

Google’s two reports do not agree on what CVE-2026-40217 is. The 3 November report calls it a user ID rebind flaw in the /key/regenerate endpoint. The 17 November tracker calls it a sandbox escape that elevates Virtual Keys.

BerriAI, X41 and CISA all describe the guardrail code-execution bug. The CSA notes that Obsidian Security tracks the key-route abuse and the self-promotion to proxy admin as two separate CVEs, CVE-2026-47101 and CVE-2026-47102. The CSA’s own reading is that the intrusions used the whole chain and Google filed it under one number, but the CSA says it has not confirmed that with Google.

Timeline: why did it take seven months?

The bug was found in February, public in April and fixed by the end of April. It reached KEV in November. X41’s disclosure log explains the early part: the vendor acknowledged the report quickly, then follow-ups went unanswered and one bounced, so the distros mailing list embargo expired and the advisory went out with no patch.

Timeline of CVE-2026-40217 from discovery in February 2026 to the December federal deadline
The fix existed for almost seven months before CISA confirmed exploitation. Data: X41 D-Sec, GitHub, Google GTIG, CISA.
Date Event Source
13 Feb 2026 X41 identifies the flaw and builds a proof of concept X41
18 Feb 2026 LiteLLM acknowledges and promises a fix within about a week X41
24 Mar 2026 Urgent follow-up bounces from the technical contact X41
8 Apr 2026 Embargo ends, X41 publishes advisory X41-2026-001 with no patch X41
27 Apr 2026 LiteLLM v1.83.10-stable released on GitHub GitHub
7 May 2026 BerriAI publishes GHSA-wxxx-gvqv-xp7p GitHub
3 Nov 2026 Google links the CVE to an LLMjacking intrusion GTIG, Mandiant
18 Nov 2026 CISA adds the CVE to KEV CISA
2 Dec 2026 US federal remediation deadline CISA

Who is affected and how do you check?

You are affected if you run a self-hosted LiteLLM proxy between version 1.81.8 and the fix, according to the GitHub advisory. The LiteLLM Python SDK used only as a library does not expose the proxy endpoint, though you should still check what your containers actually run.

Which version fixes CVE-2026-40217?

Sources give three answers:

Source Fixed version it names
GitHub advisory metadata 1.83.10
GitHub advisory text 1.83.11 or later
CSA, citing Obsidian Security 1.83.14-stable as the full baseline

The safe reading is to go to 1.83.14-stable or newer. The CSA also warns against litellm==1.107.0 and several floating Docker tags, which it says briefly served a credential stealer on 21 October 2026, citing StepSecurity. Pin by version and image digest.

How hard is it to reach?

The sources disagree on privilege. BerriAI rates it CVSS 4.0 5.9 with high privileges, saying a proxy-admin credential is needed in default configurations. X41 rates it 8.7 with low privileges, because its test needed only a valid key for the proxy, in its case the master key.

An earlier, related advisory matters here. CVE-2026-59821, fixed in 1.82.0-stable, says the production guardrail create and update paths skipped the sandbox, and that in deployments with no master key configured callers could be treated as proxy admins. A proxy with no master key set is much easier to reach.

Quick exposure check

  1. List every LiteLLM proxy, including staging, laptops and gateways bundled inside other products.
  2. Read the version from inside the running container, not from a manifest.
  3. Check whether the admin routes, including /guardrails, are reachable from the internet or from user networks.
  4. Confirm a master key is set and who holds it.

How do you detect exploitation?

CISA and Google publish no indicators of compromise for this CVE. Detection has to come from your own gateway and billing data. The CSA suggests these checks:

  • Reverse proxy and LiteLLM access logs: requests to /guardrails/test_custom_code and to POST /guardrails or PUT /guardrails/{id}, especially from unusual sources or at unusual times.
  • Role changes: calls to /user/update or /user/bulk_update that change user_role, and keys created with wide allowed_routes.
  • Proxy database: unexpected proxy_admin users, custom-code guardrails nobody wrote, new callbacks, and model api_base values that point at unknown hosts.
  • Container behaviour: the proxy process spawning shells or network tools, which a gateway has no reason to do.
  • Provider billing: sudden spend spikes. Google notes that attackers test stolen keys with tiny requests such as max_tokens=1 before using them heavily.

Google’s report names no ATT&CK IDs. The behaviour maps most closely to Exploitation for Privilege Escalation (T1068), Valid Accounts (T1078) and Resource Hijacking (T1496), but that mapping is ours, not Google’s.

Bar chart of days from GitHub advisory to CISA KEV for four LiteLLM CVEs in 2026
Each LiteLLM entry took longer to reach KEV, so patch on the advisory, not on the KEV listing. Data: BerriAI GHSA, CISA KEV.

How do you mitigate CVE-2026-40217?

In priority order:

  1. Upgrade every proxy to 1.83.14-stable or later, pinned by digest, and skip 1.107.0.
  2. Block POST /guardrails/test_custom_code at the reverse proxy if you cannot upgrade today. BerriAI and X41 both recommend this.
  3. Separate the admin and management routes from the inference API and keep them on an admin network or VPN.
  4. Run as non-root. Start the container with an unprivileged user so a breakout does not land as root.
  5. Lock down the master key. Keep it in a secrets manager, give it to a few named admins and never to API consumers or CI variables.
  6. Rotate the master key, provider keys, database credentials, Virtual Keys and cloud credentials the container could reach if the proxy was exposed while vulnerable.
  7. Audit stored configuration. The CSA notes that guardrails and callbacks live in the proxy database and survive an upgrade.

How does it compare with the other LiteLLM KEV entries?

All four LiteLLM entries in KEV this year sit in the proxy, and every one gives an attacker a path to the keys the proxy holds.

CVE Type GitHub advisory Added to KEV Fixed in
CVE-2026-42208 SQL injection in API key verification 20 Apr 2026 8 May 2026 1.83.7
CVE-2026-42271 Command execution via MCP stdio test endpoints 21 Apr 2026 8 Jun 2026 1.83.7
CVE-2026-59822 MCP authentication bypass 30 Jun 2026 2 Sep 2026 1.84.0
CVE-2026-40217 Guardrail sandbox escape 7 May 2026 18 Nov 2026 1.83.10

The pattern looks like other AI infrastructure flaws, such as the GPUStack authentication bypass that was exploited months after its fix. Gateways hold money in the form of keys, so attackers return to them. Amazon’s honeypots saw the same appetite when ARTEX AI agents raided exposed LiteLLM servers for provider keys, and the Cursor breach showed how far a single AI vendor key can travel.

The catch: test endpoints are production code

Two of the four bugs, CVE-2026-42271 and CVE-2026-40217, live in endpoints meant for testing. A feature that runs code on request is a remote execution feature, whatever it is called. If your gateway exposes “test” routes, they need the same protection as anything else.

What is still unknown?

  • Victims. CISA names none, and Google gives no count of LiteLLM intrusions.
  • The exact bug Google saw. Google describes CVE-2026-40217 two different ways, and the CSA’s three-CVE explanation is unconfirmed.
  • The fixed version. 1.83.10, 1.83.11 and 1.83.14 all appear in sources.
  • Severity. BerriAI says 5.9 with high privileges, X41 says 8.7 with low privileges.
  • Key theft and cryptomining. Some vendor blogs say attackers stole provider keys and ran miners through this CVE. We found no primary source for that and left it out.

The bottom line

LiteLLM CVE-2026-40217 is not an unauthenticated internet worm. It is a code-execution door behind an admin key, and Google’s reporting shows attackers who already had keys found a way to use it.

Upgrade to 1.83.14-stable or later, take the guardrail test endpoint off the network, stop running the proxy as root, and treat every key on an exposed gateway as burned.

Sources

This article is written for defenders and authorised security testers. Only test systems you own or have written permission to assess.

Frequently asked questions

What is LiteLLM CVE-2026-40217?

CVE-2026-40217 is a sandbox escape in the LiteLLM proxy's custom-code guardrail feature. The POST /guardrails/test_custom_code endpoint runs user-supplied Python behind a text filter that can be bypassed, which lets the caller run arbitrary code in the proxy process.

Is CVE-2026-40217 being exploited?

Yes. CISA added CVE-2026-40217 to its Known Exploited Vulnerabilities catalog on 18 November 2026. Google Threat Intelligence Group also names it in an LLMjacking intrusion, though CISA itself names no victims or actors and lists ransomware use as unknown.

Which LiteLLM versions are affected by CVE-2026-40217?

BerriAI's GitHub advisory lists litellm versions from 1.81.8 up to but not including 1.83.10. The advisory text says to upgrade to 1.83.11 or later, and the Cloud Security Alliance recommends 1.83.14-stable as a baseline because later fixes closed related bugs.

Does CVE-2026-40217 need authentication?

Yes. BerriAI says reaching the endpoint requires a proxy-admin credential in default configurations, and X41 D-Sec's proof of concept used the master key. Google reports that attackers combined it with stolen Virtual Keys, so a leaked key of any kind raises the risk.

What should I do if I cannot upgrade LiteLLM right away?

Block POST /guardrails/test_custom_code at your reverse proxy or API gateway, keep the admin interface off untrusted networks, keep the master key with a few named administrators and run the container as an unprivileged user so a breakout does not land as root.

How do I know if my LiteLLM proxy was exploited?

Search proxy and reverse-proxy logs for requests to /guardrails/test_custom_code and /guardrails, look for new proxy_admin users, unfamiliar custom-code guardrails, new callbacks or model api_base values pointing at unknown hosts, and check provider billing for sudden spend spikes.

What is LLMjacking?

LLMjacking is the theft of access to paid AI models, usually through stolen API keys, cloud credentials or a compromised AI gateway. Google says some intrusions ran up more than 100,000 US dollars in model charges in a single day.

What is a LiteLLM Virtual Key?

A Virtual Key is a key the LiteLLM proxy issues to users and applications so they can call models without seeing the real provider keys. Each Virtual Key can be limited to certain models, routes and budgets, unlike the master key, which has full admin rights.

Keep reading

LiteLLM CVE-2026-40217LiteLLMCISA KEVAI gateway securityLLMjackingvulnerability managementsandbox escape