PyPI: litellm
CVE-2026-40217
Safety vulnerability ID: SFTY-20260511-02826
Safety legacy ID: pyup.io-96900
Affected versions of the litellm package are vulnerable to Sandbox Escape due to an insufficient hand-rolled sandbox in the custom-code guardrail testing endpoint. The POST /guardrails/test_custom_code endpoint executes user-supplied Python code within a custom sandbox that can be bypassed using bytecode-level techniques, allowing arbitrary code execution in the proxy process. An attacker with proxy-admin credentials can escape the sandbox to achieve arbitrary code execution, which runs as root in the default Docker image.
Overview
LiteLLM has a sandbox escape in custom-code guardrail
Advisory
Affected versions of the litellm package are vulnerable to Sandbox Escape due to an insufficient hand-rolled sandbox in the custom-code guardrail testing endpoint. The POST /guardrails/test_custom_code endpoint executes user-supplied Python code within a custom sandbox that can be bypassed using bytecode-level techniques, allowing arbitrary code execution in the proxy process. An attacker with proxy-admin credentials can escape the sandbox to achieve arbitrary code execution, which runs as root in the default Docker image.
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20260511-02826/CVE-2026-40217
- https://data.safetycli.com/changelogs/litellm/
- https://github.com/advisories/GHSA-wxxx-gvqv-xp7p
- https://pypi.org/project/litellm
- https://github.com/BerriAI/litellm/security/advisories/GHSA-wxxx-gvqv-xp7p
- https://nvd.nist.gov/vuln/detail/CVE-2026-40217
- https://github.com/BerriAI/litellm/releases/tag/v1.83.10-stable
- https://www.x41-dsec.de/lab/advisories/x41-2026-001-litellm
- https://github.com/advisories/GHSA-wxxx-gvqv-xp7p
Verified by Safety
Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.
Learn more
