Skip to content

Hide Navigation Hide TOC

LiteLLM Custom-Code Guardrail Sandbox Escape (CVE-2026-40217) - ATR-2026-01935 (e41645e9-6f53-5e5c-9010-7595d5236ca6)

Detects CVE-2026-40217 (CWE-94/CWE-265): LiteLLM's custom-code guardrail test/compile path /guardrails/test_custom_code evaluates caller-supplied Python in an unsafe sandbox that can be escaped via bytecode rewriting and dunder-attribute traversal, yielding server-side code execution as the LiteLLM proxy process. Affected through 2026-04-08 builds. Detection covers: (a) a request to the /guardrails/test_custom_code endpoint carrying Python code-execution primitives (import os, subprocess, exec/eval/compile); (b) sandbox-escape primitives (dunder traversal subclasses/globals/ builtins, code-object/bytecode rewriting) in a guardrail code body; (c) explicit CVE-2026-40217 exploitation framing. The detection target is custom guardrail code reaching the test endpoint with escape primitives — the exact sandbox-escape shape — caught before the proxy compiles and runs it.

Cluster A Galaxy A Cluster B Galaxy B Level
Exploit Public-Facing Application (47d73872-5336-44f7-81e3-d30bc7e039dd) MITRE ATLAS Attack Pattern LiteLLM Custom-Code Guardrail Sandbox Escape (CVE-2026-40217) - ATR-2026-01935 (e41645e9-6f53-5e5c-9010-7595d5236ca6) Agent Threat Rules 1
LiteLLM Custom-Code Guardrail Sandbox Escape (CVE-2026-40217) - ATR-2026-01935 (e41645e9-6f53-5e5c-9010-7595d5236ca6) Agent Threat Rules Python - T1059.006 (cc3502b5-30cc-4473-ad48-42d51a6ef6d1) Attack Pattern 1
Command and Scripting Interpreter - T1059 (7385dfaf-6886-4229-9ecd-6fd678040830) Attack Pattern Python - T1059.006 (cc3502b5-30cc-4473-ad48-42d51a6ef6d1) Attack Pattern 2