
Summary A command injection vulnerability exists in the mcp-server-kubernetes MCP Server. The vulnerability is caused by the unsanitized use of input parameters within a call to child_process.execSync, enabling an attacker to inject arbitrary system commands. Successful exploitation can lead to remote code execution under the server process's privileges. The server constructs and executes shell commands using unvalidated user input directly within command-line strings. This introduces the possibility of shell metacharacter injection (|, >, &&, etc.). Details The MCP Server exposes tools (kubectl_scale, kubectl_patch , explain_resource, etc) to perform several kubernetes operations. An MCP Client can be instructed to execute additional actions for example via prompt injection when asked to read pod logs. Below some example of vulnerable code and different ways to test this vulnerability including a real example of indirect prompt injection that can lead to arbitrary command injection. Vulnerable code The following snippet illustrates the vulnerable code pattern used in the MCP Server’s tooling. Note: These is only one instance, but similar patterns may exist elsewhere in the codebase. kubectl_scale tool “`js import { execSync } from "child_process"; // https://github.com/Flux159/mcp-server-kubernetes/blob/v2.4.9/src/tools/kubectl-scale.ts#L44-L52 const namespace = input.namespace || "default"; const resourceType = input.resourceType || "deployment"; // Build the kubectl…Read More
MCP Server Kubernetes vulnerable to command injection in several tools

