CVE-2026-40217LiteLLM guardrail tester runs attacker Python as root behind a guessable master key
What broke
LiteLLM is a proxy that sits between applications and LLM providers and holds their API keys. Its POST /guardrails/test_custom_code endpoint lets an administrator try out a custom guardrail written in Python. X41 D-Sec's advisory X41-2026-001, published April 8, 2026, showed that the endpoint's regex-based sandbox can be escaped by rewriting a generator's bytecode to reach the real __import__, so an attacker can "execute arbitrary commands as the user the LiteLLM process runs as," which is root in the default Docker image. BerriAI's advisory GHSA-wxxx-gvqv-xp7p says the endpoint "requires a proxy-admin credential in default configurations" and lists versions 1.81.8 up to 1.83.10 as affected; v1.83.10-stable replaced the hand-rolled sandbox with RestrictedPython. NVD scores it CVSS 3.1 8.8 and lists CWE-420 (unprotected alternate channel) and CWE-94.
The admin requirement did not hold everywhere. Obsidian Security showed on June 11, 2026 that before v1.82.0-stable a default internal_user could mint a key with wildcard routes (CVE-2026-47101) and reach the endpoint, and that a self-update could promote a user to proxy_admin (CVE-2026-47102). Zenity Labs reported on June 30, 2026 that its honeypots logged 569 requests to the endpoint between April 15 and May 24. Attackers sent 47 different guessed master keys, including sk-1234, LiteLLM's documented example key, and sk-admin, then ran payloads that serialized environment variables whose names contained key, secret, api, aws or master. CISA added it to KEV on November 18, 2026.
Why it matters
An AI gateway is a credential broker, and here the credential that guarded code execution was often a value an attacker could guess. Once code runs inside the proxy, every provider API key in its config or environment is readable, and Obsidian notes that the salt key in the same environment decrypts keys stored in the database. The earlier LiteLLM flaw in this catalog, CVE-2026-59822, made a failed token check produce a user. This one shows the other half of the same lesson: an admin-only feature is only as safe as the admin key and the role checks in front of it.
What to do
- Upgrade LiteLLM to v1.83.14-stable or later, which also closes the CVE-2026-47101 and CVE-2026-47102 escalation path.
- Until then, block
POST /guardrails/test_custom_codeat the reverse proxy or API gateway. - Replace any default or guessable master key, keep the management interface off the internet, and run the container as a non-root user.
After you patch
- Rotate the LiteLLM master key, the salt key and every provider API key the proxy holds, since the observed payloads targeted exactly those.
- Search proxy logs for POST requests to
/guardrails/test_custom_codefrom outside your admin network and for bursts of failed requests with shortsk-bearer values.
Sources
- NVD: CVE-2026-40217
- BerriAI security advisory GHSA-wxxx-gvqv-xp7p
- X41 D-Sec advisory X41-2026-001: LiteLLM guardrail sandbox escape
- Obsidian Security: Breaking LiteLLM, from low-privilege user to admin and RCE
- Zenity Labs: threat actors are trying to use LiteLLM's guardrail tester to run code as root (June 30, 2026)
- CISA Known Exploited Vulnerabilities catalog, added November 18, 2026
Related on Start with Identity
- BlogCISA adds LiteLLM guardrail sandbox escape to KEV, and it starts with a proxy-admin key
CISA added CVE-2026-40217 to KEV on November 18. LiteLLM's custom-code guardrail test endpoint ran Python in a hand-rolled sandbox that bytecode tricks escape,
- CVECommvault Web Server zero-day that exposed Metallic Microsoft 365 app secrets
An authenticated webshell flaw in Commvault Web Server, used as a zero-day in Commvault's Azure environment, where the actor may have reached client secrets cus
- CVEtj-actions/changed-files tags repointed to dump CI secrets into logs
An attacker repointed tj-actions/changed-files version tags to a commit that read the GitHub Actions runner's memory and printed its secrets into workflow logs.
- CVETrivy release and GitHub Action tags hijacked to steal CI secrets
With credentials left valid by a non-atomic rotation, an attacker shipped a malicious Trivy v0.69.4 and repointed 76 of 77 trivy-action tags to code that dumped
- BlogLiteLLM traces its poisoned release to an admin key leaked in May and never revoked
LiteLLM's October 23 attack-chain report says an Agent Platform admin key committed to a public repo on May 27 was deleted but never revoked. On October 10 it r
- BlogNearly one in ten exposed LiteLLM gateways still accept the documentation's example admin key
Wiz found 3,074 internet-facing LiteLLM gateways, of which 294 accepted sk-1234, the key printed in the setup docs. In 191 of those no key was set at all, which