The LiteLLM Guardrail Tester Ran Code, and CISA Already Lists It as Exploited

On November 18, 2026, CISA added four vulnerabilities to its KEV catalog, the list of flaws with evidence of real exploitation. One of them is CVE-2026-40217, in LiteLLM, an open source proxy with 63,511 stars on GitHub that sits in front of model providers to unify their APIs, balance load and control spending.

The flaw is not in request routing or in key management. It is in a testing feature: the POST /guardrails/test_custom_code endpoint, which ran the Python you sent it so you could check your guardrail before enabling it.

According to the KEV catalog (version 2026.11.18), it is LiteLLM’s fourth entry in 2026. The catalog sets December 2 as the deadline for United States federal agencies, although internet-exposed instances have less time.

What interests me about this case is not the Python trick, which is well known. It is the combination: a gateway that holds the keys to all your providers, an administration feature that runs code and a Docker image that runs as root.

What exactly did /guardrails/test_custom_code do?

LiteLLM lets you write your own guardrails in Python: a function that inspects each request or response and decides whether to let it through, block it or modify it. A typical use is stripping personal data or secrets before they reach the model.

To test that function before deploying it, there is the /guardrails/test_custom_code endpoint. It receives the code and a sample input, runs it on the server and returns the result.

The project’s own advisory, GHSA-wxxx-gvqv-xp7p, published on May 7, 2026, describes it bluntly. The code ran inside a hand-built sandbox, and that sandbox could be broken with bytecode-level techniques.

The result is arbitrary code execution in the proxy process, which runs as root in the default Docker image. Reaching the endpoint requires, in the default configuration, a proxy administrator credential.

How was the sandbox broken?

The finding belongs to Markus Vervier, of X41 D-Sec, who published it on April 8, 2026 as X41-2026-001. His analysis explains that the sandbox filtered the source code with regular expressions: it looked for dangerous names such as __globals__, __builtins__ or __import__ written literally.

That filter only looks at the text. If you build those names at runtime by concatenating string fragments, the filter does not see them.

From there, X41 describes six steps. In short: obtain the object base class without writing __class__, take the code object of a generator, rewrite its name table with code.replace() and swap the function’s code.

With that, the modified generator reads __globals__ from a function the sandbox itself provided, reaches the real builtins and recovers __import__. From there, import os and any command.

In their test, the id command returned uid=0(root) in the default image. I do not reproduce the proof of concept here; it is in the X41 advisory for anyone who needs to validate their own deployment.

The technical lesson is an old one: a list of forbidden words is not a sandbox. Python offers too many paths to the same object. The project fixed it by replacing the homemade sandbox with RestrictedPython, according to its advisory.

Why is an administrator key no comfort?

It is tempting to read that an administrator credential is required and lower the priority. The project’s advisory on GitHub marks it as moderate severity, with 5.9 in CVSS 4.0. I think that would be a mistake, for two reasons.

The first is what sits behind the proxy. A model gateway holds the API keys for every provider the company uses. Running code in that process means reading its environment.

The second is how the key gets obtained. Zenity Labs published on June 30 what its honeypot sensors recorded between April 15 and May 24, 2026: 569 POST requests to that endpoint.

Almost all of them tried a guessed master key. Zenity counted 47 distinct values, all of them looking like default keys, such as sk-1234 or sk-litellm-master-key, and 64 requests with an empty authorization header.

On April 15, 520 identical requests arrived with a function that only returned {'probe': 1}. It is a check that asks two questions in one: whether the key works and whether the endpoint runs what you send it. In May the real payloads arrived, among them one that read the process environment variables.

These are Zenity’s data, measured on its own honeypots, not an independent replication. They show attempts, not confirmed compromises of real deployments. But they say something important: the attacker did not need to steal anything if the deployment kept a sample key.

How long did it take to reach KEV?

This is the timeline with the dates that appear in the records each party published. The PyPI release dates come from the PyPI API; the rest, from each advisory.

DateEventSource
2026-02-13X41 identifies the flaw and creates the proof of conceptX41-2026-001
2026-04-08X41 publishes its advisory, with no patch availableX41-2026-001
2026-04-10CVE-2026-40217 is published in NVD, CVSS 3.1 of 8.8 assigned by MITRENVD
2026-04-15First probes against Zenity’s honeypotsZenity Labs
2026-04-19litellm 1.83.10 is released on PyPIPyPI
2026-04-22litellm 1.83.11 is released on PyPIPyPI
2026-05-07The project publishes GHSA-wxxx-gvqv-xp7pGitHub
2026-11-18CISA adds it to KEVCISA
2026-12-02Catalog deadline (14 days); 3 days for exposed instances under BOD 26-04CISA

Between the X41 advisory and the KEV entry, 224 days go by. The first probes Zenity saw arrived seven months before the listing.

KEV does not measure when exploitation began. It measures when CISA had enough evidence to list it. Anyone who waited for KEV to prioritize this flaw arrived half a year late.

There is one more detail in the project’s advisory. The affected range says that 1.83.10 is already fixed, but the text says “Fixed in 1.83.11”. It is not serious if you update to a recent version, but it is the kind of inconsistency that breaks a scanner that only compares version numbers.

Is it an isolated case?

No. Cross-referencing the KEV catalog with the security advisories published in the LiteLLM repository turns up four LiteLLM entries in KEV. The cross-reference can be repeated with the catalog’s public JSON and GitHub’s advisory API:

CVEProject advisoryPublishedIn KEVDays
CVE-2026-42208SQL injection in the proxy’s key verification2026-04-202026-05-0818
CVE-2026-42271Authenticated command execution in the MCP stdio test endpoints2026-04-212026-06-0848
CVE-2026-59822MCP authentication bypass through the fallback to OAuth2 passthrough2026-06-302026-09-0264
CVE-2026-40217Sandbox escape in the custom-code guardrail2026-05-072026-11-18195

Source: CISA KEV catalog (version 2026.11.18) and the security advisories API of the BerriAI/litellm repository, queried on November 19, 2026. “Days” runs from the project advisory to the KEV entry.

Two of the four are test endpoints that run something on the server. The KEV entry for CVE-2026-42271 says that any authenticated user, including those with low-privilege internal keys, could run commands on the host.

A feature to “test” a configuration is, in practice, a feature that runs configuration sent over the network. It deserves the same treatment as the rest of the control plane. I suspect it often gets less, because it is thought of as a development tool.

LiteLLM is not alone in the catalog. In the same KEV, Langflow, another tool for orchestrating models, has accumulated six entries since May 2025.

That does not say the two projects are equally insecure. It says that the software connecting applications to models is already a regular target.

What does the evidence not establish?

It pays to separate what we know from what we do not:

  • KEV confirms exploitation, but it does not say who carried it out, how many victims there are or whether the attackers had a valid key. Ransomware use is listed as “Unknown”, which is not the same as “No”.
  • The KEV description talks about “remote attackers” and does not mention authentication. The project’s advisory says an administrator credential is required. The two fit together if the attacker has a stolen or default key.
  • The same flaw has different scores depending on who measures it: moderate, with 5.9 in CVSS 4.0 and CWE-913, in the project’s advisory; high, with 8.8, in GitHub’s reviewed database that Dependabot uses; 8.8 from MITRE in NVD; 8.7 in CVSS 4.0 and CWE-94 according to X41; CWE-420 in KEV. Anyone prioritizing only by the label on the project’s advisory would have underrated it.
  • Zenity’s data come from its honeypots. They do not measure the whole internet or prove that a real deployment fell.
  • The timeline of the communication between X41 and the project is X41’s version. From it I only use the identification date and the publication date; I do not use it to judge the project’s response.

Nor should this flaw be confused with another recent incident. On October 21, according to LiteLLM itself, its release channel was compromised and version 1.107.0 shipped with malware to PyPI and Docker for less than three hours (on PyPI, from 11:39 to 13:23 UTC).

The project later published a detailed record of the attack. It is a different problem, but it matters here: “update” is not enough, you have to update to a verified version.

What would I check today if I had LiteLLM deployed?

This is the list I would follow, in order:

  1. Inventory. Every LiteLLM deployment, its version and who administers it. Your team does not always install it: Red Hat lists among the affected products the Lightspeed chatbot in Ansible Automation Platform 2.6 and a component of OpenShift AI 3.3, with their own errata.
  2. Version. Any version from 1.81.8 up to but not including 1.83.10 is affected according to the advisory. I would go straight to a current version, not to 1.107.0, and to check the image signature I would follow the October incident note, not the release notes of older versions: the project changed its key after the incident and the most recent versions use keyless signing.
  3. Block the endpoint. If you do not use custom-code guardrails, deny /guardrails/test_custom_code at the reverse proxy. It is the mitigation that both the project and X41 propose.
  4. Rotate the master key. Never a sample value. If it was ever sk-1234 or something similar, treat it as public.
  5. Do not run as root. X41 and Zenity recommend running the container as an unprivileged user, and the project publishes a non_root image.
  6. Administration port off the internet. The administration API should not be reachable from untrusted networks.
  7. Review the logs. Look for POST requests to /guardrails/test_custom_code since an affected version was deployed, and at least since April 8. If one shows up that you do not recognize, rotate every provider key the proxy holds, not just the master key.

For federal agencies there is also a specific rule: the BOD 26-04 directive that the KEV entry cites. CISA scores this CVE in NVD as exploited, not automatable and with total impact. For that case, table 1 of the directive gives 3 days for publicly exposed assets and 14 days, until December 2, for everything else.

Yesterday I wrote about how an MCP tool name does not identify whoever offers it. Today the problem sits one level lower, in the infrastructure: in an AI gateway, every administration feature acts on all the keys it holds.

A test feature that runs code is not a convenience detail. It is part of the perimeter.

Frequently asked questions

Am I affected if I only use LiteLLM as a Python library?

The flaw is in an HTTP endpoint of the LiteLLM proxy server. If you only import the SDK in your code and do not run the proxy, there is no endpoint to reach. Even so, it is worth checking the version.

Is updating to 1.83.10 enough?

The project’s advisory is inconsistent between 1.83.10 and 1.83.11. I would go to a current verified version, and I would also block the endpoint if you do not use it.

Why did it take so long to enter KEV?

KEV lists a flaw when CISA has evidence of exploitation that it considers sufficient. It is not a record of when exploitation began. Zenity’s data show attempts since April.

What do I do if I find requests to that endpoint in my logs?

Assume the process may have run code as root. Rotate the master key and every provider key in the proxy, and review the host as if it were compromised.

Sources

Blog

Let's talk security

Talks, press or partnerships: get in touch.