LiteLLM Authenticated Command Execution via MCP stdio Test Endpoints
Authenticated users with low-privilege API keys could execute arbitrary commands on the host running LiteLLM via the `/mcp-rest/test/connection` and `/mcp-rest/test/tools/list` endpoints, by submitting a server configuration including command execution parameters.
LiteLLM versions 1.74.2 through 1.83.6 are vulnerable to authenticated command execution. Two endpoints, POST /mcp-rest/test/connection and POST /mcp-rest/test/tools/list, intended for previewing MCP server configurations, allowed any authenticated user to execute arbitrary commands on the proxy host. This was possible because the endpoints accepted a full server configuration in the request body, including the command, args, and env fields used by the stdio transport, without proper role checks. An attacker could exploit this vulnerability by using a low-privilege API key to send a crafted request containing malicious commands, leading to command execution with the privileges of the proxy process. The vulnerability was patched in version 1.83.7 by enforcing the PROXY_ADMIN role for these endpoints.
Attack Chain
- Attacker authenticates to the LiteLLM proxy with a valid, but low-privilege, API key.
- Attacker crafts a malicious JSON payload containing a server configuration intended for the stdio transport. The payload includes the
command,args, andenvfields, which specify the command to be executed, its arguments, and environment variables, respectively. - Attacker sends a
POSTrequest to either the/mcp-rest/test/connectionor/mcp-rest/test/tools/listendpoint, with the malicious JSON payload in the request body. - The LiteLLM proxy receives the request and, due to the vulnerability, attempts to connect to the supplied server configuration.
- The proxy spawns the supplied command as a subprocess on the proxy host, using the privileges of the proxy process.
- The attacker-supplied command executes arbitrary code on the host.
- The attacker gains control of the proxy host with the privileges of the LiteLLM proxy.
Impact
Successful exploitation of this vulnerability allows an attacker to execute arbitrary commands on the host running the LiteLLM proxy. Since the vulnerability can be exploited with a low-privilege API key, this significantly broadens the attack surface. Depending on the privileges of the proxy process, this could lead to full system compromise, data exfiltration, or denial of service. The lack of specific victim count or sector targeting information in the advisory suggests a broad potential impact across various deployments of LiteLLM.
Recommendation
- Upgrade LiteLLM to version 1.83.7 or later to remediate the vulnerability (see Patches).
- As a temporary workaround, block
POSTrequests to the/mcp-rest/test/connectionand/mcp-rest/test/tools/listendpoints at your reverse proxy or API gateway (see Workarounds). - Monitor web server logs for
POSTrequests to/mcp-rest/test/connectionand/mcp-rest/test/tools/listendpoints, looking for suspiciouscommand,args, andenvparameters in the request body (see rules below).
Detection coverage 2
Detect POST Requests to LiteLLM MCP Test Endpoints
mediumDetects POST requests to the /mcp-rest/test/connection or /mcp-rest/test/tools/list endpoints, potentially indicating an attempt to exploit the command execution vulnerability.
Detect Suspicious Commands in LiteLLM MCP Test Requests
highDetects suspicious commands within the request body of POST requests to the /mcp-rest/test/connection or /mcp-rest/test/tools/list endpoints, potentially indicating command execution attempts.
Detection queries are kept inside the platform. Get full rules →