Skip to main content
Mallory
HighExploited in the wildCISA KEVPublic exploitVulnerability

CVE-2026-40217: Python Sandbox Escape in BerriAI LiteLLM Custom Guardrail Testing

Published Apr 10, 2026 · Updated 1 day ago
Trending this weekNot trendingOutside this week’s top 100
Mention activity · 30 days82 mentions · peak 27 in a dayToday
CVSS8.8High · v3.1
EPSS20.6%98th percentile
CISA KEVYesAdded Nov 18, 2026
In the wildActivePer CISA KEV
Vendors
Red HatLitellm
IdentifiersCVE-2026-40217CWE-420 · Unprotected Alternate Channel

CVE-2026-40217 is an unprotected alternate channel vulnerability in BerriAI LiteLLM's custom guardrail testing functionality. Attacker-supplied Python code can manipulate or rewrite bytecode to bypass the custom sandbox's validation and execute arbitrary code within the LiteLLM proxy process. The vulnerable functionality requires proxy-administrator credentials in default configurations; separate authorization weaknesses or insecure configurations can make it accessible to lower-privileged callers. Exploitation is confirmed in the wild, including in LLMjacking activity.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Analyst brief

Impact, mitigation & remediation

What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.

Impact

What an attacker gets, and what they’ve been doing with it.

Successful exploitation compromises the confidentiality, integrity, and availability of resources accessible to the LiteLLM process. Execution can occur as root inside the default Docker container, but does not inherently establish escape to the container host. Attackers can potentially obtain provider API keys, proxy administrative credentials, database credentials, and other accessible secrets; alter gateway behavior; disrupt service; and abuse connected model services at the victim's expense. Stolen credentials can enable persistence and further access to connected infrastructure.

Mitigation

If you can’t patch tonight, do this now.

Until patching is complete, disable the custom-code guardrail tester or block access to POST /guardrails/test_custom_code at the reverse proxy, API gateway, or ingress layer. Restrict administrative and guardrail APIs to trusted networks and authorized administrators, and review which keys can access them. Investigate unexpected tester requests, child-process execution, outbound connections, administrative changes, and abnormal model usage or billing. Access restrictions do not remove an existing compromise.

Remediation

Patch, then assume compromise.

Upgrade to the latest supported, vendor-confirmed fixed LiteLLM release. Maintainer guidance identifies 1.83.11 or later as fixing this vulnerability, while some accounts identify 1.83.10 as the initial fix; verify the applicable advisory rather than relying on the earlier cutoff. The remediation replaces the custom sandbox with RestrictedPython. Address related authorization and credential-exposure vulnerabilities separately, since fixing this sandbox escape alone does not resolve the broader attack chain. Apply product-specific updates for bundled LiteLLM deployments. For potentially compromised instances, investigate before returning them to service and rotate LiteLLM master keys, upstream provider keys, database credentials, and other exposed secrets.

Public exploits

Exploits

3 exploits validated by Mallory's analysis.

View more in app →
CVE-2026-40217-PoCThis repository is a standalone Python proof-of-concept exploit for CVE-2026-40217, a LiteLLM guardrail sandbox escape that leads to authenticated remote code execution. The repo contains 10 files: a top-level README with exploitation steps and vulnerability background, docker-compose.yml for spinning up a pinned vulnerable LiteLLM container plus an optional fixed comparison container, exploit/exploit.py as the main operator-facing script, exploit/payload.py as the payload generator, requirements.txt listing requests, an advisory translation under docs/, and screenshot/text artifacts demonstrating successful exploitation. The main exploit flow is in exploit/exploit.py. It accepts a target base URL, LiteLLM Bearer API/master key, arbitrary shell command, optional proxy, timeout, and SSL verification toggle. It builds the URL {target}/guardrails/test_custom_code, generates a malicious JSON body via generate_full_payload(), and POSTs it with requests. On success it parses JSON and prints the returned command output from result.rce. It also includes an interactive_shell() loop that repeatedly sends attacker-entered commands, effectively providing a simple remote command shell over the vulnerable API. The actual sandbox-escape logic is in exploit/payload.py. That module generates Python source for the custom_code field expected by LiteLLM's guardrail testing endpoint. The payload defines apply_guardrail(inputs, request_data, input_type), then bypasses regex filtering by constructing blocked identifiers through string concatenation, obtains object via str.mro()[1], accesses a generator code object through gi_code, rewrites the function bytecode name table using object.__setattr__ and code.replace(), recovers __builtins__/__import__ from http_get globals, imports os, and executes an attacker-controlled shell command with os.popen(...).read(). The command output is returned as {'rce': ...}, which the exploit script surfaces to the operator. Capabilities are therefore strong and clearly offensive: authenticated exploitation of a network-exposed web API, arbitrary command execution, reading sensitive files, and interactive command execution. The exploit does not include persistence, lateral movement, or post-exploitation automation beyond command execution, so it is best classified as OPERATIONAL rather than weaponized. The repository is not a framework module and is not merely a detector; it is a functioning exploit with a reusable payload generator and a reproducible vulnerable lab environment.learner202649 · Disclosed May 19, 2026 · python · yaml · web · networkOperationalCVE-LiteLLMThis repository contains two related Python exploit implementations for CVE-2026-40217, a LiteLLM authenticated RCE via the POST /guardrails/test_custom_code endpoint. The repo is not part of a major exploit framework. Structure-wise, the top level includes a generic README, license, a main PoC script at CVE-2026-40217/cve-2026-40217.py, dependency files, and a targets list. It also embeds a more complete nested PoC project under CVE-2026-40217/CVE-2026-40217-PoC-learner202649/ with its own README, docker-compose lab, advisory notes, exploit module, payload generator, and screenshot artifacts. The nested exploit/exploit.py is the more technically coherent exploit. It uses requests to authenticate with a Bearer token and POST JSON to the vulnerable endpoint. Its companion exploit/payload.py generates a malicious custom_code function that bypasses LiteLLM's regex-based sandbox by constructing blocked identifiers indirectly, rewriting a generator code object's co_names via object.__setattr__ and code.replace(), recovering __globals__/__builtins__/__import__, and finally invoking os.popen(command).read(). This returns command output in the JSON response under result.rce. It also supports an interactive shell loop, proxying through an intercepting proxy, configurable timeout, and optional SSL verification disablement. The top-level cve-2026-40217.py is a more aggressive operational PoC. It supports single-target or file-based multi-target exploitation with threading, command obfuscation modes, optional reverse-shell command generation, and colored console output. However, its payload format differs from the nested PoC and appears less aligned with the documented vulnerable API schema; it may be less reliable than the nested exploit. Still, its intended capability is clear: submit malicious custom guardrail code to achieve command execution, including a bash reverse shell using /dev/tcp/<lhost>/<lport>. The docker-compose file provides a reproducible lab by exposing a pinned vulnerable LiteLLM image on port 4000 with a known master key and a patched comparison instance on port 4001. Overall, this is a real exploit repository focused on authenticated web/API exploitation of LiteLLM's custom guardrail testing feature to obtain arbitrary command execution, often as root in the default containerized deployment.HORKimhab · Disclosed Jun 16, 2026 · python · yaml · web · networkOperationalCVE-2026-40217The supplied repository contains README.md and one standalone Python entry point, poc.py. The README describes a claimed LiteLLM guardrail sandbox vulnerability, affected versions, remediation, detection ideas, and command/reverse-shell examples. The script uses requests to probe availability, attempt version discovery, and submit Python code to /guardrails/test_custom_code. It supports an optional Bearer master key, custom command, timeout, port, and HTTP proxy; TLS certificate verification is disabled. No exploit framework, automatic exfiltration, persistence implementation, or fixed attacker-controlled callback is present. The primary payload is a plausible Python introspection escape that locates os._wrap_close and retrieves system from its initializer globals. Whether it bypasses the actual target sandbox is not demonstrated. The advertised bytecode-rewriting fallback is ineffective as an RCE payload: it reconstructs an empty function without introducing command execution. The command is interpolated into a single-quoted Python literal without escaping, so commands containing single quotes can break the payload, including the README's reverse-shell example. Detection is unreliable: any HTTP 200 response is reported as successful exploitation without validating execution, and the no-op fallback can therefore produce false positives. Contrary to the README's 'detection only' description, the default invocation submits a command-execution attempt using id. os.system does not itself capture command output into the HTTP response. Root access would depend on the server process identity and is not established by this code. The supplied files do not independently verify the CVE assignment, CVSS score, KEV/EPSS assertions, affected versions, or claimed 1.83.11 fix. No original repository URL, Git reference, or archive size was provided; empty strings and zero represent unavailable metadata.cveForge · Disclosed Nov 24, 2026 · python · webOperational
Exposure surface

Affected products & vendors

Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.

VendorProductType
LitellmLitellmapplication
Red HatAnsible Automation Platformapplication
Red HatOpenshift Aiapplication
Red HatOpenshift Lightspeedapplication
FAQ

Frequently asked questions

Is CVE-2026-40217 exploited in the wild?
Yes. As of Nov 27, 2026, Mallory has reports of exploitation in the wild, and CISA added it to KEV on Nov 18, 2026.
Is there a public exploit for CVE-2026-40217?
Yes. Mallory tracks 3 public exploits or proofs of concept for CVE-2026-40217, the earliest disclosed May 19, 2026.
Is there a patch for CVE-2026-40217?
Upgrade to the latest supported, vendor-confirmed fixed LiteLLM release. Maintainer guidance identifies 1.83.11 or later as fixing this vulnerability, while some accounts identify 1.83.10 as the initial fix; verify the applicable advisory rather than relying on the earlier cutoff.
What products are affected by CVE-2026-40217?
Litellm, Red Hat Ansible Automation Platform, Red Hat Openshift Ai, and Red Hat Openshift Lightspeed.
How severe is CVE-2026-40217?
CVE-2026-40217 has a CVSS v3.1 score of 8.8 (High) and an EPSS score of 20.6% (98th percentile) as of Nov 27, 2026.
Activity feed

Recent activity

103 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.

View more in app →
fortinet threat signalNews · Nov 24, 2026Threat Signal Report | FortiGuard LabsA sandbox escape in LiteLLM's guardrail custom-code tester allows a low-privileged attacker to rewrite Python bytecode and execute arbitrary code through POST /guardrails/test_custom_code. Execution occurs with the LiteLLM process's privileges, potentially root, exposing stored provider API keys and enabling further compromise. The report assigns a CVSS score of 8.8 and states that exploitation has been observed and the vulnerability was added to CISA's Known Exploited Vulnerabilities catalog on November 18, 2026. A public proof of concept and Nuclei template are available. Upgrade LiteLLM after verifying the fixed version against vendor advisories, or apply the relevant Red Hat errata for bundled deployments. Interim mitigations include disabling or restricting the test endpoint and limiting guardrail API access.Read more ↗cyberveilleNews · Nov 21, 2026CVE-2026-40217 : Sandbox escape dans LiteLLM ajoutée au catalogue KEV de la CISA | CyberVeilleA sandbox escape in LiteLLM's POST /guardrails/test_custom_code endpoint allows attackers with proxy-admin credentials and network access to execute arbitrary Python code in the proxy process, which runs as root in the default Docker image. The article identifies affected versions as 1.81.8 through versions before 1.83.10, lists fixes in 1.83.10/1.83.11, and recommends upgrading to at least 1.84.0. It reports active exploitation, functional sandbox-escape payloads observed by honeypots, a public proof of concept, and addition to CISA KEV on November 18, 2026.Read more ↗scworldNews · Nov 20, 2026CISA adds four critical vulnerabilities to known exploited catalog | brief | SC MediaA vulnerability in BerriAI LiteLLM actively exploited for LLMjacking, enabling unauthorized access to large language models across global sectors. Added to CISA's Known Exploited Vulnerabilities catalog.Read more ↗risky biz rssNews · Nov 20, 2026New Windows security feature will allow apps to refuse to run on insecure systemsAn unprotected alternate channel vulnerability in BerriAI LiteLLM. The content identifies it as actively exploited and newly added to CISA's Known Exploited Vulnerabilities catalog.Read more ↗
+31 more in the timeline. Sign up to see them
Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Mallory platform

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, and which detections to deploy tonight.
Exposure mappingQuery your assets running an affected version, and investigate the blast radius.
Threat actor evidenceEvery report linking this CVE to a named adversary.
Associated malwareMalware families linked to this CVE, with evidence and IOCs.
Detection signatures1YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activity61Community discussion across Reddit, Mastodon, and other social sources.