Safeguard
Vulnerability Analysis•

LiteLLM CVE-2026-40217: Guardrail Sandbox Escape Now on CISA KEV

CVE-2026-40217 lets a proxy-admin caller escape LiteLLM's custom-code guardrail sandbox and run code in the proxy. CISA lists it as exploited. Versions, checks and fix.

Safeguard Security Team
9 min read

CVE-2026-40217 is a sandbox escape in LiteLLM, the open source Python proxy that many teams put in front of their LLM providers. The POST /guardrails/test_custom_code endpoint runs user-supplied Python inside a home-made sandbox, and that sandbox can be escaped with bytecode-level tricks. The result is arbitrary code execution inside the proxy process. On 18 November 2026 CISA added it to the Known Exploited Vulnerabilities (KEV) catalog, which means CISA has evidence it is being exploited. The fix has been out since April: run LiteLLM 1.83.11 or later.

Key takeaways

  • What: sandbox escape to code execution through POST /guardrails/test_custom_code in the LiteLLM proxy (GHSA-wxxx-gvqv-xp7p).
  • Affected: litellm 1.81.8 up to, but not including, 1.83.10, per the GitHub advisory and NVD.
  • Fixed: the advisory text says "Fixed in 1.83.11". Its version data lists 1.83.10 as first patched. Target 1.83.11 or later and you satisfy both.
  • Exploited: yes, according to CISA, which added it to KEV on 18 November 2026.
  • Who can reach it: the advisory says a proxy-admin credential is required in default configurations. CVSS 3.1 is 8.8 (AV:N/AC:L/PR:L).
  • Stopgap: block POST /guardrails/test_custom_code at your reverse proxy or API gateway until you upgrade.

What is CVE-2026-40217?

LiteLLM's proxy lets administrators write custom guardrails in Python and test them through an HTTP endpoint before they go live. The GitHub advisory describes the problem plainly: the endpoint "runs user-supplied Python inside a hand-rolled sandbox. The sandbox can be escaped using bytecode-level techniques, allowing arbitrary code execution in the proxy process."

Two details make this worse than a typical admin-only bug.

First, the advisory notes that the proxy "runs as root in the default Docker image." Code that escapes the sandbox lands with root inside the container.

Second, an LLM proxy is a concentration point. It usually holds the API keys for every model provider a company uses, plus virtual keys for internal teams, request logs and sometimes cached prompts and responses. Code execution in that process puts all of it within reach.

NVD classifies the weakness for KEV purposes as CWE-420, unprotected alternate channel. In practice it is a sandbox that was never a real security boundary. The maintainers' fix, per the advisory, replaced the hand-rolled sandbox with RestrictedPython.

Which LiteLLM versions are affected and which are fixed?

SourceAffectedFixed
GitHub advisory GHSA-wxxx-gvqv-xp7p (version data)>= 1.81.8, < 1.83.101.83.10
Same advisory (text)not stated separately"Fixed in 1.83.11"
NVD CVE-2026-40217 (CPE)1.81.8 up to, excluding, 1.83.10not stated

The advisory also links the patched release tag v1.83.10-stable. On PyPI, 1.81.8 was uploaded on 5 February 2026, 1.83.10 on 19 April 2026 and 1.83.11 on 22 April 2026. The current release on PyPI as of 24 November 2026 is 1.110.3.

Because the sources disagree by one patch release, the safe instruction is simple: upgrade to 1.83.11 or anything newer. Most teams should go straight to a current release.

NVD also lists Red Hat products that bundle LiteLLM in its configuration data, including Ansible Automation Platform before 2.6-9 and OpenShift AI 3.3 before 3.3.4. If you run those, follow Red Hat's errata (RHSA-2026:24866, RHSA-2026:30056) rather than upgrading the embedded package by hand.

Is CVE-2026-40217 being exploited?

CISA says yes. The KEV catalog entry, added 18 November 2026, reads: "BerriAI LiteLLM contains an unprotected alternate channel vulnerability that could allow remote attackers to execute arbitrary code via bytecode rewriting at the /guardrails/test_custom_code URI." Ransomware use is listed as "Unknown".

The EPSS score from FIRST on 23 November 2026 was 0.828, in the 99.7th percentile of all scored CVEs. That is a very high predicted probability of exploitation activity in the next 30 days.

Note the timeline. The CVE was published in April 2026 and the GitHub advisory in May. The KEV listing in November is what changed. A vulnerability that sat at "high, admin required" for seven months is now confirmed as used in attacks, so any proxy still on an old build moves to the top of the queue.

Why does an admin-only bug matter?

"Requires proxy-admin" sounds reassuring. It is less so in practice.

  • Admin keys for LLM proxies end up in places they should not: CI variables, shared notebooks, chat threads and config repos.
  • LiteLLM has had other issues this year that touch authentication and keys. We covered CVE-2026-59822, an MCP auth bypass also on KEV, and the host header auth bypass CVE-2026-49468. Chained bugs turn "admin only" into "anyone who can reach the port".
  • Many proxies are exposed far more widely than intended, because they were stood up quickly for a pilot and never moved behind a gateway.

Treat the admin requirement as a speed bump, not a wall.

How do you check if you are affected today?

Start with where LiteLLM runs. It shows up as a Python dependency in apps, as a container, and inside other products.

1. Find the version in Python environments and lockfiles.

# Installed version in the current environment
python -c "import importlib.metadata as m; print(m.version('litellm'))"

# Every pinned reference across your repositories
grep -rnE "litellm[=<>~ ]" --include="requirements*.txt" --include="pyproject.toml" --include="*.lock" --include="Pipfile*" .

Anything from 1.81.8 to 1.83.10 is in the vulnerable range. Treat 1.83.10 as suspect too until you are on 1.83.11 or later.

2. Check running containers.

# Which containers run a LiteLLM image
docker ps --format '{{.ID}} {{.Image}}' | grep -i litellm

# Version inside a running container
docker exec <container-id> python -c "import importlib.metadata as m; print(m.version('litellm'))"

# Kubernetes
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}' | grep -i litellm

3. Test whether the endpoint is reachable from where an attacker would sit. From outside your network, or from an ordinary internal host, send a request without credentials:

curl -s -o /dev/null -w "%{http_code}\n" -X POST https://<your-proxy-host>/guardrails/test_custom_code

A 401 or 403 means the endpoint exists but wants auth. A 404 or a block page from your gateway is what you want to see after the stopgap below. A timeout from the internet is better still.

4. Look for signs of use. Search proxy and gateway access logs for any POST /guardrails/test_custom_code request. In most deployments that endpoint is used rarely, by a handful of admins. Requests from unknown IPs or keys, or at odd hours, deserve a closer look.

grep -E "POST /guardrails/test_custom_code" /var/log/nginx/access.log* 2>/dev/null
kubectl logs -n <namespace> deploy/<litellm-deployment> --since=720h | grep test_custom_code

How do you fix it?

The upstream fix exists, so this is a patch job.

  1. Upgrade every LiteLLM install to 1.83.11 or later. For pip: pip install --upgrade "litellm>=1.83.11". For containers, pull a current image tag and redeploy. Pin the version in your lockfile so a rebuild does not drift back.

  2. Block the endpoint in the meantime. The advisory's workaround is to block POST /guardrails/test_custom_code at your reverse proxy or API gateway. With nginx in front:

    location = /guardrails/test_custom_code {
        return 403;
    }
    
  3. Rotate secrets if exposure is possible. If an old version was reachable and you cannot rule out use, rotate the master key, admin keys and every upstream provider key the proxy held. CISA's listing is a reason to assume the worst for any internet-facing instance.

  4. Stop running as root. Run the container with a non-root user and a read-only root filesystem where your deployment allows it. It does not fix this bug, but it limits the next one.

  5. Put the proxy behind a gateway with its own authentication, so admin endpoints are never directly on the internet.

How does Safeguard help with LiteLLM exposure?

Safeguard helps with the parts of this that are about knowing and moving fast. It does not replace the upgrade.

  • Inventory. Software composition analysis and SBOMs show every repository, service and image that pulls in litellm, including as a transitive dependency of another AI framework, with the exact resolved version.
  • Prioritisation. Findings carry CISA KEV status and EPSS, so CVE-2026-40217 rises above the long tail of high-severity issues that nobody is exploiting.
  • A CI gate. A policy can fail builds that resolve litellm below 1.83.11, so a stale lockfile cannot reintroduce it.
  • Fix pull requests. Autonomous remediation can open a policy-gated pull request that bumps litellm to a safe version, and your own CI runs your tests on it before anyone merges. Auto-merge is a separate switch and stays off by default.

You can also look up CVE-2026-40217 for free on gold.safeguard.sh, with no login, to see affected and fixed versions, CVSS, EPSS and KEV status in one place.

See how Safeguard would help

This demo sets up the local runner, approves it with its device code, then scans from the terminal, the same flow you would use on a host that runs your LLM proxy.

Click through it at your own pace, or open it full screen. Get started at safeguard.sh/download and the CLI docs.

FAQ

What is CVE-2026-40217?

A sandbox escape in LiteLLM's custom-code guardrail test endpoint, POST /guardrails/test_custom_code, that allows arbitrary code execution in the proxy process.

Which LiteLLM version fixes CVE-2026-40217?

The advisory text says 1.83.11; its version data says 1.83.10. Upgrade to 1.83.11 or later.

Is CVE-2026-40217 exploited in the wild?

CISA added it to the KEV catalog on 18 November 2026, which means CISA has evidence of active exploitation.

Does an attacker need credentials?

The advisory says a proxy-admin credential is required in default configurations. CVSS rates privileges required as low.

Can I mitigate without upgrading?

Yes, for a short time. Block POST /guardrails/test_custom_code at your reverse proxy or API gateway, then upgrade.

Should I rotate keys?

If a vulnerable proxy was reachable by anyone you do not fully trust, rotate the master key, admin keys and all upstream provider keys it stored.

Sources

Last reviewed: 24 November 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

We email you a link to confirm, and only then add you to the list. Unsubscribe in one click. Privacy

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.