External risk intelligence

LiteLLM Arbitrary Code Execution via Bytecode Rewriting

CVE advisoryKnown Exploit

CVE-2026-40217

LiteLLM is a proxy server designed to act as an interface for LLM APIs. In typical deployments, it serves as an intermediary API gateway, meaning its endpoints are frequently exposed to the network to facilitate communication between client applications and large language models. The presence of a vulnerable URI in an edge-facing service makes internet-reachable exploitation a likely scenario in many configurations.

Code Injection

Litellm

2026-04-08 and earlier

Halo Surface Signal: 4 out of 5 — likely to be public-facing.

External exposure likelihood

Horizon Alert

Summary of the vulnerability and why it matters

A vulnerability exists in LiteLLM that could allow unauthorized remote code execution through bytecode rewriting. This could impact systems using this technology to interface with AI models. The primary concern is to confirm if our environment is affected and to what extent.

  • Code can be rewritten remotely for execution.
  • Essential to confirm if LiteLLM is used.
  • Understand exposure and confirm relevance.

Attack Path

How an attacker could exploit the issue

An attacker with limited access could target the LiteLLM application's `/guardrails/test_custom_code` endpoint. By sending specially crafted input that exploits a bytecode rewriting vulnerability, the attacker could achieve arbitrary code execution on the server. This could allow them to compromise the application and potentially gain further control over the system.

  • Requires authenticated access.
  • Triggered by sending malicious input to a specific URI.
  • Enables arbitrary code execution.

Live Threat

Current exploitation, exposure, and threat context

This vulnerability could allow remote attackers to execute arbitrary code when interacting with the `/guardrails/test_custom_code` URI.

  • System code execution.
  • Via unprotected code rewriting.
  • Unauthorized system access or control.

Operational Fix

Recommended remediation, mitigation, and detection steps

The LiteLLM team likely owns this issue, as it involves their product's functionality and potential exposure. The first practical step is to identify all instances of LiteLLM within your environment, determine their network reachability and business criticality, and then confirm the accountable owner for each instance to plan remediation.

  • LiteLLM team should own the issue.
  • Verify instance exposure and business criticality.
  • Plan remediation based on assessed risk.

Supplementary metadata

Validate whether this threat affects your internet-facing exposure.

Halo Threat Intelligence helps prioritize remediation with Halo Surface Signal and H/A/L/O context. Start exposure validation with a free external attack surface trial.

Frequently asked questions

What is LiteLLM and why is it used?

LiteLLM is a proxy server that acts as a unified interface for connecting applications to various large language models (LLMs). It simplifies the integration process by providing a single, standardized API that allows developers to swap between different AI models without rewriting their core application code. This makes it a central gateway for routing and managing AI-related traffic in a technical stack.

What does CVE-2026-40217 mean for LiteLLM?

This vulnerability involves improper code generation or control, specifically classified under CWE-94 (Code Injection) and CWE-420. In plain terms, it means the application fails to properly validate data sent to a specific part of the system, allowing an attacker to inject and execute their own unauthorized code on the server hosting LiteLLM.

How is the CVE-2026-40217 vulnerability triggered?

The flaw is triggered when someone sends specifically crafted input to the /guardrails/test_custom_code endpoint. It is important to note that this requires the attacker to have at least limited access to reach that specific URI. Simply using the standard proxy features of LiteLLM for normal model queries without interacting with this diagnostic endpoint does not trigger this specific issue.

Is my LiteLLM instance relevant to this threat?

According to Halo Surface Signal, LiteLLM is typically deployed as an API gateway, which often makes its endpoints internet-facing to handle incoming requests. If your instance is reachable from the network—especially the internet—it is at a higher risk, as attackers can reach the vulnerable URI directly. Internal-only instances are generally safer but still warrant review.

What is the first step to address this CVE?

Your immediate priority is to locate every instance of LiteLLM running in your environment. Once identified, evaluate whether those instances are accessible from the network. Coordinate with your technical teams to confirm the ownership of these assets and review vendor guidance to plan the necessary updates or configuration changes to secure the affected endpoints.

References