rm -rf ~/.kube/config I deleted the kubeconfig on my Mac for every GKE and EKS cluster I work with. Not because kubeconfig is a bad format, but because of who else can read it.
Anything that runs as your macOS user can do what you can do: an AI agent, an npm postinstall script, an editor extension, malware. If that includes reading ~/.kube/config and the cloud logins behind it, it includes running kubectl against production.
Supply chain attacks now go after cloud and Kubernetes credentials
Three incidents from 2025 show the pattern.
- Nx "s1ngularity", August 2025. Compromised Nx releases on npm ran a
postinstallscript that looked for Claude Code, Gemini CLI and Amazon Q on the machine and ran them with--dangerously-skip-permissions,--yoloand--trust-all-toolsto search the disk for secrets. The malware didn't bring its own scanner. It used the developer's AI agents. - Shai-Hulud, September and November 2025. A self-spreading npm worm ran during
npm install, searched for AWS, GCP and Azure credentials and tokens, and published poisoned versions of other packages the victim maintained. CISA issued an alert for the first wave; the second wave hit hundreds more packages. - Amazon Q Developer extension for VS Code, July 2025. An official release shipped with an injected prompt telling the AI agent to delete local files and cloud resources. AWS says the prompt was malformed and did not run.
None of these needed a Kubernetes exploit. They needed a developer machine where the keys were already lying in the home directory.
Where your kubeconfig credentials actually live
On GKE and EKS, deleting ~/.kube/config is not the whole job, because the kubeconfig there usually holds no token. It holds an exec entry that runs a credential plugin:
users: - name: gke_my-project_europe-west1_prod user: exec: apiVersion: client.authentication.k8s.io/v1beta1 command: gke-gcloud-auth-plugin gcloud container clusters get-credentials writes that for GKE. aws eks update-kubeconfig writes a similar entry that runs aws eks get-token. Each time kubectl needs a token, it runs the plugin, and the plugin reads your CLI login:
| Cluster | Plugin in kubeconfig | What it reads on disk |
|---|---|---|
| GKE | gke-gcloud-auth-plugin | ~/.config/gcloud/ (refresh token); it also caches an access token in ~/.kube/gke_gcloud_auth_plugin_cache |
| EKS | aws eks get-token | ~/.aws/credentials or ~/.aws/sso/cache/ |
So a process running as you has two ways in: read the files, or simply run the plugin, exactly as kubectl does. Removing the kubeconfig without removing the gcloud and AWS CLI logins only hides the address; the key is still under the doormat.
Removing them by hand works for a day. Then you need to look at a pod, and the fastest way back is get-credentials again.
What I use instead: credentials that stay in Krust
Krust is a native macOS Kubernetes IDE. Since 1.9.0 my GKE and EKS clusters are connected like this.
1. Sign in to Google Cloud and AWS inside Krust. Add a cluster from File → Add Cluster…, sign in with Google or AWS, and pick the cluster. No gcloud, no AWS CLI, no kubeconfig file. The GKE guide has the steps.
2. The credential lives in the macOS Keychain. Saved Google Cloud and AWS credentials are in the data protection keychain, which hands them only to Krust's signed app: other apps and the security command can't read them. Turn on Require Touch ID to use saved Google Cloud and AWS credentials in Settings › Security and Keychain itself asks for Touch ID once per launch.
3. kubectl in a Krust terminal tab gets a token, never the login. The kubeconfig in a Krust terminal points at krust kube-credential. It asks Krust for a short-lived token over that tab's own socket, and Krust answers only processes running in that tab. No token is written to disk, and an expired one is refreshed on the next command.
4. A shell anywhere else finds nothing. Open iTerm or the VS Code terminal and kubectl has no kubeconfig, no gcloud login and no AWS profile to fall back on. The same goes for an npm postinstall script.
Give Claude Code only the cluster access you allow
AI agents are the reason this matters now. A coding agent with your shell can run the same kubectl you can, and s1ngularity showed malware is happy to drive it for you.
In Krust 1.9.0, a Claude Code tab on a GKE or EKS cluster never holds the cluster credential. Its kubectl and helm talk to a local proxy in Krust on 127.0.0.1, and Krust adds the real token to each request it lets through. You choose the mode in a bar above the tab:
- Read-only: reads work; changes,
exec,attach,cp,debugandport-forwardare refused. Secret values read as<hidden by Krust>, while their keys, sizes and metadata stay real. - Ask (the default): reads work, and each change or stream waits for your answer in Krust before it reaches the cluster. Secret values stay hidden.
- Write: full access, either until you switch back or for 15 minutes.
Impersonation (--as) and kubectl proxy are refused in every mode. When Claude tries a change in Read-only, it gets an answer it can act on:
$ kubectl delete pod api-7f9c Error from server (Forbidden): This Claude tab is in Read-only mode in Krust, so it cannot change the cluster. Kubernetes RBAC still applies on top. The proxy can narrow what your identity may do from that tab; it never grants more.
What this does not fix
There is no silver bullet. Malware running as you can still read your source code, your SSH keys and your browser data, and it can still try to trick you into approving a request. Krust does not change IAM or RBAC, so an over-privileged identity is still over-privileged when you use it yourself.
What changes is the default. A compromised package no longer finds a working production credential just by sharing your home directory, and your AI agent gets the access you chose for that tab, not everything you have.
Checklist: removing kubeconfig credentials from a Mac
- List what is on disk:
~/.kube/config,~/.kube/gke_gcloud_auth_plugin_cache,~/.config/gcloud/,~/.aws/credentials,~/.aws/sso/cache/. - Add the same clusters in Krust with Google Cloud or AWS sign-in, and check you can list pods from a Krust terminal tab.
- Turn on the Touch ID requirement in Settings › Security.
- Revoke the CLI logins (
gcloud auth revoke,aws sso logout, remove static keys from~/.aws/credentials) and delete the files from step 1. - Open Claude Code tabs in Read-only or Ask, and use Write only when you mean it.
Kubeconfig contexts you import stay Free in Krust; Google Cloud and AWS sign-in are part of Krust Pro.
Sources
- Nx security advisory GHSA-cxm3-wv7p-598c and Wiz: s1ngularity supply chain attack
- CISA: Widespread supply chain compromise impacting npm ecosystem and Wiz: Shai-Hulud 2.0
- AWS security bulletin AWS-2025-015 (Amazon Q Developer extension)
- Google Cloud: kubectl auth changes in GKE
- AWS CLI: aws eks get-token
- Kubernetes: client-go credential plugins
Originally published on krust.io.