CVE-2026-40217 is a remote code execution vulnerability in LiteLLM’s Custom Code Guardrail testing functionality, specifically the /guardrails/test_custom_code endpoint. Affected versions are LiteLLM 1.81.8 through 1.83.9 (fixed in 1.83.10; the CVE record describes LiteLLM through 2026-04-08 as affected). The endpoint accepts user-supplied Python intended for guardrail testing. In vulnerable builds, this code is executed in an unsafe sandbox based on exec()/eval() and a deny-list of forbidden strings. Attackers can bypass the deny-list by reconstructing blocked identifiers at runtime and abusing Python introspection primitives such as generator/coroutine internals, including gi_code and cr_frame, to regain access to builtins and import functionality. Supporting reporting also notes bytecode-rewriting-based bypasses on the playground endpoint. Once the sandbox is escaped, arbitrary Python code executes in the LiteLLM process context, enabling actions such as reading environment variables or spawning subprocesses.
Mallory correlates every CVE against your assets, your vendors, and active adversary campaigns. Know which vulnerabilities matter for you, not just which ones are loud.
What it means. What to do now. Patch path, mitigations, and the assume-compromise checklist.
What an attacker gets, and what they’ve been doing with it.
If you can’t patch tonight, do this now.
Patch, then assume compromise.
2 valid exploits after Mallory filtered fakes, detection scripts, and README-only repos.
This 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.
This 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.
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
Vendor-confirmed product mapping. Mallory continuously reconciles this list against your asset inventory.
10 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.
A LiteLLM custom-code guardrail sandbox escape vulnerability caused by unsafe eval usage and a weak text deny-list, allowing attackers to bypass the sandbox, achieve code execution, and exfiltrate environment variables.
A specific LiteLLM vulnerability that the content says was targeted in exploitation attempts shortly after publication and was under active exploitation in the wild.
A sandbox escape in LiteLLM Custom Code Guardrail that allows server-side code execution via unsafe Python exec() handling and related bypass techniques.
A high-severity arbitrary code execution vulnerability affecting LiteLLM that can give an authenticated attacker full control over the LiteLLM process and, in the default Docker deployment, root privileges within the container.
Query your assets running an affected version, and investigate the blast radius.
Every observed campaign linking this CVE to a named adversary.
Malware families riding this exploit, with evidence and IOCs.
YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Cross-references every affected SKU, including bundled OEM variants.
Community discussion across Reddit, Mastodon, and other social sources.