CVE-2026-40217
Received Received - Intake
Remote Code Execution via Bytecode Rewriting in LiteLLM

Publication date: 2026-04-10

Last updated on: 2026-04-27

Assigner: MITRE

Description
LiteLLM through 2026-04-08 allows remote attackers to execute arbitrary code via bytecode rewriting at the /guardrails/test_custom_code URI.
CVSS Scores
EPSS Scores
Probability:
Percentile:
Meta Information
Published
2026-04-10
Last Modified
2026-04-27
Generated
2026-05-07
AI Q&A
2026-04-10
EPSS Evaluated
2026-05-05
NVD
EUVD
Affected Vendors & Products
Showing 1 associated CPE
Vendor Product Version / Range
litellm litellm to 2026-04-08 (inc)
Helpful Resources
Exploitability
CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-420 The product protects a primary channel, but it does not use the same level of protection for an alternate channel.
Attack-Flow Graph
AI Powered Q&A
Can you explain this vulnerability to me?

CVE-2026-40217 is a high-severity vulnerability in LiteLLM, an open-source large language model proxy. It allows authenticated remote attackers to execute arbitrary code on the server by bypassing the sandbox protections at the /guardrails/test_custom_code API endpoint.

The vulnerability arises because the endpoint uses regex-based filtering to block dangerous Python attributes like __globals__, __builtins__, and __import__, but this filtering only scans source code literals and can be bypassed by dynamically constructing these attribute names through string concatenation.

Attackers exploit this by rewriting Python bytecode at runtime, replacing code objects to access restricted functions and ultimately execute arbitrary shell commands with root privileges, as the LiteLLM process runs as root by default in its Docker image.


How can this vulnerability impact me? :

This vulnerability allows an authenticated attacker to execute arbitrary commands on the server hosting LiteLLM with root privileges.

  • Complete system compromise due to root-level code execution.
  • Potential unauthorized access to sensitive data and system resources.
  • Ability to run arbitrary shell commands, which can lead to data theft, service disruption, or further network penetration.
  • If the LiteLLM management interface is exposed to untrusted networks, the risk of exploitation increases.

How can this vulnerability be detected on my network or system? Can you suggest some commands?

Detection of this vulnerability involves identifying if your LiteLLM instance is running a vulnerable version and if the /guardrails/test_custom_code endpoint is accessible and being used.

You can check for the presence of the vulnerable LiteLLM Docker image by running the following command to list running containers and their images:

  • docker ps --format '{{.ID}}: {{.Image}}'

To test if the vulnerable endpoint is accessible, you can send an authenticated HTTP POST request to /guardrails/test_custom_code and observe the response. For example, using curl (replace <token> with a valid authentication token):

  • curl -X POST https://<liteLLM-host>/guardrails/test_custom_code -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' -d '{"custom_code":"def f(): return 1","test_input":""}'

If the endpoint responds and executes the code, it indicates the vulnerable interface is exposed.

Monitoring network traffic for POST requests to /guardrails/test_custom_code can also help detect exploitation attempts.


What immediate steps should I take to mitigate this vulnerability?

Immediate mitigation steps include restricting access and reducing the attack surface since no official patch is available yet.

  • Block access to the /guardrails/test_custom_code endpoint at the reverse proxy level (e.g., using nginx or Caddy) to prevent any requests reaching the vulnerable API.
  • Restrict master key and authentication token access to trusted administrators only to limit who can authenticate and use the vulnerable endpoint.
  • Do not expose the LiteLLM management interface to untrusted networks; use network-level controls such as firewalls or VPNs.
  • Avoid running LiteLLM as root. Run the Docker container as an unprivileged user by using Docker’s --user option to limit the impact of a potential compromise.

How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:

The vulnerability CVE-2026-40217 allows remote authenticated attackers to execute arbitrary code with root privileges on the LiteLLM server. This can lead to unauthorized access, modification, or exfiltration of sensitive data processed or stored by the system.

Such unauthorized access and control can result in violations of common compliance standards and regulations like GDPR and HIPAA, which mandate strict controls over data confidentiality, integrity, and access.

Specifically, the ability to execute arbitrary code as root could enable attackers to bypass security controls, access personal or protected health information, and compromise system integrity, thereby undermining compliance requirements.

Mitigations such as restricting access to the vulnerable endpoint, running the service with least privilege, and network-level protections are critical to reduce the risk of non-compliance due to this vulnerability.


Ask Our AI Assistant
Need more information? Ask your question to get an AI reply (Powered by our expertise)
0/70
EPSS Chart