← All playbooks
HighExploited vuln · 2026-11-19

LiteLLM CVE-2026-40217: guardrail test endpoint sandbox escape runs code as root, now exploited (CISA KEV)

SockAnalyst · Security+ certified analyst.

What happened

On November 18, 2026, CISA added CVE-2026-40217 in BerriAI's LiteLLM, the open-source proxy many teams put in front of OpenAI, Anthropic and other model APIs, to its Known Exploited Vulnerabilities catalog (due December 2, 2026). The flaw (CVSS 3.1 8.8, published April 10, 2026) is in POST /guardrails/test_custom_code, which runs user-supplied Python for testing custom guardrails inside a hand-rolled sandbox. Per LiteLLM's GitHub advisory GHSA-wxxx-gvqv-xp7p, that sandbox can be escaped with bytecode-level techniques, giving arbitrary code execution in the proxy process, which runs as root in the default Docker image. Reaching the endpoint requires a proxy-admin credential in default configurations, so the real-world risk is highest where the master key was left at a documented default. Zenity Labs reported honeypot traffic starting April 15, 2026 (the day the fix shipped): 569 POSTs to the endpoint that guessed default master keys such as sk-1234 and carried payloads ranging from a probe to environment-variable dumps aimed at stealing provider API keys.

Who's affected

Anyone self-hosting the LiteLLM proxy from 1.81.8 up to (not including) 1.83.10, especially the official Docker image (runs as root) reachable from the internet or a broad internal network, and any install still using a default or weak master key. A compromise exposes every model-provider API key, virtual key and database credential the proxy holds.

✅ Fix / patch

  • Upgrade LiteLLM to 1.83.11 or later; the advisory text says the hand-rolled sandbox was replaced with RestrictedPython in 1.83.11 (its package metadata lists the v1.83.10-stable release as patched). Federal agencies: remediate by Dec 2, 2026 per CISA KEV / BOD 26-04.
  • If you cannot upgrade now, block POST /guardrails/test_custom_code at your reverse proxy or API gateway, as the advisory recommends.
  • Replace any default or guessable master key (sk-1234 and similar) immediately and keep the admin API off the public internet.
  • If the endpoint was reachable on a vulnerable version, assume the environment was read: rotate the master key, every provider API key (OpenAI, Anthropic, Azure, AWS Bedrock, etc.) and the database URL stored in the proxy's environment, and review provider usage bills for spikes.
  • Consider LiteLLM's non-root image variant so a future escape does not land as root.

🔎 Quick hunt check

No attacker IPs, domains or hashes are published by LiteLLM or CISA. Hunt for behaviour: (1) any POST to /guardrails/test_custom_code (most teams never call it in production), especially from unfamiliar sources, with empty or default Authorization: Bearer values; (2) request bodies containing custom_code with runtime-built dunder names (string fragments like "_gl"+"ob"+"als"), gi_code, cr_frame or os.environ; (3) the LiteLLM proxy process (python/uvicorn) spawning sh, bash, curl or wget; (4) sudden spikes on your model-provider API keys from new IPs after a test_custom_code hit.

MITRE ATT&CK: T1190, T1078.001, T1059.006, T1552.001

IOCs

No IOCs (IPs, domains or hashes) published by the sources yet.

Hunt queries

Starting points built only from published indicators. Field names vary; tune before use.

```LiteLLM CVE-2026-40217: calls to the guardrail custom-code tester, sandbox-escape markers, proxy spawning shells```
index=* earliest=04/01/2026:00:00:00
("/guardrails/test_custom_code" OR "test_custom_code" OR (parent_process_name IN ("python","python3","uvicorn","litellm") AND process_name IN ("sh","bash","dash","curl","wget","nc")))
| eval uri=coalesce(uri_path, uri, url, cs_uri_stem, "")
| eval meth=upper(coalesce(http_method, method, cs_method, ""))
| eval signal=case(
    match(_raw,"test_custom_code") AND match(_raw,"(?i)gi_code|cr_frame|os\.environ|\"_\"\s*\+\s*\"_gl|__import__"), "sandbox_escape_markers",
    match(_raw,"test_custom_code") AND match(_raw,"(?i)Bearer\s+sk-(1234|litellm-master-key|admin|changeme)\b"), "default_master_key_guess",
    match(uri,"(?i)/guardrails/test_custom_code") AND (meth="POST" OR meth=""), "guardrail_tester_call",
    match(lower(coalesce(parent_process,"")),"litellm|uvicorn") AND match(lower(coalesce(process_name,"")),"^(sh|bash|dash|curl|wget|nc)$"), "litellm_spawned_shell",
    true(), null())
| where isnotnull(signal)
| eval client=coalesce(src, clientip, src_ip, c_ip)
| stats count min(_time) as first_seen max(_time) as last_seen values(signal) as signals values(status) as http_status values(process) as cmdlines by host, client
| convert ctime(first_seen) ctime(last_seen)
| sort - count
// LiteLLM CVE-2026-40217: guardrail custom-code tester calls, escape markers, LiteLLM process spawning shells
let Since = datetime(2026-04-01);
let Shells = dynamic(["sh","bash","dash","curl","wget","nc"]);
union isfuzzy=true
(CommonSecurityLog | where TimeGenerated >= Since
 | where RequestURL has "/guardrails/test_custom_code"
 | extend Signal = case(AdditionalExtensions has_any ("gi_code","cr_frame","os.environ","__import__"), "sandbox_escape_markers", AdditionalExtensions has_any ("sk-1234","sk-litellm-master-key","sk-admin","sk-changeme"), "default_master_key_guess", "guardrail_tester_call")
 | extend Who = SourceIP, Evidence = strcat(RequestMethod, " ", DestinationHostName, RequestURL)),
(AzureDiagnostics | where TimeGenerated >= Since
 | where requestUri_s has "/guardrails/test_custom_code"
 | extend Signal = "guardrail_tester_call", Who = clientIP_s, Evidence = strcat(httpMethod_s, " ", requestUri_s, " ", tostring(httpStatus_d))),
(DeviceProcessEvents | where TimeGenerated >= Since
 | where InitiatingProcessCommandLine has_any ("litellm","uvicorn") and FileName in~ (Shells)
 | extend Signal = "litellm_spawned_shell", Who = DeviceName, Evidence = ProcessCommandLine)
| summarize Hits = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), Signals = make_set(Signal), Evidence = make_set(Evidence, 20) by Who
| order by Hits desc

See all hunt queries →

⏱ CISA deadline

CVE-2026-40217CVSS 8.8 High (v3.1, CNA)
--
Federal due 2026-12-02 · CISA KEV catalog

Sources

Related playbooks

Get the SockAnalyst Weekly Brief free, every Thursday.

One email a week with the KEV deadlines, patches and hunt queries that matter. New playbooks still post here on the site every morning.

Subscribe free

Read the free weekly pack →