LiteLLM — Critical bytecode rewriting RCE (CVE-2026-40217)

LiteLLM — Critical bytecode rewriting RCE (CVE-2026-40217)

AI relevance: This RCE vulnerability in LiteLLM's guardrail testing endpoint demonstrates the security risks of exposing AI model inference and testing capabilities to untrusted networks, particularly in AI-serving infrastructure.

A critical remote code execution vulnerability has been discovered in LiteLLM, a popular open-source library for unified LLM API calls, allowing unauthenticated attackers to execute arbitrary code via bytecode rewriting manipulation at the /guardrails/test_custom_code endpoint.

Vulnerability details

  • CVE-2026-40217 with CVSS score of 8.8 (High)
  • Affects all LiteLLM versions through 2026-04-08
  • No authentication required for exploitation
  • Attack complexity: Low with network-based exploitability
  • Endpoint: /guardrails/test_custom_code URI
  • Mechanism: Bytecode rewriting manipulation

Why it matters

LiteLLM is widely used as a unified interface for various LLM providers (OpenAI, Anthropic, Cohere, etc.), making this vulnerability particularly dangerous for AI infrastructure deployments. The exposed guardrail testing endpoint demonstrates how AI-serving infrastructure can introduce unexpected attack surfaces when internal testing capabilities are exposed to external networks.

This vulnerability highlights the security challenges in AI inference stacks where guardrail testing, model validation, and custom code execution features may inadvertently expose critical attack surfaces. Organizations using LiteLLM for production AI workloads should treat this as a critical security issue requiring immediate attention.

What to do

  • Immediately update LiteLLM to the latest version beyond 2026-04-08
  • Restrict network access to LiteLLM guardrail testing endpoints
  • Implement network segmentation for AI inference infrastructure
  • Review exposed endpoints in AI-serving applications
  • Monitor for suspicious activity targeting /guardrails/test_custom_code
  • Consider WAF protection for AI API endpoints

Sources