AI Security

LiteLLM CVE-2026-40217 Is in KEV at CVSS 5.9, and Another Bug Leaks the Master Key It Needs

Dark cyberpunk illustration of a matte-black relay cabinet at night, its front face a grid of glowing cyan key slots, with a narrow side hatch hanging open and spilling amber light into the dark.

Twenty-three minor releases separate the two patches you need. LiteLLM closed the guardrail sandbox escape in version 1.83.11, back in April. It closed the bug that leaks the proxy master key out of an Azure error message on November 12, in versions 1.106.9, 1.108.6, 1.109.1 and 1.110.0-rc.2. A proxy sitting anywhere between those two points carries the fix for the vulnerability CISA just added to the Known Exploited Vulnerabilities catalog, and still hands a low-privilege user the exact credential that exploit needs.

CISA added CVE-2026-40217 to the KEV catalog on November 18, 2026, with a federal remediation deadline of December 2. The listing is terse: an "unprotected alternate channel vulnerability that could allow remote attackers to execute arbitrary code via bytecode rewriting at the /guardrails/test_custom_code URI." Four authorities have scored the same bug differently. NVD and Red Hat both publish CVSS v3.1 8.8. X41 D-Sec, the firm that found it, published CVSS v4.0 8.7. BerriAI's own GitHub advisory rates it Moderate at CVSS v4.0 5.9, on the stated grounds that "reaching the endpoint requires a proxy-admin credential in default configurations."

That last clause is the one worth arguing with, because the privilege it treats as a barrier was available for sale, by accident, in the same codebase eight days ago.

Who this affects, and who can close the tab

If you do not run a self-hosted LiteLLM proxy, this one is not yours. There is no client-side exposure, nothing to patch in an application that merely calls a hosted LLM API, and no risk from using LiteLLM as a plain Python library in a script. The bug lives in the proxy server's admin surface.

If you do run the proxy, the affected range is >= 1.81.8, < 1.83.10 per the GitHub advisory, with the fix landing in 1.83.11. Those are February-to-April 2026 builds. Current lines are 1.106 through 1.111, so the population still exposed to this specific CVE is narrow: proxies that were stood up once, pinned, and never revisited. In my experience that describes most of the LLM gateways running inside small and mid-sized companies, because the gateway was a platform-team side project that worked on the first try and then stopped being anybody's job.

There is a second group that will not find LiteLLM in a pip list at all, because they did not install it. Red Hat's CSAF advisory for this CVE names the Ansible Automation Platform 2.6 Lightspeed chatbot image and the OpenShift AI 3.3 Llama Stack core image as shipping an affected LiteLLM, fixed in RHSA-2026:24866 and RHSA-2026:30056 respectively. The same advisory still lists the Lightspeed Core and AAP 2 Lightspeed chatbot user workloads as known affected. If you bought an AI assistant feature from a platform vendor, you may be operating an LLM proxy without ever having chosen one.

Google's Threat Intelligence Group reported observed exploitation on November 16, two days before the KEV listing: "We also 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. Privileged service accounts were sufficient to establish persistence without the use of malware." The commercial motive in that report is LLMjacking - reselling someone else's inference quota. GTIG puts single-day fraudulent charges above 100,000 USD in some cases and cumulative abuse at 1 million USD in the worst, with one botnet generating millions of API calls in roughly 24 hours before the credentials were revoked.

What the endpoint actually does

LiteLLM's custom-code guardrail feature lets an administrator paste Python into the proxy and have it evaluated against a sample request, so you can test a content filter without a deploy. To make that safe, the proxy ran the submitted code in a hand-written sandbox.

X41 D-Sec's advisory, published April 8 by Markus Vervier, describes why the sandbox did not hold. The filter worked on the literal text of the submitted source, using regular expressions to reject dangerous names such as the builtins mapping and the import machinery. A name that is assembled at runtime from string fragments never appears in the source text, so the filter never sees it. From there the escape used low-level CPython code-object manipulation to change which names a function's bytecode resolves, reaching the unrestricted builtins and the import mechanism. The result is operating-system command execution as the account running the proxy, which in the default Docker image is root.

I am deliberately not reproducing the technique here, and neither should you go looking for a proof of concept to run against your own proxy to "confirm" exposure. A version check answers the question with no risk. The fix in 1.83.11 replaced the hand-rolled filter with RestrictedPython, which is the correct move: text filtering cannot constrain a language that can build any name it wants at runtime.

One detail from the X41 timeline matters for how you read this vendor's advisories. X41 reported the bug on February 18, sent an urgent follow-up on March 24 that bounced off the technical contact's mailbox, escalated through the distros list the next day, and published on April 8 with no patch available because the embargo had run out. The GitHub advisory appeared on May 7, a 79-day gap on a root-code-execution bug.

The credential the exploit needs, and the bug that gives it away

BerriAI's severity rating rests on the attacker already holding proxy-admin. Treat that as an accounting convention rather than a defensive control, because LiteLLM shipped a stream of advisories in 2026 whose entire effect is handing an attacker exactly that:

  • GHSA-4xpc-pv4p-pm3w, Critical, May 28 - authentication bypass via Host header injection.
  • GHSA-7hp6-4w63-5g45, Critical, September 30 - privilege escalation to proxy admin through cross-domain reuse of the salt key.
  • GHSA-w4c7-34wj-hqm8, Critical, October 27 - unauthenticated file read leaking the master key on the Enterprise proxy.
  • GHSA-2rwg-2wh4-7c4f, High at CVSS v3.1 7.7, November 12 - authenticated secret exfiltration via Azure Entra credential parameters in the request body.

The November 12 one is the clearest. The proxy's request-body blocklist omitted six Azure Entra parameters, including client_id and client_secret. A caller with a virtual key and access to any azure/ or azure_ai/ model could send those fields in an ordinary /v1/chat/completions request and override the deployment's credential. Point client_id at a server-side environment variable reference such as LITELLM_MASTER_KEY, let Entra reject the resolved value, and the error message returns it to the caller. The advisory notes it affects deployments with an Azure model and no AZURE_API_KEY or AZURE_OPENAI_API_KEY set, and that the readable surface includes the database URL and provider keys as well.

Read those two advisories together. One bug gives a low-privilege key holder the master key. The other turns the master key into root on the proxy host. The patches landed 23 minor releases apart, which means version ranges exist that have one and not the other. A proxy pinned at 1.83.11 in April patched the KEV CVE and spent the next seven months leaking the credential it depends on. A proxy on 1.95 has neither problem for this chain and is still behind on the November fixes.

I have not seen a public report tying these two specific advisories together in the wild, and I am not claiming one. GTIG described virtual keys being elevated to administrative credentials without naming the mechanism. The composition above is what the primary advisories permit, and it is enough to justify treating the vendor's 5.9 as a floor rather than a ceiling.

Find every LiteLLM you are running

Work the inventory by how the proxy got there, because each path reports its version differently.

Containers and Kubernetes

# Self-hosted container: ask the interpreter, not the image tag.
# main-latest tells you nothing about which build you pulled.
docker inspect --format '{{index .RepoDigests 0}}' litellm
docker exec litellm pip show litellm | grep -i ^Version

# Kubernetes: every pod that could be the proxy, across namespaces.
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{range .spec.containers[*]}{.image}{" "}{end}{"\n"}{end}' \
  | grep -Ei 'litellm|lightspeed|llama-stack'

# Then read the real version out of the running container.
kubectl exec -n   -- pip show litellm | grep -i ^Version

Platform products that bundle it

For Ansible Automation Platform 2.6, confirm the Lightspeed chatbot image carries RHSA-2026:24866. For OpenShift AI, confirm the cluster is on 3.3.4 or later per RHSA-2026:30056. Ask which release of the vendor product you are on rather than which version of LiteLLM, because the version inside a vendor image is the vendor's problem to track and yours to verify.

If you cannot upgrade today

Block POST /guardrails/test_custom_code at the ingress or reverse proxy. Both advisories recommend it, and it is a one-line change on the thing already in front of the proxy:

# nginx, in the server block in front of LiteLLM
location = /guardrails/test_custom_code {
    return 403;
}

# Also block the six Entra parameters from GHSA-2rwg-2wh4-7c4f until
# you are past 1.106.9 / 1.108.6 / 1.109.1 / 1.110.0-rc.2.
# tenant_id client_id client_secret azure_username azure_password azure_scope

Two more things that cost nothing. Stop running the container as root, which caps what a successful escape reaches. And take the proxy's admin surface off any network that virtual-key holders can reach, so the admin routes and the inference routes are not the same front door.

What to pull from the logs

The guardrail route is an admin endpoint that a healthy deployment hits roughly never. Any request to it is worth a look, and the ingress log is the honest record because it survives a compromised proxy.

# Ingress or reverse-proxy access logs: every hit on the admin route.
grep -F '/guardrails/test_custom_code' /var/log/nginx/access.log* \
  | awk '{print $1, $4, $9}' | sort | uniq -c | sort -rn

# LiteLLM's own spend table: keys whose volume changed shape.
# api_key is stored as a hash; startTime is the time column.
SELECT api_key,
       date_trunc('hour', "startTime") AS hour,
       count(*) AS calls,
       round(sum(spend)::numeric, 2) AS spend
FROM "LiteLLM_SpendLogs"
WHERE "startTime" > now() - interval '30 days'
GROUP BY api_key, hour
HAVING count(*) > 1000
ORDER BY calls DESC
LIMIT 50;

Pair that with two reviews that need no queries. In the admin UI, read the internal-user list and account for every holder of the proxy-admin role; GTIG's note about privileged service accounts being enough for persistence means an extra admin account is the persistence. And pull the provider-side billing console for each upstream, because LLMjacking shows up as a spend anomaly on the provider bill before it shows up anywhere in your stack. Millions of calls in a day is not subtle on an invoice.

Rotate the provider keys, not just the master key

If your proxy sat in the affected range while reachable by anyone outside your platform team, upgrade past both fix points, then rotate in this order: every upstream provider key the proxy holds, then LITELLM_MASTER_KEY, then the virtual keys you issued. Teams routinely do only the middle one, and that is the rotation that protects the least. The master key is the credential an attacker uses once to get root; the provider keys are the asset they actually monetize, and a copy taken in June still bills to you in December unless you have cycled it. Keep the old keys revoked rather than disabled, and check the provider console for spend in the window before you assume nothing happened.

An LLM gateway is a single process that holds every model credential your company owns, exposes an administrative API on the same network as its inference API, and has collected four critical or high advisories in six months. Inventory it, patch it, and scope it like the credential store it is.

Running an LLM gateway you have not assessed?

We assess self-hosted AI gateways and agent infrastructure the way an attacker does: credential scope, admin surface exposure, version drift, and what a single stolen virtual key actually reaches. Book a session to walk through your deployment.