On November 18, 2026, CISA added CVE-2026-40217 to its Known Exploited Vulnerabilities (KEV) catalog for BerriAI LiteLLM. The flaw is an unprotected alternate channel at POST /guardrails/test_custom_code: authenticated admins can submit Python for guardrail testing, but X41 D-Sec advisory X41-2026-001 showed bytecode rewriting escapes the regex-filtered sandbox and runs arbitrary commands in the proxy process—as root in the default Docker image. GitHub advisory GHSA-wxxx-gvqv-xp7p fixed the hand-rolled sandbox in litellm 1.83.10+ with RestrictedPython. If you route Claude Code, Codex, or batch jobs through LiteLLM, treat the KEV row as patch-now: verify pip show litellm, block the route at the edge if you lag on upgrades, and rotate master and provider keys after any suspicious admin traffic.
See Beam’s and the LiteLLM tool page for version tables; this post adds the November 18 KEV context on top of the May 2026 disclosure.
TL;DR
| Question | Answer |
|---|---|
| Am I affected? | litellm >= 1.81.8 and < 1.83.10 (pip) or images built before the patch |
| Is it exploited? | Yes — CISA KEV date added 2026-11-18 |
| Is there a fix? | pip install --upgrade litellm to 1.83.11+; verify RestrictedPython path |
| Auth required? | Proxy-admin credential (e.g. master key) in default configs |
| Federal due date? | 2026-12-02 |
| Workaround? | Deny POST /guardrails/test_custom_code at reverse proxy |
| Data leave my machine? | Exploit hits your gateway host; all keys on that process are in scope |
What CISA published on November 18, 2026
The KEV catalog entry for CVE-2026-40217 names BerriAI | LiteLLM, cites CWE-420 (unprotected alternate channel), and repeats the vendor sentence: remote attackers can achieve arbitrary code via bytecode rewriting at /guardrails/test_custom_code. Date added is 2026-11-18 with due date 2026-12-02. Forensic triage under BOD 26-04 is No for this CVE; ransomware use is Unknown.
That KEV line upgrades urgency for teams who treated GHSA-wxxx-gvqv-xp7p as “authenticated admin only” in May. Adversaries now meet the catalog bar for known exploitation.
Mechanism: from guardrail test to root in Docker
LiteLLM is an OpenAI-compatible LLM proxy teams use to centralize provider keys, rate limits, and guardrails—a common pattern when coding agents share one gateway.
Step 1 — Admin-authenticated POST
The /guardrails/test_custom_code endpoint accepts JSON with custom_code (Python) and test_input. It is meant to let operators test custom guardrail functions before deployment. X41 and GitHub’s advisory agree the call needs Authorization: Bearer with a proxy-admin credential—typically the LITELLM_MASTER_KEY.
Step 2 — Regex filter that does not touch bytecode
The pre-patch server filtered “dangerous” names like __import__ and __globals__ with regex on source text. Attackers built those strings with runtime concatenation so the source never contained literal blocked tokens.
Step 3 — Generator bytecode swap
X41’s chain obtains object via str.mro()[1], reads a generator’s gi_code, uses code.replace(co_names=...) to retarget names, swaps __code__ onto the generator with object.__setattr__, then drives the generator to recover real __builtins__ and __import__.
Step 4 — Code execution as proxy user
With __import__, the proof of concept runs os.popen("id"). In the default ghcr.io/berriai/litellm:main-latest image X41 tested, that returned uid=0(root). GitHub’s advisory states the same impact: arbitrary code in the proxy process running root in default Docker.
Step 5 — Post-exploit value for agent fleets
A compromised proxy can exfiltrate every provider API key, rewrite responses to agents, or log full prompts from Claude Code or Codex sessions. That is adjacent to LLMjacking stolen keys but local to your gateway host.
Affected versions, fixes, and verification commands
| Source | Affected | Patched |
|---|---|---|
| GHSA-wxxx-gvqv-xp7p | >= 1.81.8, < 1.83.10 | >= 1.83.10 |
| Advisory narrative | Same | 1.83.11 with RestrictedPython |
| Release v1.83.10-stable | — | Tagged stable line |
Check version:
pip show litellm
Upgrade:
pip install --upgrade 'litellm>=1.83.11'
For Docker, bump the image tag and redeploy; do not assume main-latest is patched without checking the digest against your patch window.
Workaround (from GitHub and X41): at nginx or similar, deny location /guardrails/test_custom_code. Also narrow network ACLs on the admin port and avoid sharing the master key with automation users.
How to tell if you were hit
Neither CISA nor the GitHub advisory ships IOCs. Reasonable hunts:
- HTTP logs for
POST .../guardrails/test_custom_codeoutside change windows - Bodies containing concatenated underscore strings,
gi_code, orco_names - New processes, files, or egress from the LiteLLM container after such POSTs
- Master key use from unexpected IPs
After suspicion, rotate LITELLM_MASTER_KEY, database credentials, and all provider keys the proxy held—same playbook as LiteLLM PyPI compromise recovery.
What this means if you run AI coding agents
Many teams park one LiteLLM instance between IDE agents and cloud models so keys never sit on every laptop. That architecture concentrates risk on CVE-2026-40217:
- Agents are not the exploit vector, but they are the consumers of a poisoned gateway.
- Salt-key escalation (CVE-2026-114612) and this sandbox escape are different bugs—patch both lines if you run current LiteLLM.
- Do not store the master key in MCP env blocks, skills, or
.envfiles agents edit; Beam scans heuristics catch some leaks but not runtime theft after RCE.
What Beam can and cannot do here
Beam can flag risky shell commands via Claude Code and Codex PreToolUse hooks, scan skills and MCP configs before execution, and keep an on-device audit trail of tool use. It does not patch LiteLLM, does not sit in front of your proxy’s admin API, and cannot prevent bytecode escape on the server. Use Beam on workstations that call the gateway; patch the gateway on the server.
Comparison to earlier LiteLLM incidents
| Incident | Mechanism | Agent angle |
|---|---|---|
| CVE-2026-114612 | Salt key reuse → forged admin | Breaks Claude Code SSO paths |
| PyPI/docker compromise | Supply chain | Malicious package install |
| CVE-2026-40217 (KEV) | Guardrail test sandbox escape | Exploited server RCE |
Disclosure timeline: X41, GitHub, and KEV
Understanding the calendar helps you explain why May 2026 patches still miss KEV urgency in November 2026:
| Date | Event |
|---|---|
| 2026-02-13 | X41 identifies sandbox escape and builds proof of concept (X41-2026-001) |
| 2026-04-08 | X41 publishes after coordination window |
| 2026-05-07 | GHSA-wxxx-gvqv-xp7p published |
| 2026-05-11 | CVE-2026-40217 assigned |
| 2026-11-18 | CISA KEV date added — exploitation treated as ongoing |
Teams that patched in Q2 2026 but forked old images, or re-deployed compose files pinning main-latest digests from before 1.83.10, can still be vulnerable. KEV is the signal to re-audit every environment, not only production pip pins.
Docker and compose checks agent teams use
LiteLLM often ships as docker compose up on the same host that runs batch embedding jobs or nightly agent evals. After KEV:
docker inspect litellm --format '{{.Config.Image}}'
docker exec litellm pip show litellm 2>/dev/null || echo "check image build metadata"
If the container prints < 1.83.10, rebuild from a tagged release (v1.83.10-stable), not an unchecked latest pointer.
Non-root runtime (X41 and GitHub workarounds): run the container with --user so escape stays unprivileged—defense in depth, not a substitute for RestrictedPython.
Master key hygiene when agents share the proxy
Coding agents encourage pasting keys into .env, MCP server env blocks, and CI secrets. The LITELLM_MASTER_KEY is exactly the credential test_custom_code expects.
| Mistake | Why KEV matters more |
|---|---|
Master key in repo .env.example agents fill in | Any CI leak becomes admin RCE |
| Same key on staging and production | Staging escape → prod keys |
Agent curl recipes hitting :4000 with Bearer token | Teaches attackers the URL shape |
Rotate the master key after patch. Invalidate database sessions and virtual keys your proxy issued. Cross-check with credential stealer targeting agent frameworks patterns—attackers already hunt agent env files.
RestrictedPython fix: what changed
GitHub’s advisory states the hand-rolled sandbox became RestrictedPython. That moves execution from regex-on-source to a purpose-built restricted interpreter—closer to how Python sandboxes are supposed to work, though no sandbox is perfect for arbitrary code testing endpoints.
Operational guidance: if your team never calls /guardrails/test_custom_code, disable the route even on patched builds. Guardrail testing belongs in CI with ephemeral containers, not on the long-lived key-bearer process.
Federal and enterprise patching cadence
CISA set due date 2026-12-02—shorter than some infrastructure KEV entries, aligning LiteLLM with LLM gateway tiering. Pair with CVE volume record guidance so agent-driven bulk bump PRs actually merge before the due date.
Incident response checklist (gateway operators)
If you suspect exploitation against an internet-reachable LiteLLM admin API, work from the outside in:
- Snapshot the container or VM for forensics before rebuild.
- Revoke
LITELLM_MASTER_KEY, database passwords, and every provider key stored in the proxy config or UI. - Search reverse-proxy logs for
test_custom_codePOST bodies with concatenated dunder names orgi_codestrings. - Compare running image digest against
v1.83.10-stableor newer release tags on GitHub. - Notify teams whose agents used the gateway during the exposure window—they may need local key rotation too.
- Re-enable only after upgrade and optional WAF deny on the test route.
Document findings in your AI compliance audit trail if regulators ask what models touched which keys during the window—see audit trail solution for what to record from agent hosts even when the breach was server-side.
CVSS and prioritization nuance
GitHub’s advisory lists Moderate 5.9 on CVSS v4 while NVD’s analysis block cites 8.8 on CVSS 3.1—different scales, same bug. CISA KEV listing cuts through severity arguments: treat exploitation as confirmed. EPSS on Beam’s was already elevated before KEV; the catalog row is the executive signal for patch boards.
When agents generate risk tickets, ensure they cite KEV date added, not only GHSA moderate label—otherwise SOC may deprioritize below flashier CVSS 9.8 bugs that are not yet exploited.
Link the ticket to OWASP agent guidance for gateways so owners patch before agents schedule guardrail experiments on production hosts.
Frequently asked questions
What is CVE-2026-40217?
It is a sandbox escape in LiteLLM’s guardrail testing API that becomes full proxy RCE, often as root in default Docker.
Is CVE-2026-40217 exploited in the wild?
CISA KEV (2026-11-18) answers yes for catalog purposes.
Which LiteLLM versions fix CVE-2026-40217?
≥ 1.83.10, prefer ≥ 1.83.11 per advisory text.
How do I block the endpoint without upgrading?
Reverse-proxy deny on POST /guardrails/test_custom_code—documented by GitHub and X41.
Does this replace patching CVE-2026-114612?
No. CVE-2026-114612 is a different escalation chain on newer LiteLLM lines—track both on /cve/tool/litellm.
Related reading
- LiteLLM CVE-2026-114612: proxy admin escalation
- LLMjacking and stolen LiteLLM keys (GTIG)
- MCP and gateway security practical guide
- November 2026 attacks timeline
- Agent runtime security solutions
- What is AI agent monitoring?
Version numbers and advisory text reflect GitHub, X41, and CISA sources as of November 18, 2026. Beam is a local hook-based prototype; it does not replace gateway patching or network segmentation.

