79% vs 51%: independent neobanks lag on app security. Read the report

Deep Dive

Deep Dive

LiteLLM Guardrail Sandbox Escape RCE (CVE-2026-40217)

A LiteLLM proxy administrator can run code as the proxy process, which runs as root in the default Docker image. Upgrade to 1.83.11 or later.

TL;DR

  • LiteLLM's /guardrails/test_custom_code endpoint ran user-supplied Python in a hand-rolled sandbox that a proxy administrator could escape. The escaped code runs as the proxy process, which is root in the default Docker image.
  • The GitHub Advisory Database rates CVE-2026-40217 CVSS v3.1 8.8 High and CVSS v4.0 7.5 High. The endpoint requires a proxy-admin credential in a default installation.
  • CISA added CVE-2026-40217 to KEV on 2026-11-18. The federal remediation deadline is 2026-12-02.
  • Upgrade to 1.83.11 or later, or block POST /guardrails/test_custom_code at the reverse proxy until you do.

Am I affected?

All of these must hold:

  • The LiteLLM proxy runs 1.81.8 or later, before 1.83.10.
  • The /guardrails/test_custom_code endpoint is reachable.
  • An attacker has a proxy-admin API key or can obtain one.

The endpoint is part of the proxy and authenticates the caller with user_api_key_auth. The function then checks that the caller's role is PROXY_ADMIN:

if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
    raise HTTPException(...)

That check is why the CVE record gives PR:L (privileges required: low) rather than PR:N. The KEV description calls the attacker "remote", which describes the network path, not the authentication requirement. A lower-privileged user cannot call the endpoint; a compromised or malicious proxy administrator can.

Branch Affected versions Recommended upgrade
1.83.x 1.83.0 to 1.83.9 1.83.11
1.82.x 1.82.0 to 1.82.x 1.83.11 or later
1.81.x 1.81.8 to 1.81.x 1.83.11 or later
Earlier Not listed as affected Not applicable

The vendor’s package metadata lists 1.83.10 as the first patched version. Its advisory directs operators to upgrade to 1.83.11 or later.

Check what is installed:

# Python installs
pip show litellm | grep -E "^Version"

# Docker deployments, inside the running container
docker exec <container> pip show litellm | grep -E "^Version"

# A virtual environment
/path/to/venv/bin/pip show litellm | grep -E "^Version"

How do I fix it?

Upgrade to 1.83.11 or later. The fix replaces the regex-based sandbox with RestrictedPython, so the endpoint keeps working but the escape path is closed.

pip install --upgrade "litellm>=1.83.11"

# Docker
docker pull ghcr.io/berriai/litellm:main-stable
  1. Upgrade every proxy that serves the admin API, including replicas and staging deployments.
  2. Recreate the container rather than only pulling the image, so the new package is used by the running process.
  3. Confirm the version with pip show litellm inside the running container.
  4. If you cannot upgrade immediately, block POST /guardrails/test_custom_code at the reverse proxy or API gateway. That removes the documented path but leaves the old sandbox in place.

The upgrade is the complete fix. Blocking the endpoint is effective against this path because the endpoint is the only place the vulnerable compiler is reached. It does not repair a proxy that already ran the escape.

What is the root cause?

LiteLLM evaluated custom guardrail code inside the proxy process. The original sandbox filtered the text of a Python program but could not reliably restrict what it did at runtime. The updated implementation uses RestrictedPython to limit operations on the objects available to guardrails.

What can an attacker do?

Code executed through the flaw inherits the proxy process’s privileges. In the default Docker image, this is root inside the container. The deployment’s mounts, network policy and credentials determine what that process can reach.

  • The attacker can read the proxy's environment, including provider API keys, database credentials and the master key.
  • The attacker can read and modify the proxy configuration and the guardrail definitions.
  • The attacker can reach the container's network and any mounted files or sockets.
  • The attacker can use the proxy as a base for further access, depending on how the container is deployed.

The conditions are listed in full in "Am I affected?". A proxy administrator already has broad control over the proxy; this flaw turns that control into code execution outside the intended sandbox, which matters when the admin role is delegated or when one administrator credential is compromised.

How do I check if I was compromised?

There are no published indicators of compromise. The request is a normal authenticated admin call, and the response is a normal guardrail result.

# Requests to the test endpoint in the proxy or reverse-proxy log
grep -i "guardrails/test_custom_code" /var/log/litellm.log /var/log/nginx/access.log 2>/dev/null

Correlate requests with the administrator identity, configuration history and process or network events from the same time. Preserve relevant logs and container evidence before rebuilding. If you find evidence of code execution, revoke the affected credentials and rotate secrets accessible to the proxy.

The access log may omit the POST body. Check the LiteLLM application log and the reverse-proxy log before you conclude that a proxy is clean.

Timeline

  • 2026-04-08: X41 publishes advisory X41-2026-001.
  • 2026-04-10: the CVE record for CVE-2026-40217 is published.
  • 2026-04-27: LiteLLM 1.83.10 is released with the RestrictedPython sandbox.
  • 2026-11-18: CISA adds CVE-2026-40217 to KEV, with a federal due date of 2026-12-02.

Timeline of CVE-2026-40217: the advisory, the CVE record, the fix and the KEV listing
Figure 1: The flaw was fixed in April, and CISA recorded exploitation in November. Source: X41, the CVE record and the CISA KEV catalog, checked November 19, 2026.

FAQ

Is it unauthenticated?

No. The endpoint requires a proxy-admin API key. The CVE record gives PR:L, and the endpoint checks user_role == PROXY_ADMIN. The KEV summary says "remote", which describes the network path rather than the credential.

Which versions are affected?

Package metadata lists releases from 1.81.8 up to, but excluding, 1.83.10. For remediation the vendor recommends 1.83.11 or later.

Is there a public exploit?

X41 published a technical advisory in April 2026. CISA later confirmed that the vulnerability had been exploited.

Was it exploited in the wild?

CISA added the CVE to KEV on 2026-11-18, which records known exploitation. The KEV entry does not name victims or give a count, and X41 does not report one.

Does blocking the endpoint fix it?

Yes for this path. The endpoint is the only place the vulnerable compiler is reached, so blocking POST /guardrails/test_custom_code at the reverse proxy removes it. Upgrade as well, because the old sandbox remains in the code until you do.

Why does an admin-only flaw matter?

A proxy administrator can already change guardrails and read configuration. This flaw turns that role into code execution outside the intended sandbox, which matters when the admin role is delegated to a team, when a key leaks, or when the proxy runs with root in a shared container.

Find vulnerable LiteLLM deployments with Ostorlab

Ostorlab's SCA and SBOM inventories the open-source packages in your applications and container images. For a LiteLLM deployment, it shows which images and Python environments still pin a release before 1.83.11, so you can upgrade the proxies that expose the admin API first.

References

  • GitHub advisory, GHSA-wxxx-gvqv-xp7p, "LiteLLM has a sandbox escape in custom-code guardrail": https://github.com/BerriAI/litellm/security/advisories/GHSA-wxxx-gvqv-xp7p (checked November 19, 2026)
  • GitHub Advisory Database, GHSA-wxxx-gvqv-xp7p: https://github.com/advisories/GHSA-wxxx-gvqv-xp7p (checked November 19, 2026)
  • CVE record, CVE-2026-40217: https://www.cve.org/CVERecord?id=CVE-2026-40217 (checked November 19, 2026)
  • CISA Known Exploited Vulnerabilities catalog, CVE-2026-40217: https://www.cisa.gov/known-exploited-vulnerabilities-catalog (checked November 19, 2026)
  • X41 D-Sec, "Guardrail Sandbox Escape in LiteLLM", 2026-04-08: https://www.x41-dsec.de/lab/advisories/x41-2026-001-litellm/ (checked November 19, 2026)
  • LiteLLM v1.83.10-stable release: https://github.com/BerriAI/litellm/releases/tag/v1.83.10-stable (checked November 19, 2026)