Azure AKS Certificate Signing Request Created or Approved
editAzure AKS Certificate Signing Request Created or Approved
editDetects an identity creating a client-authentication CertificateSigningRequest (signer kubernetes.io/kube-apiserver-client) or approving a CSR on AKS (Azure Kubernetes Service), excluding node bootstrap and platform controllers. Adversaries submit and self-approve a CSR against the kube-apiserver-client signer to mint a long-lived client certificate for an arbitrary subject (for example a Common Name in system:masters), giving durable authenticated access that survives token revocation. Coverage includes workload service accounts (system:serviceaccount:*), so a compromised in-cluster token forging a certificate is not excluded.
Rule type: query
Rule indices:
- logs-azure.platformlogs-*
Severity: medium
Risk score: 47
Runs every: 5m
Searches indices from: now-9m (Date Math format, see also Additional look-back time)
Maximum alerts per execution: 100
References:
- https://kubernetes.io/docs/reference/access-authn-authz/certificate-signing-requests/
- https://microsoft.github.io/Threat-Matrix-for-Kubernetes/
- https://github.com/inguardians/peirates
- https://raesene.github.io/blog/2022/12/21/Kubernetes-persistence-with-Tocan-and-Teisteanas/
- https://cloud.google.com/blog/topics/threat-intelligence/escalating-privileges-azure-kubernetes-services
- https://www.aquasec.com/blog/kubernetes-rbac-privilige-escalation/
Tags:
- Domain: Cloud
- Domain: Kubernetes
- Data Source: Azure
- Data Source: Azure Platform Logs
- Data Source: Kubernetes
- Use Case: Threat Detection
- Tactic: Credential Access
- Resources: Investigation Guide
Version: 1
Rule authors:
- Elastic
Rule license: Elastic License v2
Investigation guide
editTriage and analysis
Investigating Azure AKS Certificate Signing Request Created or Approved
AKS kube-audit events are carried under the flattened azure.platformlogs.properties.log.* subtree and share the ARM
operation event.action: Microsoft.ContainerService/managedClusters/diagnosticLogs/Read. A CSR created against the
kubernetes.io/kube-apiserver-client signer lets the requester choose the certificate’s subject (Common Name and
organization/groups); once approved it mints a client certificate for an arbitrary identity that yields access not tied
to a token. The default CertificateSubjectRestriction admission controller blocks requests for the system:masters
group, so attackers commonly request a Common Name matching an existing privileged user (or another privileged group)
instead, making the requested subject the key thing to decode. Node and kubelet certificates use the
kube-apiserver-client-kubelet and kubelet-serving signers (whose subject is constrained to the node) and are out of
scope; cert-manager and application CSRs use their own signers.
Possible investigation steps
-
Identify the requesting identity in
azure.platformlogs.properties.log.user.username(and its groups inazure.platformlogs.properties.log.user.groups) and whether it should submit or approve CSRs. A workload service account (system:serviceaccount:<ns>:<sa>) ormasterclient(the local cluster-admin cert) is the higher-concern case. -
Confirm the signer in
azure.platformlogs.properties.log.requestObject.spec.signerNameand decode the base64 CSR inazure.platformlogs.properties.log.requestObject.spec.requestto read the requested Common Name and organization (groups); a subject insystem:mastersor another privileged group is the escalation. -
Determine whether the same or a related identity approved the CSR (
verb:update/patchon theapprovalsubresource), which indicates self-approval, and inspectazure.platformlogs.properties.log.userAgent. -
Evaluate the source in
azure.platformlogs.properties.log.sourceIPsand pivot on it for follow-on privileged API activity using the newly issued certificate.
False positive analysis
-
Node bootstrap (
kube-apiserver-client-kubeletsigner), kubelet-serving CSRs, and cert-manager/application CSRs (custom signers) are out of scope by design; the kube-controller-managercertificate-controllerand the AKSaksServiceapprover are excluded by identity. -
Manual CSR approval by an administrator, or an operator that legitimately mints client certificates, may surface;
baseline those identities and exclude the specific validated account rather than re-broadening to all
system:*, which would blind the rule to compromised workload service accounts.
Response and remediation
- If unauthorized, deny or delete the CSR, revoke the issued certificate, and rotate the cluster CA if a privileged certificate was minted.
- Review the RBAC that allowed CSR creation and approval, and audit actions taken with the certificate.
- Collect kube-audit and identity artifacts per incident response procedures.
Setup
editThe Azure Fleet integration collecting AKS diagnostic logs forwarded through Event Hub into the azure.platformlogs
data stream is required for this rule. Enable either the kube-audit or the kube-audit-admin log category (Microsoft
recommends kube-audit-admin alone to reduce volume, as it only drops read-only get/list events). CSR create and
approval are mutating operations recorded in both categories with the same auditID, so clusters that enable both
categories may generate two alerts per event.
Rule query
editdata_stream.dataset:azure.platformlogs and
event.action:"Microsoft.ContainerService/managedClusters/diagnosticLogs/Read" and
azure.platformlogs.category:("kube-audit" or "kube-audit-admin") and
azure.platformlogs.properties.log.stage:"ResponseComplete" and
azure.platformlogs.properties.log.objectRef.resource:"certificatesigningrequests" and
azure.platformlogs.properties.log.responseStatus.code: "200" and
azure.platformlogs.properties.log.requestObject.status.conditions.type: "Approved" and
(
(
azure.platformlogs.properties.log.verb:"create" and
azure.platformlogs.properties.log.requestObject.spec.signerName:"kubernetes.io/kube-apiserver-client"
) or (
azure.platformlogs.properties.log.verb:("update" or "patch") and
azure.platformlogs.properties.log.objectRef.subresource:"approval"
)
) and
not azure.platformlogs.properties.log.user.username:(
system\:node\:* or system\:bootstrap\:* or "aksService" or "hcpService" or
"readinessChecker" or system\:serviceaccount\:kube-system\:*
)
Framework: MITRE ATT&CKTM
-
Tactic:
- Name: Credential Access
- ID: TA0006
- Reference URL: https://attack.mitre.org/tactics/TA0006/
-
Technique:
- Name: Steal or Forge Authentication Certificates
- ID: T1649
- Reference URL: https://attack.mitre.org/techniques/T1649/