AI
LiteLLM Proxy Flaw (CVE-2026-40217) Added to CISA KEV: How Guardrail Bytecode Rewriting Enables LLMjacking
On November 18, 2026, CISA added BerriAI LiteLLM CVE-2026-40217 (CVSS 3.1: 8.8) to its Known Exploited Vulnerabilities catalog with a December 2 deadline under BOD 26-04. Attackers are exploiting the /guardrails/test_custom_code sandbox escape in LLMjacking campaigns to steal provider API keys and run code as root in default Docker containers. Learn why you must target 1.83.11+ rather than 1.83.10 and how to block the endpoint at your gateway.
7 min read
LiteLLM Proxy Flaw (CVE-2026-40217) Added to CISA KEV: How Guardrail Bytecode Rewriting Enables LLMjacking
Executive Summary
On November 18, 2026, the U.S. Cybersecurity and Infrastructure Security Agency (CISA) added CVE-2026-40217—an unprotected alternate channel vulnerability (CWE-420) in BerriAI LiteLLM—to its Known Exploited Vulnerabilities (KEV) catalog, assigning a federal remediation deadline of December 2, 2026 under BOD 26-04 (including mandatory Forensics Triage Requirements). Although BerriAI originally patched the flaw in April 2026 (GHSA-wxxx-gvqv-xp7p), Aviatrix Threat Research Center (November 20, 2026) and The Hacker News report that threat actors are actively exploiting CVE-2026-40217 in LLMjacking campaigns targeting the financial and retail sectors.
Discovered by X41 D-Sec (X41-2026-001, published April 8, 2026), CVE-2026-40217 resides in LiteLLM's custom-code guardrail testing endpoint (POST /guardrails/test_custom_code). By submitting crafted Python bytecode, an attacker who can reach the endpoint can escape LiteLLM's custom sandbox and execute arbitrary OS commands in the proxy process—which runs as root in the default Docker image—exposing every downstream OpenAI, Anthropic, AWS Bedrock, or Azure OpenAI API key stored in the proxy.
Severity ratings differ across advisories: MITRE and Red Hat score CVE-2026-40217 at 8.8 (High) under CVSS v3.1, whereas BerriAI scores it 5.9 (Moderate) under CVSS v4.0 because reaching the endpoint in a default deployment requires a proxy-admin credential. Notably, BerriAI's advisory contains an unresolved version conflict: its table marks 1.83.10 as patched, while its patch text instructs upgrading to 1.83.11 or later. Security teams should target LiteLLM 1.83.11 or newer immediately, block POST /guardrails/test_custom_code at the API gateway if patching must wait, and rotate any potentially exposed master and model-provider API keys.
| Attribute | Verified Value | Source |
|---|---|---|
| CVE Identifier | CVE-2026-40217 (CWE-420: Unprotected Alternate Channel) |
CISA KEV / NVD / SentinelOne |
| GitHub / Vendor Advisory | GHSA-wxxx-gvqv-xp7p (May 7, 2026); X41-2026-001 (Apr 8, 2026) |
GitHub / Brandefense / Tuskira |
| CVSS Scores | 8.8 High (CVSS 3.1, MITRE/Red Hat) / 5.9 Moderate (CVSS 4.0, BerriAI) | Tuskira AI / The Hacker News |
| Affected Versions | LiteLLM 1.81.8 through < 1.83.10 (target 1.83.11+ per patch text) |
Brandefense / Tuskira AI |
| CISA KEV Status | Added November 18, 2026; Due December 2, 2026 (BOD 26-04) |
CISA KEV / MLQ.ai |
| EPSS Score | 17.0% (Top 3% as of Nov 19, 2026) |
StrikeCyber |
| Active Exploitation | Leveraged in LLMjacking campaigns (financial & retail sectors) | Aviatrix TRC / CISA KEV |
Technical Mechanics and Architecture
Why LiteLLM's Hand-Rolled Guardrail Sandbox Failed
LiteLLM allows administrators to define and test custom Python guardrail logic via POST /guardrails/test_custom_code (and the equivalent config/DB custom_code guardrail compilation path). In affected builds (1.81.8 through < 1.83.11), LiteLLM attempted to restrict user-supplied Python by running a regex-based source validator (validate_custom_code in code_validator.py) and executing the compiled code with __builtins__ = {} inside guardrail_endpoints.test_custom_code_guardrail and CustomCodeGuardrail._do_compile.
As X41 D-Sec and Miggo Security documented, source-level regex filtering and clearing __builtins__ are insufficient to isolate Python execution: through bytecode rewriting and Python object introspection (traversing __globals__["__builtins__"]), an attacker can bypass the regex filter and invoke arbitrary OS commands.
In commit 0a1b4427a6c4ee07add32295e331bd0cf9cac572 ("fix(guardrails): replace custom_code sandbox with RestrictedPython"), BerriAI deleted code_validator.py and the raw exec(compile(...)) blocks, replacing them with RestrictedPython (compile_restricted and guarded globals via build_sandbox_globals / compile_sandboxed).
LLM Proxy Blast Radius Architecture
+-------------------------------------------------------------------------+
| ATTACKER WITH ADMIN KEY OR EXPOSED API |
| - Sends crafted Python / bytecode payload to: |
| POST /guardrails/test_custom_code |
+------------------------------------+------------------------------------+
|
v
+-------------------------------------------------------------------------+
| LITELLM PROXY CONTAINER (1.81.8 to < 1.83.11, Default: ROOT) |
| 1. Regex filter (validate_custom_code) bypassed |
| 2. Raw exec(compile(...)) escapes __builtins__={} sandbox |
| 3. Arbitrary OS code execution as container ROOT |
+------------------------------------+------------------------------------+
|
+-------------------------+-------------------------+
| |
v v
+-------------------------+ +---------------------+
| SECRETS & ENV HARVEST | | LLMJACKING ABUSE |
| - LITELLM_MASTER_KEY | | - Hijacks OpenAI, |
| - DB / Redis creds | | Anthropic, AWS, |
| - Provider API keys | | Azure AI quotas |
+-------------------------+ +---------------------+
Defensive Verification & Gateway Containment Snippets
1. Safe Host & Container Version Audit (Read-Only):
#!/usr/bin/env bash
# Read-only LiteLLM version and container privilege audit
set -euo pipefail
echo "=== Python Package Check ==="
python3 -m pip show litellm 2>/dev/null | grep -E '^(Name|Version):' || echo "litellm pip package not in active env"
echo "=== Running Docker Containers (Check Image Tag & User) ==="
if command -v docker >/dev/null 2>&1; then
docker ps --format '{{.ID}} {{.Image}} {{.Names}}' | grep -i litellm || echo "No running litellm containers"
for cid in $(docker ps -q --filter "ancestor=ghcr.io/berriai/litellm" 2>/dev/null); do
echo "Container $cid running as user: $(docker inspect -f '{{.Config.User}}' "$cid")"
done
fi
2. Defensive Nginx / Reverse-Proxy Endpoint Block (Interim Mitigation):
# Block POST /guardrails/test_custom_code at the reverse proxy or API gateway
# Reference: BerriAI GHSA-wxxx-gvqv-xp7p / Tuskira AI mitigation guidance
location = /guardrails/test_custom_code {
deny all;
return 403;
}
3. Non-Root Docker Hardening (--user):
Per X41 D-Sec's guidance, never run the LiteLLM proxy container as root (the default image behavior). Explicitly drop to a non-root UID/GID (--user 10001:10001) and restrict management-interface ingress to internal admin subnets only.
Evidence & Operational Impact
Active Exploitation & KEV Context
- LLMjacking in Financial & Retail Sectors: Aviatrix Threat Research Center reported on November 20, 2026 that CVE-2026-40217 was leveraged in LLMjacking campaigns targeting financial and retail organizations—where attackers compromise AI inference proxies to siphon commercial model API quotas, exfiltrate prompts/responses, or pivot into cloud environments.
- Note on Unrelated Supply-Chain Incident (
1.107.0): On the LiteLLM supply-chain front, Phoenix Security specifically warned defenders not to confuseCVE-2026-40217(a product vulnerability patched in April 2026) with the separateLiteLLM 1.107.0PyPI/Docker credential-stealer compromise; neitherCVE-2026-40217norCVE-2026-59822has been confirmed as the access vector for that supply-chain incident. - Version Discrepancy & Benchmarks:
- 1.83.10 vs. 1.83.11: Because BerriAI's advisory table marks
1.83.10as patched while its patch paragraph specifies1.83.11 or later, Brandefense and Tuskira AI advise upgrading directly to1.83.11or later. - Performance Benchmarks: Quantitative proxy latency or throughput benchmarks comparing
RestrictedPythonguardrails in1.83.11+against prior versions are unavailable in the fetched advisories.
- 1.83.10 vs. 1.83.11: Because BerriAI's advisory table marks
Hardening Playbook
Inventory Self-Hosted LiteLLM Proxies
- Identify every self-hosted LiteLLM proxy container, VM, or Python virtual environment—including internal developer sandboxes and staging gateways—and record the running version (
1.81.8through< 1.83.11is in scope) and who holdsLITELLM_MASTER_KEYor proxy-admin tokens.
- Identify every self-hosted LiteLLM proxy container, VM, or Python virtual environment—including internal developer sandboxes and staging gateways—and record the running version (
Upgrade to LiteLLM
1.83.11or Later- Upgrade all instances to LiteLLM
1.83.11or later, then verify the live running version inside each container or process rather than trustinglatesttags or stale package manifests.
- Upgrade all instances to LiteLLM
Block
/guardrails/test_custom_code& Isolate Management Interfaces- Configure your reverse proxy, Kubernetes Ingress, or API gateway to return
403 Forbiddenfor/guardrails/test_custom_codeif you do not actively use custom-code guardrail testing, and restrict all LiteLLM admin/management routes to trusted internal administrative networks.
- Configure your reverse proxy, Kubernetes Ingress, or API gateway to return
Run Containers Non-Root & Rotate Exposed Secrets
- Redeploy LiteLLM containers with an explicit non-root
--userflag. - If an unpatched (
< 1.83.11) LiteLLM proxy was reachable from the internet or untrusted internal networks—or if proxy-admin credentials may have leaked—follow BOD 26-04 triage principles: preserve logs, rotateLITELLM_MASTER_KEY, and rotate all downstream LLM provider API keys (OpenAI, Anthropic, Azure, Bedrock, Vertex) stored in the proxy.
Example SIEM/reverse-proxy hunting query (Splunk/SPL-style) for guardrail test abuse and anomalous child processes:
index=web_proxy OR index=ingress uri_path="*/guardrails/test_custom_code*" | stats count values(status) as http_status values(http_user_agent) as uas by src_ip, host, _time span=15m- Redeploy LiteLLM containers with an explicit non-root
Rollback & Change-Control Notes
- Before upgrading to
1.83.11+, verify whether any existing custom-code guardrails rely on Python builtins disallowed byRestrictedPython. If a custom guardrail breaks after upgrading, keep1.83.11+deployed and refactor the guardrail to useRestrictedPython-safe constructs—never roll back to< 1.83.11with/guardrails/test_custom_codeexposed.
- Before upgrading to
Frequently Asked Questions (FAQ)
1. Should we upgrade to LiteLLM 1.83.10 or 1.83.11 to fix CVE-2026-40217?
Upgrade to 1.83.11 or later. BerriAI's advisory contains a conflict between its version table (1.83.10) and its patch instructions (1.83.11), so Brandefense and Tuskira AI recommend 1.83.11+ as the safe target.
2. Does CVE-2026-40217 require authentication?
In default configurations, BerriAI states that reaching /guardrails/test_custom_code requires a proxy-admin credential. However, if admin keys are weak, shared in CI/env files, or combined with privilege-escalation/auth-bypass flaws, attackers can reach the endpoint and execute code as root in default Docker images.
3. Why did CISA add CVE-2026-40217 to KEV seven months after it was patched? CISA adds vulnerabilities to KEV when it confirms active exploitation in the wild—regardless of patch age. In November 2026, attackers actively targeted unpatched LiteLLM instances in LLMjacking campaigns, prompting the November 18 KEV addition with a December 2, 2026 deadline.
4. Is CVE-2026-40217 the same as the LiteLLM 1.107.0 PyPI supply-chain attack?
No. CVE-2026-40217 is a product sandbox-escape vulnerability in LiteLLM's guardrail testing endpoint (GHSA-wxxx-gvqv-xp7p), whereas the 1.107.0 incident was a separate PyPI/Docker package backdoor.
5. What keys must be rotated if our unpatched LiteLLM proxy was exposed?
Rotate LITELLM_MASTER_KEY, database/Redis credentials used by the proxy, and every downstream model-provider API key (OpenAI, Anthropic, AWS, Azure, Google) configured inside LiteLLM.
Sources
- CISA Known Exploited Vulnerabilities (KEV) Catalog — CVE-2026-40217: BerriAI LiteLLM Unprotected Alternate Channel Vulnerability. Added: November 18, 2026 (Due: December 2, 2026). URL: https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- Brandefense Knowledge Hub — CVE-2026-40217: LiteLLM Sandbox Escape, Fix Status. Published: November 19, 2026. URL: https://brandefense.io/knowledge-hub/vulnerabilities/cve-2026-40217/
- Tuskira AI Advisories — CVE-2026-40217 LiteLLM proxy code execution. Published: November 19, 2026. URL: https://www.tuskira.ai/advisories/cve-2026-40217
- Miggo Security — CVE-2026-40217: LiteLLM Guardrail Sandbox RCE. Accessed: November 20, 2026. URL: https://www.miggo.io/vulnerability-database/cve/CVE-2026-40217
- Aviatrix Threat Research Center — Four CVEs, Four Threat Vectors (CVE-2026-40217 LLMjacking). Published: November 20, 2026. URL: https://aviatrix.ai/threat-research-center/cisa-kev-2026-cve-2026-90436-cve-2026-90817-cve-2026-40217-cve-2024-10441-ransomware-cryptomining-llmjacking/