On August 28, 2026, the maintainer of mcp-server-kubernetes published an advisory saying that fourteen tools in the server passed caller-supplied strings straight into the argument list of kubectl. Three months earlier, the same class of bug had been fixed in exactly one of them. This is a case study of that fix history, written from the public advisories, the npm registry, and the source of the current release (4.2.3 as of November 25, 2026). The maintainer wrote detailed advisories and kept shipping fixes, which is why the record is useful: it shows what happens when an MCP server wraps a CLI, and most MCP servers do exactly that.

The sequence

The repository’s advisory page lists at least ten published advisories, from December 2025 to October 2026. Four of them trace one bug class, CWE-88 argument injection, and they arrive in order.

On April 14, GHSA-4xqg-gf5c-ghwq (CVE-2026-39884, fixed in 3.5.0) covered port_forward, which concatenated user fields into one string and split it on spaces. Any space in a value became a new kubectl argument. The advisory’s suggested fix was to build an argv array and call spawn("kubectl", args).

On May 22, GHSA-6mx4-4h42-r8vh (CVE-2026-47250, fixed in 3.7.0) covered kubectl_generic. Flags like --server and --insecure-skip-tls-verify=true could redirect kubectl to an endpoint the attacker controlled, and kubectl then sent the operator’s bearer token there. The advisory describes an indirect prompt injection path: text written into logs that the operator’s agent later reads.

On August 28, GHSA-jjrr-53h8-h34w (CVE-2026-75603, fixed in 3.9.0, CVSS 8.6) said the earlier fix had covered only kubectl_generic. Fourteen other tools put user values into bare positional slots of execFileSync("kubectl", argv), and kubectl’s flag parser treats a positional that begins with -- as a flag.

On September 4, GHSA-c257-86m4-m579 (CVE-2026-85986, fixed in 4.0.6) said the guard added for the previous advisory did not separate a short flag from an attached value. A token like -shttp://attacker.example slipped past the denylist, and kubectl read it as --server=URL. Versions 3.9.0 and earlier were affected, so the release that fixed the 14-tool advisory was itself bypassable.

The 4.2.0 release notes (October 26) list the next round: a verb policy for kubectl_generic, fail-closed argument checks, flag-shaped operand checks in other tools, and kubectl_context set disabled in read-only mode.

One more fact matters for anyone who relies on scanners. Comparing the advisory dates against the npm publish times for the fixed versions, the advisories trailed the fixes by a wide margin. We read the publish times from the npm registry.

AdvisoryFixed versionVersion on npmAdvisory published
GHSA-jjrr (14 tools)3.9.0June 9August 28 (80 days later)
GHSA-c257 (short flag)4.0.6July 18September 4 (48 days later)
GHSA-9j3p (SSE DNS rebinding)4.0.8July 23September 29 (68 days later)
GHSA-6963 (kubectl_patch path)4.1.1July 27October 2 (67 days later)

Someone who updated on advisory alerts alone learned about each of these a month or two after the patched version existed. We found no evidence in the sources we read about exploitation of any of them. The advisories describe proof-of-concept runs against a local kind cluster, which is a different statement.

The tool allowlist did not cover this

The server has three environment variables for restricting tools: ALLOW_ONLY_READONLY_TOOLS, ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS and ALLOWED_TOOLS. In May, GHSA-cr22-wjx7-2w6m (CVE-2026-46519, CVSS 8.8, fixed in 3.6.0) found that they were enforced when listing tools but not when calling them. A client that knew the name kubectl_delete could call it even though tools/list never showed it. We unpacked the 4.2.3 tarball from npm, and the CallToolRequestSchema handler now calls the same isToolAllowed(name) check before dispatching.

That fix is correct, and the flag injection bugs show why it is not enough. The 14-tool advisory states that ALLOW_ONLY_READONLY_TOOLS=true does not mitigate the bug, because kubectl_get is on the read-only list. A read-only tool with an attacker-chosen --server flag is a credential exfiltration tool. A tool name is a coarse permission. The authority lives in the arguments, and the allowlist never looks at them.

The same pattern appears in the path bugs. The advisory for kubectl_patch (GHSA-6963-p4fp-2wxw, CVE-2026-104776, fixed in 4.1.1) says sibling tools had received an isRemoteTransport() guard in earlier hardening, and kubectl_patch was missed. The advisory’s own recommendation is a shared check for all server-side path parameters, so future tools do not need per-tool guards. Per-tool fixes miss the next tool. A check at the one place where argv is built covers it.

What a denylist has to know

The 4.2.3 source shows how much parser knowledge a flag denylist needs. In dist/security/kubectl-flags.js there is a set of dangerous long flags (server, kubeconfig, token, as, insecure-skip-tls-verify, and more), a short alias table, and a list of short flags that consume a value. The comments explain why. pflag stops parsing a shorthand cluster at the first flag that takes a value, so -ojsonpath={...} carries a value, while boolean shorthands keep going. A comment on the table says leaving a letter out is always the safe direction, because at worst a legitimate attached value is refused. There is a separate set for helm, which uses --kube-apiserver for the same purpose and has a --post-renderer flag that runs a binary on the server host.

This is careful work, and it is also a copy of a third-party parser’s behavior that has to be kept in sync with every kubectl and helm release. The c257 advisory makes the broader recommendation itself: stop passing free-form argument arrays, and pass user values through explicit, separately validated parameters.

Here is how we would write a tool of this kind. This is our example, not code from the project. Each value is validated against the shape it must have, and the argv is built from constants plus validated values.

import { execFile } from "node:child_process";
import { promisify } from "node:util";

const run = promisify(execFile);

// DNS-1123 subdomain: must start with a letter or digit, so it can never begin with "-".
const NAME = /^[a-z0-9]([-a-z0-9.]{0,251}[a-z0-9])?$/;
const KINDS = new Set(["pods", "deployments", "services", "events"]);

export async function kubectlGet(kind: string, name: string | undefined, ns: string) {
  if (!KINDS.has(kind)) throw new Error("kind not allowed");
  if (!NAME.test(ns)) throw new Error("invalid namespace");
  if (name !== undefined && !NAME.test(name)) throw new Error("invalid name");

  const argv = ["get", kind, ...(name ? [name] : []), "-n", ns, "-o", "json"];
  const { stdout } = await run("kubectl", argv, {
    timeout: 15_000,
    env: { PATH: process.env.PATH, KUBECONFIG: "/etc/mcp/kubeconfig" },
  });
  return stdout;
}

Nothing here parses flags, because nothing user-controlled can start with a dash. The tradeoff is that you write one function per capability and lose the convenience of a generic kubectl tool. For a server that an LLM drives, we think that is the right trade, and the maintainers’ own 4.2.0 notes (a verb policy for the generic tool) point the same way.

Bound what a stolen token can do

Every flag injection advisory ends the same way: the captured token is replayed against the real API server with the operator’s RBAC permissions. So the cheapest control is to make that token boring. Give the server its own service account in one namespace, with read verbs on the resources the agent needs, and point the server at a kubeconfig that holds only that identity.

apiVersion: v1
kind: ServiceAccount
metadata:
  name: mcp-k8s
  namespace: mcp
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: mcp-k8s-read
  namespace: staging
rules:
  - apiGroups: [""]
    resources: ["pods", "pods/log", "events", "services"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["apps"]
    resources: ["deployments"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: mcp-k8s-read
  namespace: staging
subjects:
  - kind: ServiceAccount
    name: mcp-k8s
    namespace: mcp
roleRef:
  kind: Role
  name: mcp-k8s-read
  apiGroup: rbac.authorization.k8s.io

Then ask the cluster what that identity can do, instead of trusting the manifest:

kubectl auth can-i --list --as=system:serviceaccount:mcp:mcp-k8s -n staging
kubectl auth can-i get secrets --as=system:serviceaccount:mcp:mcp-k8s -n staging

The second command should print no. There is an honest limit here. The pods/log permission is the useful part of the tool and also the injection channel the advisories describe, since anything a workload writes to its logs ends up in front of the model. You cannot remove it without losing the feature, so the token scope has to carry the risk. A token that can read pods and logs in staging is a bad day. A token with cluster-admin is a different category, and the 3.6.0 advisory notes that cluster-admin is common in dev and staging service accounts.

What we could not confirm

Third-party vulnerability trackers list one more CVE against versions before 4.2.0, an argument injection through flag-shaped positional operands. We could not read a primary source for it (the repository’s advisory page did not show it when we looked), so it is not counted in the ten above. If it is real, it is another instance of the same pattern. We also did not test any of the exploits. Everything about behavior in this article comes from the advisories and from reading the 4.2.3 package.

This week

Find every place your team runs this server. A search of the usual config locations is a start:

grep -rn "mcp-server-kubernetes" ~/.claude.json ~/.cursor/mcp.json .mcp.json 2>/dev/null
npm ls -g mcp-server-kubernetes
npm view mcp-server-kubernetes version

For each hit, check three things. The version should be 4.2.3 or later, pinned as mcp-server-kubernetes@4.2.3 instead of floating on npx with no version. The kubeconfig it uses should belong to a scoped service account, verified with auth can-i. And if anyone runs the SSE transport, it should be on 4.0.8 or later with MCP_AUTH_TOKEN set, because GHSA-9j3p-gvw3-h8r8 is worst when the token is unset. Then subscribe to the repository’s security advisories, and treat npm’s version list as a more current signal than the advisory feed.