Leaked AKS Admin Kubeconfig: Disable Local Accounts and Rotate Certificates to Revoke Admin Access
Overview
An AKS admin kubeconfig that has leaked keeps working until its certificate expires, because Kubernetes cannot revoke a certificate. Disable local accounts once Entra sign-in is proved, then rotate the cluster certificates in a maintenance window; rotation recreates nodes with up to 30 minutes of downtime.
Diagnose
Symptom
What responders observe.
AKS clusters have local accounts enabled by default, and Microsoft describes az aks get-credentials --admin as a non-auditable backdoor that survives turning on RBAC or Entra integration. The admin context also skips the Entra sign-in prompt.
Treat any of these as the trigger: An admin kubeconfig file was committed to a repository, pasted into a ticket or chat, or left on a build agent or laptop. A person who held that file has left the team or lost a device.
A review finds disableLocalAccounts set to false on a cluster that is supposed to be Entra-only.
Detection
Metrics, logs and confirmation commands.
Root cause
Why the incident occurred.
Contain and prevent
Blast radius
What else this can affect.
Prevention
Controls and guardrails that stop it recurring.
-
Create new clusters with --enable-aad --aad-admin-group-object-ids <group-id> --disable-local-accounts, and keep the Entra admin group small, because its members can still reach the cluster once local accounts are off.
-
Store reviewed RBAC manifests in version control and compare the live bindings to them regularly.
-
Kubectl auth reconcile supports a dry run for that.
-
Look at admission bypasses as well, such as a namespace exemption label that lets privileged pods through.
-
NIST SP 800-61 Rev.
-
3 Aims to help organisations improve how they detect, respond to and recover from incidents, so record the exposure window, what was rotated and what you will change.
Fix
Pre-flight checks
Check these before you change anything.
Azure CLI 2.0.77 or later and kubectl, signed in as an Entra identity in the cluster admin group.
A cluster with Microsoft Entra integration enabled and a maintenance window agreed for a node recreation.
Commands
az aks show --resource-group <resource-group> --name <cluster-name> -o json > aks-before.json
kubectl auth whoami
kubectl get clusterrolebindings -o custom-columns=NAME:.metadata.name,ROLE:.roleRef.name,SUBJECTS:.subjects[*].name
kubectl get clusterrolebinding <name> -o yaml > crb-<name>.yaml
kubectl auth can-i --list --namespace <namespace> --as <user>
az aks get-credentials --resource-group <resource-group> --name <cluster-name> --overwrite-existing
az aks update --resource-group <resource-group> --name <cluster-name> --disable-local-accounts
az aks rotate-certs --resource-group <resource-group> --name <cluster-name>
kubectl delete clusterrolebinding <name> --dry-run=server
kubectl delete clusterrolebinding <name>
Verify and recover
Verification
Evidence required before you close the incident.
Run az aks show and read disableLocalAccounts. — disableLocalAccounts is true. — The cluster no longer issues the static admin credential.
Run kubectl get nodes from a workstation holding the old admin kubeconfig after rotation. — Unable to connect to the server: x509: certificate signed by unknown authority. — The old admin certificate no longer reaches the API server. Refresh your Entra credential with az aks get-credentials --overwrite-existing, then run kubectl get nodes. — An Entra sign-in and the node list. — Entra access still works on the rotated cluster.
Re-run the ClusterRoleBinding listing and compare it with the reviewed list. — Only reviewed cluster-admin subjects remain. — No unexplained cluster-admin binding remains.
Rollback
The safe way back.
Re-enable local accounts with az aks update --enable-local-accounts only for an Entra lockout and with the incident lead's agreement
it reopens the static credential, so follow it with a certificate rotation.
Certificate rotation has no documented undo
if it fails, check az aks show for Certificate Rotating, rerun az aks rotate-certs, then refresh credentials with az aks get-credentials --overwrite-existing.
Recreate a deleted ClusterRoleBinding with kubectl create clusterrolebinding, using the roleRef and subjects from the file saved before deletion.
Escalate when
Conditions that need another owner.
-
Hand over to your security team at once if an unknown cluster-admin binding, service account or workload turns up, or if the old kubeconfig still works after rotation.
-
Those are signs of use, not just exposure.
-
Open a Microsoft support case if a rerun of az aks rotate-certs leaves the cluster in a failed state, and tell the owners of anything the cluster's secrets unlock, since those secrets were readable.
-
Hold a rotation until the maintenance window is agreed unless you have evidence of live misuse.
-
Cloud platform owner Incident lead Microsoft support.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Found this useful? Follow KBY for more like it.
Sources
Based on the vendor sources listed below. Check each step against your environment before acting.
First published 29 November 2026
Manage local accounts with Microsoft Entra integration
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Manage and rotate certificates in Azure Kubernetes Service (AKS)
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Overview of certificate management and rotation in AKS
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Use Kubernetes RBAC with Microsoft Entra ID in AKS
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Authenticating
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Using RBAC Authorization
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Authorization Overview
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
SP 800-61 Rev. 3: Incident Response Recommendations and Considerations
Cited for: Supports the documented platform behaviour, diagnosis or recovery controls used by this Runbook.
Recommended reading
More from KBY that goes with this runbook.
