# LiteLLM guardrail tester runs attacker Python as root behind a guessable master key

Source: https://startwithidentity.com/cves/cve-2026-40217/
Last updated: 2026-11-23
License: content by Start with Identity. Cite the source URL.

---

## 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](https://startwithidentity.com/glossary/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](https://startwithidentity.com/cves/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

- [NVD: CVE-2026-40217](https://nvd.nist.gov/vuln/detail/cve-2026-40217)
- [BerriAI security advisory GHSA-wxxx-gvqv-xp7p](https://github.com/BerriAI/litellm/security/advisories/GHSA-wxxx-gvqv-xp7p)
- [X41 D-Sec advisory X41-2026-001: LiteLLM guardrail sandbox escape](https://www.x41-dsec.de/lab/advisories/x41-2026-001-litellm/)
- [Obsidian Security: Breaking LiteLLM, from low-privilege user to admin and RCE](https://obsidiansecurity.com/blog/litellm-privilege-escalation-rce)
- [Zenity Labs: threat actors are trying to use LiteLLM's guardrail tester to run code as root (June 30, 2026)](https://labs.zenity.io/p/threat-actors-are-trying-to-use-litellm-s-guardrail-tester-to-run-code-as-root)
- [CISA Known Exploited Vulnerabilities catalog, added November 18, 2026](https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2026-40217)
