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.

By 0xScorPionSon

7 min read

LiteLLM Proxy Flaw (CVE-2026-40217) Added to CISA KEV: How Guardrail Bytecode Rewriting Enables LLMjacking

BerriAI LiteLLM CVE-2026-40217 CISA KEV LLMjacking and RCE infographic

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 confuse CVE-2026-40217 (a product vulnerability patched in April 2026) with the separate LiteLLM 1.107.0 PyPI/Docker credential-stealer compromise; neither CVE-2026-40217 nor CVE-2026-59822 has 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.10 as patched while its patch paragraph specifies 1.83.11 or later, Brandefense and Tuskira AI advise upgrading directly to 1.83.11 or later.
    • Performance Benchmarks: Quantitative proxy latency or throughput benchmarks comparing RestrictedPython guardrails in 1.83.11+ against prior versions are unavailable in the fetched advisories.

Hardening Playbook

  1. 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.8 through < 1.83.11 is in scope) and who holds LITELLM_MASTER_KEY or proxy-admin tokens.
  2. Upgrade to LiteLLM 1.83.11 or Later

    • Upgrade all instances to LiteLLM 1.83.11 or later, then verify the live running version inside each container or process rather than trusting latest tags or stale package manifests.
  3. Block /guardrails/test_custom_code & Isolate Management Interfaces

    • Configure your reverse proxy, Kubernetes Ingress, or API gateway to return 403 Forbidden for /guardrails/test_custom_code if you do not actively use custom-code guardrail testing, and restrict all LiteLLM admin/management routes to trusted internal administrative networks.
  4. Run Containers Non-Root & Rotate Exposed Secrets

    • Redeploy LiteLLM containers with an explicit non-root --user flag.
    • 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, rotate LITELLM_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
    
  5. Rollback & Change-Control Notes

    • Before upgrading to 1.83.11+, verify whether any existing custom-code guardrails rely on Python builtins disallowed by RestrictedPython. If a custom guardrail breaks after upgrading, keep 1.83.11+ deployed and refactor the guardrail to use RestrictedPython-safe constructs—never roll back to < 1.83.11 with /guardrails/test_custom_code exposed.

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

  1. 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
  2. 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/
  3. Tuskira AI Advisories — CVE-2026-40217 LiteLLM proxy code execution. Published: November 19, 2026. URL: https://www.tuskira.ai/advisories/cve-2026-40217
  4. Miggo Security — CVE-2026-40217: LiteLLM Guardrail Sandbox RCE. Accessed: November 20, 2026. URL: https://www.miggo.io/vulnerability-database/cve/CVE-2026-40217
  5. 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/

More on AI

AI

GPT-6.2 Astra vs Gemini 4 Carbon and Claude Opus 5.5: Token Cost Inversion, Code Review Noise, and Jailbreak Regressions

OpenAI launched GPT-6.2 Astra and Sol on November 17, 2026, alongside a new System Card and Codex sandbox architecture. While Astra leads Claude Opus 5.5 on Intelligence Index v5.0.1 (62.1 vs 59.1) and costs 2.5x less per task despite double the rate-card price, teams face a 272K long-prompt surcharge, noisier PR review comments, and a reported universal jailbreak regression. Here is how Astra, Sol, Gemini 4 Carbon, and Claude Opus 5.5 compare.

7 min read

AI

Microsoft agent-framework PyPI Hijack: How Two Malicious Releases Used .pth Hooks to Steal AI and Cloud Keys

On November 17, 2026, attackers published two malicious releases (1.26.1 and 1.26.2) of Microsoft's official agent-framework Python AI SDK on PyPI within 33 minutes. Using .pth startup hooks that fire on every Python invocation—even without importing the package—the payload harvested environment variables, /proc/*/environ secrets, and cloud/AI keys, and attempted to mint Azure DevOps, GitHub Actions OIDC, and Azure managed-identity tokens. This defensive incident breakdown covers the full timeline, SHA-256 IOCs, safe non-Python containment steps, and token revocation.

6 min read

Tell us what is not working

A thirty-minute call, no deck and no obligation. You will leave with a straight answer about whether this is worth building - including if that answer is no.

Start a project

Direct line

hello@codebumble.net
Dhaka, Bangladesh  :   local timeCalls in English or Bangla