Executive brief
mcp-server-kubernetes is a server that exposes tools for managing Kubernetes clusters via AI agents. The exec_in_pod tool allows executing commands inside containers but fails to validate user input, permitting attackers or malicious AI prompts to inject arbitrary shell commands. An attacker with access to the server can execute unauthorized commands with the privileges of the running pod, potentially compromising container data and operations.
Technical details
The vulnerability is a command injection flaw in the exec_in_pod function (src/tools/exec_in_pod.ts). When a string-format command is provided, the code wraps it in shell execution (/bin/sh -c) without validating or escaping shell metacharacters (;, &&, |, >, <, $). An attacker can inject commands via direct tool invocation or indirectly through prompt injection in pod logs that AI agents consume. Exploitation requires network access to the MCP server and either direct tool access or the ability to influence AI agent prompts. The fix is available in version 2.9.8 and later, which adds input validation to sanitize or reject shell metacharacters in string commands.
Affected products
- Flux159 mcp-server-kubernetes <= 2.9.7
Timeline
- 2025-12-03: disclosed
- 2025-12-03: patched: version 2.9.8 and later