BerriAI LiteLLM Guardrail Sandbox Escape RCE
What is the Vulnerability? CVE-2026-40217 is a critical arbitrary-code-execution vulnerability in BerriAI LiteLLM, a widely used open-source LLM proxy/gateway. LiteLLM’s guardrail feature includes a “test custom code” facility that runs user-supplied guardrail code in a sandbox. The sandbox can be escaped by rewriting Python bytecode, allowing an attacker to break out and execute arbitrary code…
| What is the Vulnerability? |
CVE-2026-40217 is a critical arbitrary-code-execution vulnerability in BerriAI LiteLLM, a widely used open-source LLM proxy/gateway. LiteLLM’s guardrail feature includes a “test custom code” facility that runs user-supplied guardrail code in a sandbox. The sandbox can be escaped by rewriting Python bytecode, allowing an attacker to break out and execute arbitrary code in the context of the LiteLLM process (reported running as root in some deployments). The vector is a request to POST /guardrails/test_custom_code. CVSS is 8.8- the attacker needs minimal low-privilege access, for example a valid API key or low-tier account, so this is not a fully unauthenticated RCE, though that privilege is common in multi-tenant AI gateways. LiteLLM sits at a privileged chokepoint in AI stacks: it brokers model access and stores provider API keys, so code execution there yields those keys and a foothold into the surrounding environment. Although disclosed on 2026-04-10, the flaw was added to CISA’s Known Exploited Vulnerabilities catalog only on 2026-11-18 (remediation due 2026-12-02), after Zenity Labs observed threat actors abusing the guardrail tester to run code as root. A public proof-of-concept and a Nuclei template exist, and EPSS sits around the 99th percentile. LiteLLM also ships bundled inside Red Hat Ansible Automation Platform 2.6, OpenShift AI 3.3 and Lightspeed Core, so organizations may be exposed without having deployed LiteLLM directly. |
| What is the recommended Mitigation? |
• Patch on an emergency basis. Upgrade LiteLLM to the fixed release — confirm the exact fixed version against the vendor / Snyk / Red Hat advisory, as sources list different cut-offs. For bundled products, apply the Red Hat errata RHSA-2026:24866 and RHSA-2026:30056 (Ansible Automation Platform 2.6, OpenShift AI 3.3, Lightspeed Core), and inventory any other product that embeds LiteLLM. |
| What FortiGuard Coverage is available? |
• FortiGuard Labs is actively monitoring this threat activity and will continue to provide updates, including new intelligence, indicators and protection guidance. |
