Summary
LiteLLM 1.18.10 contains a command injection flaw in its MCP server creation feature, where user-supplied JSON configuration fields are executed as system commands without validation.
An attacker who can submit or influence MCP server configurations may execute arbitrary operating system commands with the privileges of the LiteLLM process, leading to remote code execution.
Affected context
This vulnerability appears in deployments where LiteLLM's MCP server creation feature is exposed to user input, either directly or through higher-level configuration interfaces.
The issue manifests when JSON configuration for MCP servers allows arbitrary command and args values that are executed on the host without adequate validation or restriction.
Environments where LiteLLM runs with elevated privileges or broad file and network access face increased risk, especially when configuration changes are accessible to untrusted or semi-trusted users.
Exploit preconditions
- Attack surface: MCP server configuration interface (e.g., API endpoint, configuration file, or admin panel) that LiteLLM reads to create MCP servers.
- Required access: Ability to create, modify, or influence MCP server JSON configuration (including
commandandargsfields), either directly or indirectly. - Trigger point: LiteLLM's code path that processes the MCP configuration and launches the configured server as a subprocess on the host.
- Why exploitation is possible: The application treats configuration values as trusted, passing them directly to the operating system process creation mechanism without validation, sanitization, or restriction to an allowed command set, enabling arbitrary command execution (CWE-77).
Why this happens
The root cause is the unsafe handling of command-line parameters derived from user-controlled configuration data.
LiteLLM's MCP server creation logic interprets configuration fields (command and args) as executable instructions and passes them directly to the host OS without enforcing an allowlist, validating content, or limiting shell metacharacters.
This behavior corresponds to CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where untrusted input influences command execution.
Conceptually, the pattern is: "accept arbitrary command configuration from a potentially untrusted source, then execute it as a system-level process with the application's privileges."
Potential impact
- Execution of arbitrary operating system commands with the privileges of the LiteLLM process
- Reading, modifying, or deleting files accessible to the LiteLLM runtime
- Lateral movement within the host or adjacent services via network-accessible interfaces
- Deployment of malware, cryptominers, or backdoors on the host system
- Exfiltration of sensitive data such as secrets, configuration files, or user content
- Disruption of service availability through resource exhaustion or destructive commands
General mitigation guidance
Effective mitigation focuses on constraining how commands are constructed and executed, and on narrowing the trust boundary of configuration inputs.
Recommended defensive patterns include:
- Adopt an allowlist model: Restrict MCP server startup to a fixed, predefined set of binaries or adapters and validate that configuration references only these approved commands.
- Treat configuration as untrusted: Parse MCP configuration as data and validate all fields, rejecting or ignoring free-form command strings and disallowing shell metacharacters and chaining constructs.
- Avoid shell interpretation: Use process creation APIs that bypass the shell and pass arguments as structured arrays; avoid string concatenation when building command lines.
- Apply least privilege: Run LiteLLM under a dedicated, minimally privileged OS account with limited filesystem and network access, and consider containerization or sandboxing to contain impact.
- Separate configuration roles: Restrict MCP configuration changes to tightly controlled administrative channels and enforce role-based access control for any interface that can alter commands.
- Harden defaults: Provide secure-by-default templates that do not require arbitrary commands, and discourage runtime configuration of executable paths where possible.
How teams detect issues like this
Detection can focus both on code-level patterns and runtime behavior:
- Static analysis and code review:
- Search for locations where configuration-driven values are passed into process creation APIs (e.g., subprocess execution) without validation.
- Flag any use of shell-interpretive execution or string-based command construction influenced by external configuration.
- Review MCP-related modules for absence of allowlists or schema validation on executable fields.
- Configuration auditing:
- Periodically scan MCP configuration sources for unexpected or non-standard commands and arguments, especially those invoking shells or scripting interpreters.
- Enforce policy checks in CI/CD or config pipelines that reject unsafe commands or suspicious patterns.
- Runtime monitoring:
- Use host-based intrusion detection or EDR tools to detect anomalous child processes originating from the LiteLLM process.
- Monitor logs for unusual MCP configurations, repeated configuration changes, or failed/unknown command invocations.
- Automated tooling:
- Integrate security-focused linters and SAST tools capable of recognizing command injection sinks and configuration-sourced parameters in the LiteLLM codebase or extensions.

