# LiteLLM CVE-2026-40217 Is Exploited From Virtual Keys. How to Check Your Proxy

> Source: <https://dev.to/alanwest/litellm-cve-2026-40217-is-exploited-from-virtual-keys-how-to-check-your-proxy-2n9k>
> Published: 2026-11-19 16:10:03+00:00

If you run a LiteLLM proxy, the box sitting in front of your OpenAI, Anthropic and Gemini accounts has a code execution bug that attackers are using right now. CISA added LiteLLM CVE-2026-40217 to its Known Exploited Vulnerabilities catalog on November 18, 2026, with a December 2 deadline for federal agencies ([Mallory summary of the KEV addition](https://mallory.ai/stories/01a1f125-fa0c-7bc8-8018-acabeaaacd03)). Google says it watched a threat actor use it to turn ordinary virtual keys into admin credentials.

The fix was merged on April 15. If your proxy hasn't been upgraded since spring, here is how to check the version, what to upgrade to (it isn't the version the advisory names), which logs to grep and which keys to rotate.

LiteLLM lets you write custom guardrails in Python. To test one, the proxy exposes `POST /guardrails/test_custom_code`, which runs whatever code you send it inside a hand-rolled sandbox. That sandbox was a regex deny-list over the source text. X41 D-Sec showed you could build the blocked names at runtime so the regex never sees them, then rewrite a generator's bytecode to reach the real import machinery and run OS commands ([X41 advisory](https://www.x41-dsec.de/lab/advisories/x41-2026-001-litellm)). In the default Docker image the proxy runs as root, so "code execution in the proxy process" means root in the container.

The facts, from the [GitHub advisory GHSA-wxxx-gvqv-xp7p](https://github.com/advisories/GHSA-wxxx-gvqv-xp7p):

| Affected | `litellm` >= 1.81.8, < 1.83.10 (the endpoint first shipped in 1.81.8) | 
| Fixed | 1.83.10 in the advisory metadata, 1.83.11 in the advisory text | 
| CVSS | 8.8 (v3.1, [Red Hat](https://access.redhat.com/security/cve/cve-2026-40217) ); 7.5 High (v4.0, GHSA) | 
| CWE | CWE-420 Unprotected Alternate Channel, CWE-913 | 
| EPSS | 17.02% (97th percentile, per GHSA) | 

The fix replaced the regex filter with RestrictedPython.

That's the argument I keep seeing for putting this one off. The advisory does say reaching the endpoint takes a proxy-admin credential. In practice that requirement is weaker than it sounds, for two reasons.

First, Obsidian Security published a chain in June that starts from a default `internal_user` ([Obsidian write-up](https://www.obsidiansecurity.com/blog/litellm-privilege-escalation-rce)). CVE-2026-47101: `/key/generate` (and `/key/update`, `/key/regenerate`) stored a caller-supplied `allowed_routes` without validating it, so a non-admin could mint a key that reaches admin routes. CVE-2026-47102: `/user/update` let you set your own `user_role` to `proxy_admin`. CVE-2026-40217 is the last step, from admin to shell. The full chain was closed in v1.83.14-stable, released April 25.

Second, the in-the-wild exploitation matches that pattern. Google's Threat Intelligence Group wrote on November 17 that they "observed a threat actor exploit CVE-2026-40217, a sandbox escape in LiteLLM that allows an attacker to elevate limited-access inference keys ("Virtual Keys") into full administrative credentials" ([GTIG AI Threat Tracker](https://cloud.google.com/blog/topics/threat-intelligence/agentic-threat-activity-crosses-a-significant-threshold)). The same report notes that in the intrusions it covers, privileged service accounts were enough for persistence and the attackers didn't need malware at all.

So a virtual key, the kind you hand to every internal app and every intern's notebook, became the keys to the gateway. Those keys end up in `.env` files, CI logs and Slack. Whatever "PR:H" says, a credential that widely shared is not a high bar.

What attackers do with that access is LLMjacking. The same GTIG report cites Mandiant incidents from 2026 where "single-day fraudulent charges exceeded $100,000 USD" and, in the worst cases, "cumulative resource abuse reached $1 million USD before remediation."

```
pip show litellm | grep -i '^version'
docker ps --format '{{.Names}}\t{{.Image}}' | grep -i litellm
docker exec <litellm-container> sh -c "find / -maxdepth 7 -type d -name 'litellm-*.dist-info' 2>/dev/null"
docker exec <litellm-container> pip show litellm | grep -i '^version'
```

Run the version check even if the tag looks fine. If you deploy `main-latest` or `main-stable`, the tag tells you nothing about what's inside the container.

I run `find` before `pip show` on purpose. If a container pulled one of the poisoned October images (more on that below), starting Python re-runs the malware's `cook.pth` and `sitecustomize.py`, and `pip` is Python. LiteLLM's incident report says not to run `pip` in an affected environment first. `find` reads the version off the `dist-info` directory name without starting an interpreter. If it prints `litellm-1.107.0.dist-info`, stop and go to the IOC section.

```
helm list -A | grep -i litellm
helm get values <release> -n <namespace> | grep -iA3 image
kubectl get pods -n <namespace> -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}' | grep -i litellm
kubectl exec -n <namespace> <litellm-pod> -- pip show litellm | grep -i '^version'
```

The chart version and the app version are different numbers. Trust what's installed inside the pod (same `find` trick applies before `pip show`).

If you're between 1.81.8 and 1.83.9, you're exposed to this CVE. If you're below 1.83.14, you're exposed to the chain that makes it reachable from a normal key.

The advisory's 1.83.10/1.83.11 disagreement is a distraction. Don't aim for the minimum. I treat v1.83.14-stable as the floor, because that's where Obsidian confirms the whole chain is closed.

October's supply-chain compromise makes picking a target messier. On October 21, LiteLLM's own PyPI package and Docker images were compromised: `litellm==1.107.0` and the `v1.107.0`, `latest`, `main-latest` and `main-stable` tags on Docker Hub and GHCR shipped a credential stealer, for about 1 hour 45 minutes on PyPI and about 2.5 hours on Docker Hub ([LiteLLM incident report](https://docs.litellm.ai/blog/security-incident-oct-21-2026)). The project recommends pinning `litellm==1.106.2` or another explicit version published before the incident. The first releases signed with its new cosign key, `v1.103.8`, `v1.104.6`, `v1.105.4` and `v1.106.3`, came out October 24.

So:

```
pip install "litellm[proxy]==1.106.2"   # or a newer, explicitly pinned, signed release
```

For Docker and Helm, pin an explicit version tag or, better, a digest. Floating tags are exactly how people got burned in October.

If you can't upgrade today, block the endpoint at the reverse proxy. Both GitHub and X41 document this workaround:

```
location = /guardrails/test_custom_code {
    return 403;
}
```

Normal chat and completion traffic never touches the guardrail test endpoint, so any hit you can't attribute to a teammate is a red flag ([HOL write-up](https://hol.org/blog/cve-2026-40217-litellm-guardrail-sandbox-escape-cisa-kev)).

```
grep 'POST /guardrails/test_custom_code' /var/log/nginx/access.log*
docker logs <litellm-container> 2>&1 | grep 'test_custom_code'
```

Then look at the steps before it in the chain:

`/key/generate`, `/key/update` or `/key/regenerate` that set `allowed_routes`, especially wildcards.`/user/update` or `/user/bulk_update` that change `user_role`.` proxy_admin` account you don't recognize. Re-verify every single one.`POST /guardrails`, `PUT /guardrails/{id}`).` litellm_settings.callbacks` in `config.yaml`. Obsidian points out these don't show in the admin UI, and a malicious callback can read prompts and responses or alter tool calls.
While you're in there, check for the October supply-chain IOCs too: `litellm-1.107.0.dist-info`, `cook.pth`, `cook.py` or `sitecustomize.py` in site-packages, and `/tmp/remote_code_loader.lock`. LiteLLM is explicit that finding them confirms exposure but not finding them doesn't prove you're clean.

Upgrading keeps the next attacker out. If someone got in before you patched, it does nothing about them.

A LiteLLM proxy is a credential vault with an HTTP API. It holds every provider key in its database or config, the master key, the `DATABASE_URL` password and whatever else is in its environment. With root in that container, an attacker reads all of it in seconds and never needs to come back. Your logs may be incomplete, or the attacker may have cleaned them, and the absence of a `test_custom_code` hit in nginx doesn't help if someone reached the proxy directly on port 4000.

Rotate, in this order:

`LITELLM_MASTER_KEY`.
It's an annoying afternoon, but a $100,000 day on your cloud and LLM bills is worse.

And take the admin UI and management routes off the public internet. The proxy needs to serve `/chat/completions` to your apps. It doesn't need to serve `/user/update` to the whole world.

So: is your LLM gateway reachable from the internet, and when did you last rotate the provider keys behind it? If you think rotating on every KEV entry is overkill, tell me why in the comments.
