PIVTR-D
RAzure playbook · Compute and containers

AKS cluster compromise

An attacker pulls the cluster admin kubeconfig with an Azure role, or enters through an exposed workload. The attacker then binds an account to cluster-admin, reads Kubernetes secrets, and runs pods that request tokens for the kubelet identity or a workload identity, which reach Azure resources outside the cluster. Close the API server and remove the attacker's bindings first, then revoke the credentials and tokens the attacker could still use.

Look here

LogSearch for
AKSAuditAdmin (category kube-audit-admin)Role bindings, service accounts, pods, daemon sets and exec sessions created or changed: AKSAuditAdmin | where ObjectRef.resource in ("clusterrolebindings", "rolebindings", "serviceaccounts", "pods", "daemonsets") or ObjectRef.subresource == "exec" | project TimeGenerated, User, SourceIps, Verb, ObjectRef, UserAgent
AKSAudit (category kube-audit)Secret reads by user and source address. In Azure diagnostics mode, the same events are in AzureDiagnostics with the category kube-audit, in the log_s column: AKSAudit | where ObjectRef.resource == "secrets" and Verb in ("get", "list") | summarize count() by tostring(User.username), tostring(SourceIps)
AzureActivityCredential downloads, Run Command, role assignments and federated credentials. Check that role assignment writes target the cluster scope: AzureActivity | where OperationNameValue in~ ("Microsoft.ContainerService/managedClusters/listClusterAdminCredential/action", "Microsoft.ContainerService/managedClusters/listClusterUserCredential/action", "Microsoft.ContainerService/managedClusters/runCommand/action", "Microsoft.Authorization/roleAssignments/write", "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials/write") | project TimeGenerated, Caller, CallerIpAddress, OperationNameValue, _ResourceId
Cluster configurationEntra integration, local accounts, the OpenID Connect (OIDC) issuer and the kubelet identity: az aks show -g <rg> -n <cluster> --query "{aad:aadProfile, localDisabled:disableLocalAccounts, oidc:oidcIssuerProfile, kubelet:identityProfile.kubeletidentity}"
AADManagedIdentitySignInLogsToken requests by the kubelet identity and by user-assigned identities federated with the cluster, then their calls, as in the managed identity playbook
SecurityAlertDefender for Containers alerts on the cluster: SecurityAlert | where ResourceId has "<cluster>" | project TimeGenerated, AlertName, AlertType, CompromisedEntity, Entities

Contain

#Item
1Export the audit tables for the window, and snapshot the OS disks of affected nodes in the node resource group
2Limit API server access on a public cluster: az aks update -g <rg> -n <cluster> --api-server-authorized-ip-ranges <cidr>
3List Azure role assignments on the cluster. Repeat with --scope <cluster-id>/namespaces/<ns> for each namespace: az role assignment list --scope <cluster-id>
4Remove the attacker's role assignments on the cluster and its namespaces: az role assignment delete --ids <assignment-id>
5Disable local accounts on an Entra-integrated cluster: az aks update -g <rg> -n <cluster> --disable-local-accounts
6Save each binding and workload the attacker created: kubectl get clusterrolebinding <name> -o yaml
7Delete the attacker's bindings and workloads destructive: kubectl delete clusterrolebinding <name>
8Delete federated credentials that trust the attacker's service accounts destructive: az identity federated-credential delete --name <fic> --identity-name <identity> -g <rg>
9Rotate the OIDC issuer signing keys. Run the command twice, then restart pods that use projected tokens: az aks oidc-issuer rotate-signing-keys -g <rg> -n <cluster>
10Revoke client certificates and service account tokens destructive, recreates nodes and disks: az aks rotate-certs -g <rg> -n <cluster>
11Have each operator download new credentials after the rotation: az aks get-credentials -g <rg> -n <cluster>

Eradicate and recover

#Item
1Review the kubelet identity's roles and remove anything beyond image pull: az role assignment list --assignee <kubelet-object-id> --all
2Move workloads from pod-managed identity, deprecated in 2022 with add-on support through September 2025, to Microsoft Entra Workload ID
3Block pod access to the Instance Metadata Service (IMDS). The flag is in preview and needs the aks-preview extension, and host network pods keep access: az aks update -g <rg> -n <cluster> --enable-imds-restriction
4Enable Azure RBAC for Kubernetes with --enable-azure-rbac, and keep local accounts disabled on every cluster
5Redeploy workloads from trusted images, checking the registry with the image tampering playbook
6Send kube-audit-admin and guard to the workspace in resource-specific mode, and keep kube-audit on while the case is open
Watch out
  • kube-audit-admin drops get and list events, so secret reads appear only in kube-audit. Neither category exists until you create a diagnostic setting.
  • Disabling local accounts leaves downloaded admin certificates valid until az aks rotate-certs, which recreates all nodes and disks with up to 30 minutes of downtime. Snapshot node disks first.
  • After an OIDC key rotation, old and new keys stay valid for 24 hours. Rotate twice and restart pods to cut off stolen service account tokens at once.
  • Every pod reaches IMDS by default, which exposes the node's managed identity tokens. Namespace-scoped Azure RBAC assignments are hidden in the portal, and new assignments take up to five minutes to apply.

Microsoft Learn: monitor AKS; AKS local accounts; certificate rotation and rotate certificates in AKS; Microsoft Entra ID authorization for AKS; workload identity overview; OIDC issuer; block pod access to IMDS; Microsoft Entra pod-managed identity; control kubeconfig access; supported logs for managedClusters; AKSAudit and AKSAuditAdmin tables; Azure permissions for Containers; Azure CLI reference for az aks and the aks-preview extension. Checked October 2026.

Adapts material from Dynamic Incident Response: A Framework for Security Teams by Joshua Wright, © 2026 The Escal Institute of Advanced Technologies, Inc. d/b/a SANS Institute, licensed under CC BY 4.0. Figures reproduced under that license. Changes were made. Not published by, endorsed by, or affiliated with the SANS Institute.