On November 18, 2026, the U.S. Cybersecurity and Infrastructure Security Agency (CISA) added CVE-2026-40217, a code-execution flaw in the LiteLLM proxy, to its Known Exploited Vulnerabilities (KEV) catalog. In other words, it is now being used in real attacks. The flaw was disclosed in April 2026 and fixed versions already exist, so any LiteLLM proxy that has not been updated since then should be patched now.
Quick summary:
- What: a sandbox escape in the LiteLLM proxy's
/guardrails/test_custom_codeendpoint that leads to arbitrary code execution on the server. - Who can trigger it: someone holding a proxy-admin credential (the master key in default setups).
- Status: actively exploited (CISA KEV, added November 18, 2026).
- Fix: upgrade LiteLLM to 1.83.11 or later. Can't upgrade yet? Block
/guardrails/test_custom_codeat your reverse proxy.
Overview
- Type: code injection (CWE-94) through a sandbox escape
- CVE: CVE-2026-40217 (NVD) / GHSA-wxxx-gvqv-xp7p (LiteLLM advisory)
- Severity: CVSS 3.1 8.8 (High) — AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H (NVD, Red Hat)
- Exploitation: confirmed in the wild — listed in CISA KEV on November 18, 2026, with a remediation due date of December 2, 2026 for U.S. federal agencies
- Discovered by: X41 D-Sec (advisory X41-2026-001)
What is LiteLLM, and what went wrong?
LiteLLM is a popular open-source gateway that puts one OpenAI-compatible API in front of many LLM providers. Teams use its proxy server to manage API keys, track costs, apply rate limits and add "guardrails" that filter what goes into and out of the models.
One guardrail feature lets administrators write custom Python code. To try that code out, the proxy offers a test endpoint, POST /guardrails/test_custom_code, which runs the submitted code inside a home-made sandbox. That sandbox only filtered the source text for dangerous names. X41 showed that it can be bypassed by rewriting Python bytecode at runtime, which gives the code full access to the server. In LiteLLM's default Docker image, the proxy process runs as root.

Once code runs inside the proxy, the attacker can reach whatever the proxy process can reach — its configuration and secrets, connected services, and the host or container it runs on.
Who is affected?
- Affected: organizations that self-host the LiteLLM proxy server on a version before the fix. The vulnerable endpoint is part of the proxy's HTTP API.
- Required to exploit: a proxy-admin credential (the master key, in default configurations). Risk is highest where the master key is shared widely — for example, embedded in internal tools or handed to many developers — or where the admin API is reachable from the internet.
- Bundled products: some vendors ship LiteLLM inside their products. Red Hat, for example, has released fixes for Red Hat OpenShift AI 3.3 and an Ansible Automation Platform 2.6 component. Check with the vendor of any AI platform you run.

Affected and fixed versions
- NVD: "LiteLLM through 2026-04-08" (no version numbers yet; the record is still under analysis).
- LiteLLM advisory (GHSA): lists versions before 1.83.10 as affected and 1.83.10 as patched, but its text says "Fixed in 1.83.11 … Upgrade to 1.83.11 or later".
- Our recommendation: upgrade to 1.83.11 or later, which satisfies both statements. Version 1.83.11 is available on PyPI.
The fix
LiteLLM replaced the home-made sandbox with RestrictedPython. Upgrade the litellm package, or pull a current proxy image and redeploy.
If you cannot upgrade right away, both LiteLLM and X41 recommend blocking requests to /guardrails/test_custom_code at your reverse proxy or API gateway (nginx, Caddy, an AWS ALB rule and so on). X41 also advises keeping the master key with trusted administrators only and not exposing the admin interface to untrusted networks.
What to do now
- Find every LiteLLM proxy. Check servers, Docker Compose files, Kubernetes deployments and AI platforms that may bundle it. Note the version of each.
- Upgrade to 1.83.11 or later and restart the proxy. For containers, pull a current image and redeploy; images pinned to an old tag or digest stay vulnerable.
- Block the endpoint
/guardrails/test_custom_codeat the reverse proxy until the upgrade is confirmed. Blocking it afterwards does no harm if you don't use the feature. - Restrict the admin API. Allow it only from trusted networks (VPN, security groups), and avoid sharing the master key with applications or regular users.
- Rotate secrets if an outdated proxy was reachable by people beyond your trusted admins: the master key and the LLM provider API keys stored in the proxy.
- Run as non-root. The default image runs as root; running the container as an unprivileged user limits the damage of any future flaw.
- Review logs for past calls to
/guardrails/test_custom_codeand for unexpected processes started by the proxy.
Conclusion
CVE-2026-40217 is a reminder that AI infrastructure is now part of the attack surface. An LLM gateway holds the keys to every model a company uses, and it often sits next to internal data. The fix has been available since April; the risk lies in proxies that were set up once and never updated. Building an AI system is only half of the work — it also has to be operated: inventoried, patched and monitored.
Haposoft helps companies design and run AI integrations securely, from AI transformation consulting to AWS/GCP cloud operations. If you need help checking or updating your LiteLLM deployment, contact us or email contact@haposoft.com.
