Skip to content
Start with Identity
Identity CVE · Other

CVE-2026-40217LiteLLM guardrail tester runs attacker Python as root behind a guessable master key

SWI rating: highCVSS 8.8CISA KEVActively exploited
Product: LiteLLMVendor: BerriAICWE-420Disclosed: 2026-04-08Status: Actively exploitedNVD ↗CISA KEV ↗

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_code at 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_code from outside your admin network and for bursts of failed requests with short sk- bearer values.

Sources

Last reviewed By SWI Community TeamSuggest a correctionHow we research
Know a primary source we should add, or a patch status that has changed? Email community@startwithidentity.com. See all briefs in the identity CVE catalog, or volunteer as a CVE Analyst.
Compiled from vendor advisories, NVD, CISA KEV, and public research. CVSS figures can disagree across NVD and the CNA. Confirm affected versions against the vendor advisory before you patch. Independent, community-driven analysis. See the disclaimer.