Attackers are using a LiteLLM bug to take over the server that holds your AI keys. Update to 1.83.11 (CVE-2026-40217, CISA KEV)

7 min read

How to fix CVE-2026-40217: upgrade litellm to 1.83.11 or later. CISA added this LiteLLM bug to its exploited list on Nov 18. Anyone holding a proxy admin key can escape the custom guardrail sandbox and run code as root, which exposes every AI provider key the proxy stores.

BREAKING: Attackers are using a LiteLLM bug to take over the server that holds your AI keys. Update to 1.83.11 (CVE-2026-40217, CISA KEV)
On this page

Attackers are using a LiteLLM bug to take over the server that holds a company's AI keys. LiteLLM is the open-source gateway many teams put between their apps and AI providers such as OpenAI, Anthropic and Google. It stores the provider keys, the master key and the usage records. On November 18, 2026, CISA added the bug, CVE-2026-40217, to its Known Exploited Vulnerabilities catalog, which means it has evidence of real attacks. US federal agencies have until December 2 to fix it.

The fix is not new. It shipped in April, so if you have upgraded LiteLLM at any point since late April, you are almost certainly fine. The servers at risk are the ones left on a LiteLLM release from February through mid-April 2026 (versions 1.81.8 through 1.83.9). The attacker also needs an admin credential for that proxy, so this is a "someone got hold of the admin key" bug, not an "anyone on the internet" bug. That is less comforting than it sounds: master keys end up in env files, CI variables and chat threads, and once someone has one, this bug turns it into full control of the machine.

How to fix

Upgrade LiteLLM to 1.83.11 or later, then restart the proxy:

pip install --upgrade "litellm[proxy]>=1.83.11"

# Docker: move off any image built from 1.81.8 to 1.83.9, then
docker pull ghcr.io/berriai/litellm:<a tag at 1.83.11 or later>

If you are upgrading anyway, the current release on PyPI is 1.110.0 (November 17). Do not land on 1.107.0: that is the release that shipped a credential stealer on October 21, and PyPI no longer serves it.

Why 1.83.11 and not 1.83.10

The sources disagree by one version. GitHub's advisory text (GHSA-wxxx-gvqv-xp7p) says "Fixed in 1.83.11" and "Upgrade to 1.83.11 or later", but its affected range, the OSV record and the release it links (v1.83.10-stable) all put the fix at 1.83.10. The fix itself is BerriAI's pull request #25818, merged April 15, which throws away the old filter and runs guardrail code through RestrictedPython instead.

We downloaded the PyPI wheels and compared them. 1.83.8 is the last release with the old regex filter (custom_code/code_validator.py). The sandbox and guardrail files in 1.83.9, 1.83.10 and 1.83.11 are byte-for-byte identical and all use RestrictedPython. So the disagreement is about labels, not code. Go to 1.83.11 anyway: it is the highest version any official source names, it is what the advisory tells you to do, and it keeps every scanner quiet.

One check you can run now

Find the version the proxy is actually running, not the one in your lockfile:

pip show litellm | grep -i '^version'

# inside a container
docker exec <litellm-container> pip show litellm | grep -i '^version'

Anything from 1.81.8 up to and including 1.83.9 is in the affected range. Then look for use of the vulnerable endpoint in whatever records request paths, usually your reverse proxy, load balancer or the proxy's own access log:

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

Most teams never call that endpoint. It exists so an admin can try out a custom guardrail from the UI. If you see requests to it that nobody on your team made, treat the proxy as compromised: rebuild it from a clean image, then rotate the master key and every provider key it stored. If you never set LITELLM_SALT_KEY, LiteLLM encrypts stored model credentials with the master key, so follow LiteLLM's rotation steps rather than just swapping the environment variable.

If you can't upgrade today

Block the one endpoint at whatever sits in front of LiteLLM. This is the workaround in both the GitHub advisory and the researchers' write-up. In nginx:

location = /guardrails/test_custom_code {
    return 403;
}

Also keep the admin side of the proxy off the open internet, keep the master key out of shared places, and run the container as a non-root user so a break-in gets less. Normal chat and completion traffic does not touch this endpoint, so blocking it breaks nothing for your apps.

What the bug does

LiteLLM lets admins write a guardrail in Python, a small function that checks each request or response and can allow, block or change it. The POST /guardrails/test_custom_code endpoint runs that code against a sample input so you can test it. To keep the code from doing anything dangerous, versions 1.81.8 to 1.83.9 ran it in a hand-built sandbox that scanned the source text for banned words such as import, __globals__ and os..

A filter that reads the text can be fooled by text that doesn't look like the banned word. X41 D-Sec, the German security firm that found the bug, builds the banned names out of string pieces at runtime, then rewrites the bytecode of a small generator function so that, when it runs, it reaches into one of the helper functions LiteLLM hands the sandbox (http_get) and pulls out Python's real __import__. From there it imports os and runs shell commands. In the default Docker image, those commands run as root.

Root on the gateway means everything the gateway knows: the provider API keys in its environment and database, the master key, the virtual keys it issued to your teams, and the prompts and responses flowing through it. CISA calls this class of bug an "unprotected alternate channel" (CWE-420): a second way to run code that skips the protection the normal path has.

Timeline

  • February 5, 2026: LiteLLM 1.81.8 ships with the custom-code guardrail test endpoint. Earlier releases don't have it; we checked 1.81.7.
  • February 13: X41 D-Sec finds the escape and builds a working proof of concept.
  • April 8: the coordinated embargo runs out and X41 publishes advisory X41-2026-001 with the full exploit. No patch exists yet.
  • April 15: BerriAI merges the RestrictedPython rewrite (#25818). Fixed releases follow over the next week.
  • May 11: GitHub publishes the reviewed advisory, GHSA-wxxx-gvqv-xp7p.
  • November 18: CISA adds CVE-2026-40217 to the KEV catalog. Due date for federal agencies: December 2.

The working exploit has been public for seven months. CISA has not said who is using it or against whom, and it lists ransomware use as unknown.

Who is not in scope

  • LiteLLM 1.81.7 and earlier. The vulnerable endpoint was added in 1.81.8.
  • LiteLLM 1.83.11 and later, which includes every release since late April.
  • People who only use LiteLLM as a Python library inside their own code (import litellm) and never run the proxy server. The endpoint is part of the proxy.
  • Anyone who can only send normal API traffic with a team or user key. The endpoint checks for the proxy-admin role, so an attacker needs the master key or an admin account first.

What this is not

It is not a no-login bug. A stranger with no admin credential cannot use it, and the CVSS 3.1 score of 8.8 reflects that it needs a login. It is also not the October 1.107.0 incident, where the published package itself was poisoned, and it is not the October master-key leak in LiteLLM Enterprise (GHSA-w4c7-34wj-hqm8), which hit much newer releases. Different bug, different versions, same advice: keep the gateway current and treat its master key like a root password.

HOL Guard does not patch LiteLLM, so the upgrade above is still the fix. Guard checks what an AI coding agent tries to do on your machine, such as shell commands, package installs, credential file reads and MCP tool calls, and pauses risky ones for your approval. That matters here because the master key this bug needs is exactly the kind of secret agents read out of .env files. Scan your agent setup with HOL Guard (free).

What do people ask about CVE-2026-40217?

Is my LiteLLM proxy affected?

Only if it runs a version from 1.81.8 through 1.83.9 and someone untrusted could get an admin credential for it. Run pip show litellm on the proxy host or inside the container to see the version.

Is CVE-2026-40217 being exploited?

Yes. CISA added it to the Known Exploited Vulnerabilities catalog on November 18, 2026, which it only does with evidence of exploitation. A full public exploit has been available since April 8.

Which version fixes CVE-2026-40217?

Upgrade to 1.83.11 or later. Some records say 1.83.10, and the patched code is already in 1.83.9, but the GitHub advisory text names 1.83.11, so that is the safe floor.

Can I fix it without upgrading?

For now, yes: block POST /guardrails/test_custom_code at your reverse proxy or API gateway. Your apps don't use it. Upgrade when you can.

Do I need to rotate my keys?

If you were on an affected version and see requests to the test endpoint you can't explain, yes: rebuild the proxy and rotate the master key and every provider key it held. If the endpoint was never called, upgrading is enough.

References

All articles

Keep exploring

The engineering desk continues across the ecosystem: security research on shipping agents safely, and plugins that put the standards to work.