How the attack works
The mcp-server-kubernetes package exposes tools like kubectl_scale, kubectl_patch, and explain_resource to AI agents. These tools build shell commands from tool parameters and execute them with execSync without stripping shell metacharacters such as ; | && $() or backticks. If an attacker can control or inject into those parameters — for example through a manipulated prompt, a compromised upstream data source, or a malicious tool response in a multi-agent chain — they can append their own shell commands. Those commands run with whatever Kubernetes credentials the MCP server holds, which are often cluster-admin level.
Why it matters
Successful exploitation gives an attacker arbitrary command execution on the host running the MCP server, with the server's Kubernetes admin privileges — enabling full cluster compromise, data exfiltration, or lateral movement.
What you can do
- Upgrade mcp-server-kubernetes past version 2.4.9 where this is fixed.
- Until patched, disable or restrict access to kubectl_scale, kubectl_patch, and explain_resource tools.
- Run the MCP server with the least-privileged Kubernetes credentials possible, not cluster-admin.
- Review any logs or sessions where these tools received unusual arguments containing shell metacharacters (; | && $() or backticks).
Known benign look-alikes
- Legitimate use of this pattern in an authorised workflow; review the surrounding session before acting.