The vulnerability lies in the kubectl_generic tool of the mcp-server-kubernetes package, specifically within the kubectlGeneric function. This function is designed to execute kubectl commands based on input from a user or an AI agent. The core of the vulnerability is a lack of input validation on the flags and arguments passed to this function. An attacker can craft a malicious input, for example, by planting a structured log line that an AI agent might process, which includes flags like --server and --insecure-skip-tls-verify. When the kubectlGeneric function receives these flags, it passes them directly to the kubectl executable. This causes kubectl to connect to an attacker-controlled server and, due to the --insecure-skip-tls-verify flag, send the operator's Kubernetes bearer token in the Authorization header. The attacker can then capture this token and use it to impersonate the operator, gaining their privileges on the Kubernetes cluster. The patch for this vulnerability introduces a new function, assertNoDangerousFlags, which maintains a denylist of potentially harmful flags. This function is now called at the start of kubectlGeneric to inspect and reject any input containing these dangerous flags, thus preventing the flag injection attack.