the safety feature ran your Python in a homemade sandbox. CISA says people are using it. hunt LiteLLM CVE-2026-40217
LiteLLM, the open-source proxy a lot of teams put in front of every model they pay for, had an endpoint for testing custom guardrails. guardrails are the safety feature. the test endpoint took user-supplied Python and ran it inside a hand-rolled sandbox that filtered dangerous words with regex. researchers walked out of it. CISA added CVE-2026-40217 to KEV on November 18, so it is now exploited in the wild, months after the fix. this guide finds the vulnerable proxies, hunts the one endpoint that matters, and closes it. it also explains why the “you need an admin key” caveat is doing less work than it sounds like.
POST /guardrails/test_custom_code “runs user-supplied Python inside a hand-rolled sandbox” that “can be escaped using bytecode-level techniques, allowing 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.” affected range (GHSA and NVD CPE): >= 1.81.8, < 1.83.10. the GHSA text says “Fixed in 1.83.11.” we recommend 1.83.11 or later so both readings are satisfied. workaround: block POST /guardrails/test_custom_code at your reverse proxy or gateway. CISA KEV: added 2026-11-18, due 2026-12-02, forensic triage No, ransomware use Unknown.three scores walk into a CVE
the severity depends on who you ask, and the disagreement is the whole story:
- MITRE, in NVD as a Secondary metric: CVSS 3.1 8.8,
AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H. low privileges required. - X41 D-Sec, the researchers (advisory X41-2026-001, Markus Vervier): CVSS 4.0 8.7,
PR:L, “Authenticated HTTP API request,” root in the default Docker image. - BerriAI’s GitHub advisory: CVSS 4.0 5.9, severity medium,
AC:H/PR:H. high privileges required, because the endpoint wants a proxy-admin credential by default.
all three agree it is code execution and that you need to be authenticated. they disagree about how hard the credential is to come by. CISA’s KEV listing settles the practical question: somebody has been getting it. we do not know how. CISA did not say, and neither did BerriAI. plausible routes include leaked or default-looking master keys, keys sitting in CI variables and notebooks, and admin keys passed around a team chat because the proxy was “internal.” those are our guesses, not findings. the fix is the same either way.
the condition, stated carefully
- you run the LiteLLM proxy (the server), in the affected range, with the
/guardrails/test_custom_coderoute reachable. if you only import thelitellmPython SDK as a client library and never run the proxy server, this specific endpoint is not something you are exposing. check anyway, because “we only use the SDK” is often true for one team and false for the platform team. - the requester has a credential the endpoint accepts. in default configs, per GHSA, that is proxy-admin.
- impact: code runs as the proxy process user. root in the default Docker image, per both GHSA and X41.
and remember what this box is. an LLM proxy holds the API keys for every upstream provider you pay for, often a database URL with spend logs and virtual keys, and a lot of your users’ prompts in flight. code execution on the gateway is a key ring, not a single key.
the dates, because KEV lag is a feature now
- 2026-04-08: the NVD text says LiteLLM “through 2026-04-08” is affected. X41’s advisory confirms
main-latestat a specific image digest. - 2026-04-10: NVD publishes CVE-2026-40217.
- 2026-05-07 (UTC): BerriAI publishes GHSA-wxxx-gvqv-xp7p, sandbox replaced with RestrictedPython, last updated 2026-06-30.
- 2026-11-18: CISA adds it to KEV, due 2026-12-02.
seven months between fix and confirmed exploitation. that is the AI tooling patch cadence in one line: the project moves fast, the deployments do not. NVD also lists Red Hat products that ship LiteLLM (Ansible Automation Platform before 2.6-9, OpenShift AI 3.3 before 3.3.4, and OpenShift Lightspeed), with Red Hat errata RHSA-2026:24866 and RHSA-2026:30056. if you run those, follow Red Hat’s errata rather than pip versions.
step 1: find every proxy and pin it
sources of truth, in order of honesty: running container image tags and digests, pip show litellm inside the proxy environment, your Helm values, then your wiki. build a CSV of host,source,version. the kit flags >= 1.81.8, < 1.83.10 as VULN, 1.83.10 as WARN (fixed per the GHSA range, short of the 1.83.11 in the GHSA text), 1.83.11 and later as OK, and anything on a floating tag like main-latest as unknown until you pin it. X41’s confirmed-affected build was literally main-latest. floating tags are how you end up affected without ever deciding to be.

step 2: hunt the endpoint and the credentials
every abuse of this bug goes through one path. pull the access logs from whatever sits in front of the proxy (nginx, your ingress controller, your cloud load balancer) and list every request to /guardrails/test_custom_code. a 2xx POST that you cannot tie to a named admin, on a named day, testing a named guardrail, is an incident. a run of 401s followed by a 200 from the same address is a credential being found.
then look at the credentials themselves. if LITELLM_MASTER_KEY is a sample value from a quickstart, rotate it now. if the container runs as UID 0, every future escape lands as root too.

on a proxy you suspect: preserve the container (do not just redeploy over it), list processes and outbound connections from the proxy, check for new files in the image’s writable paths, and diff the proxy’s database for new virtual keys, new users, or changed model routes. then rotate every upstream provider key the proxy held, plus the master key, plus the database password. CISA set forensic triage to No for this one. that is a federal paperwork setting, not a statement about your gateway.
step 3: block it, then upgrade, then stop running as root
the GHSA workaround is a single proxy rule: block POST /guardrails/test_custom_code. the kit prints an nginx location block, a Traefik router that only lets localhost reach the path, and a compose snippet that drops root, drops capabilities, and sets a read-only filesystem. none of it is applied for you.

then upgrade to 1.83.11 or later, where per GHSA the hand-rolled sandbox “has been replaced with RestrictedPython.” test that your guardrails still load. keep the proxy block if nobody on your team actually uses the custom-code test endpoint. most teams will discover they never did.
red team notes, without the red team payload
if you are assessing an AI platform, this bug is a perfect example of a finding you can prove without exploitation: the version, the route being reachable, the credential being weak or widely shared, and the container running as root. four facts, one screenshot each, zero shells on a client’s production gateway. while you are there, check who holds the master key. the answer is usually some version of “the platform team, two former interns, and a notebook.”
the industry part, since we have to
the AI security market spent a year selling guardrails as the answer to everything. this bug is a guardrail feature that executed arbitrary Python, protected by a regex. a regex. the oldest joke in application security, deployed in front of the newest infrastructure, on the box that holds every API key the company has. RestrictedPython is a real improvement. “do not run user code on the key ring” would have been a bigger one.
and the KEV lag matters. the fix existed in May. the exploitation listing came in November. this is not a zero-day story. it is a “nobody owns the AI gateway” story, which is the more common and more boring way to get breached.
download the Kali defensive kit
litellm-cve-2026-40217-defensive-kit.zip contains litellm-40217-check.py (version, access and env modes), litellm-40217-block.sh (prints nginx, Traefik and compose hardening, applies nothing), a README with all three scores, and the synthetic lab files from the screenshots. fixed version 1.83.11 and the GHSA range are baked in. no network connections, no exploit or bypass code. lab-only, defensive use.
sources
- BerriAI, GHSA-wxxx-gvqv-xp7p: Sandbox escape in custom-code guardrail (published 2026-05-07 UTC, updated 2026-06-30; CVSS 4.0 5.9)
- X41 D-Sec, X41-2026-001: Guardrail Sandbox Escape in LiteLLM (CVSS 4.0 8.7)
- NVD, CVE-2026-40217 (published 2026-04-10; CVSS 3.1 8.8 from MITRE, Secondary; Red Hat CPEs and errata)
- CISA, KEV entry for CVE-2026-40217 (added 2026-11-18, due 2026-12-02)
- Red Hat, CVE-2026-40217
