CISA added CVE-2026-40217, a sandbox escape in the LiteLLM AI gateway’s custom-code guardrail, to its Known Exploited Vulnerabilities catalog on November 18. Federal civilian agencies have until December 2 to remediate. Google’s Threat Intelligence Group reported on November 17 that it had seen a threat actor exploit the bug. In that activity, the actor turned limited-access inference keys (LiteLLM “virtual keys”) into full admin credentials and then ran code on the proxy. The fix has been available since April, but plenty of self-hosted gateways are still on vulnerable builds.
A LiteLLM proxy holds every upstream model-provider key your organization uses, including OpenAI, Anthropic, Azure OpenAI and Bedrock, plus the master key that mints all the others. Code execution on the proxy exposes all of them.
The bug
LiteLLM lets admins write guardrails as small Python functions, and the proxy exposes a test endpoint for them: POST /guardrails/test_custom_code. In affected versions, the endpoint runs the submitted code inside a hand-rolled Python sandbox. That sandbox relies on name and attribute filtering, which is a pattern with a long history of failing. An attacker can escape it with bytecode-level tricks and by rebuilding blocked dunder names from string fragments. From there they reach subprocess and run arbitrary commands inside the proxy process. The official LiteLLM Docker image runs as root, so the result is root in the container, with the full environment and mounted secrets.
- Affected: LiteLLM
>= 1.81.8, < 1.83.10 - Fixed: the GitHub advisory (GHSA-wxxx-gvqv-xp7p) lists 1.83.10 as the first fixed version. Some downstream write-ups cite 1.83.11. The fix replaces the custom sandbox with RestrictedPython.
- Severity: CVSS v3.1 8.8 / CVSS v4.0 7.5
Why “admin-only” doesn’t save you
By default the endpoint requires a proxy-admin credential, which is why the base score is 8.8 rather than 9.8. That requirement gives less protection than it suggests. In June, Obsidian Security published a chain (rated CVSS 9.9) that gets a regular user to admin in two requests:
- CVE-2026-47101: when an
internal_usergenerates a virtual key, LiteLLM stores the caller-suppliedallowed_routeswithout checking it against the caller’s role. The result is a key scoped to admin routes. - CVE-2026-47102:
/user/updateand/user/bulk_updatedon’t protect theuser_rolefield, so a user can promote themselves toproxy_admin. - CVE-2026-40217: the attacker now has admin access, submits a guardrail to the test endpoint, escapes the sandbox and gets root.
GTIG’s description of virtual keys becoming admin credentials matches this chain. In practice, any leaked or low-privilege inference key handed to a developer, a CI job or an AI agent can lead to root on an unpatched gateway. The full fix set for the chain landed in v1.83.14-stable. Reporting indicates that 1.83.10 fixed only part of it.
Exploitation in the wild
Zenity’s honeypots logged 569 POST requests to /guardrails/test_custom_code between April 15 and May 24. The first probes arrived the same day the fix shipped. The opening wave was 520 identical go/no-go probes of the form def apply_guardrail(i,r,t): return {'probe':1}. Later requests used string-fragment dunder reconstruction and subprocess.Popen(..., shell=True). Six of the eight source IPs also hit /config/update and the api_base SSRF on the same day, a pattern that points to operators going after the master key and provider credentials. Reporting on the current campaign describes victims in finance, retail and technology, with quota theft and cryptomining as the payoff. That attribution has not been independently confirmed.
What to do now
- Upgrade to v1.83.14-stable or later. That release covers CVE-2026-40217 and the 47101/47102 escalation chain. Moving to 1.83.10 alone is not enough. Pin an explicit version and verify its hash. LiteLLM’s PyPI and Docker channels were backdoored earlier this year, so don’t float on
latest. - Get the admin UI and management routes off the internet.
/guardrails/*,/config/*,/key/*and/user/*should be reachable only from an admin network. Expose only the inference routes through your ingress. - Hunt. In access logs, look for any
POST /guardrails/test_custom_code. Outside of admins actively building guardrails, it is rare. Also look for/user/updateor/user/bulk_updatecalls that changeuser_role, and for keys whoseallowed_routesinclude admin paths. Check whether any process under the proxy container spawned a shell. - If you were exposed on an affected version, assume the secrets are gone. Rotate the LiteLLM master key, every upstream provider API key, the database credentials and any cloud credentials in the container environment. Review provider billing for quota abuse.
- Stop running the gateway as root. Set
runAsNonRoot, use a read-only root filesystem and drop capabilities. Inject provider keys from a secrets manager with short-lived credentials where providers support them.
References
- CISA KEV alert, November 18, 2026
- GitHub Advisory GHSA-wxxx-gvqv-xp7p (CVE-2026-40217)
- Obsidian Security: Breaking LiteLLM, low-privilege user to admin and RCE
- Zenity Labs: Threat actors are trying to use LiteLLM’s guardrail tester to run code as root
- CSA research note: LiteLLM AI gateway attack chain
- Heise: Attacks target flaws in Apache Axis and Roller, LiteLLM, Synology and more