Azure AKS Attempted User Exec into Pod
Detects an AKS (Azure Kubernetes Service) identity establishing an exec session into a pod. Interactive command execution inside a workload via kubectl exec is a common post-compromise technique used to access secrets, run tooling, and expand access from a foothold container. Node, control-plane, and kube-system service account identities are excluded, so workload service accounts and users, the identities an adversary is most likely to abuse, remain in scope.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2026/07/09"
3integration = ["azure"]
4maturity = "production"
5updated_date = "2026/09/18"
6
7[rule]
8author = ["Elastic"]
9description = """
10Detects an AKS (Azure Kubernetes Service) identity establishing an exec session into a pod. Interactive command
11execution inside a workload via kubectl exec is a common post-compromise technique used to access secrets, run tooling,
12and expand access from a foothold container. Node, control-plane, and kube-system service account identities are
13excluded, so workload service accounts and users, the identities an adversary is most likely to abuse, remain in scope.
14"""
15false_positives = [
16 """
17 Administrators routinely exec into pods for troubleshooting. Baseline expected users and target pods, then exclude
18 known break-glass or operator identities after review.
19 """,
20]
21from = "now-9m"
22index = ["logs-azure.platformlogs-*"]
23language = "kuery"
24license = "Elastic License v2"
25name = "Azure AKS Attempted User Exec into Pod"
26note = """## Triage and analysis
27
28### Investigating Azure AKS Attempted User Exec into Pod
29
30AKS kube-audit events are carried under the flattened `azure.platformlogs.properties.log.*` subtree and share the ARM
31operation `event.action: Microsoft.ContainerService/managedClusters/diagnosticLogs/Read`. This rule alerts on a
32`pods/exec` request by an identity that is not node, control-plane, or kube-system infrastructure. Exec into a pod grants
33an interactive shell inside the workload, which adversaries use to read mounted secrets, pivot, and stage tooling.
34
35### Possible investigation steps
36
37- Review the acting identity in `azure.platformlogs.properties.log.user.username` and its groups in
38 `azure.platformlogs.properties.log.user.groups`, and the target pod in
39 `azure.platformlogs.properties.log.objectRef.name` / `azure.platformlogs.properties.log.objectRef.namespace`.
40- Determine whether the target pod holds sensitive data, cluster credentials, or a mounted service account token.
41- Inspect the exec request path and command context in `azure.platformlogs.properties.log.requestURI` and the client in
42 `azure.platformlogs.properties.log.userAgent` (interactive `kubectl` vs a scripted client).
43- Evaluate the source in `azure.platformlogs.properties.log.sourceIPs`. Pivot on it for related API activity, secret
44 reads, or RBAC changes from the same identity.
45
46### False positive analysis
47
48- Approved admin debugging; exclude stable operator or break-glass identities after review.
49- CI/CD or platform tooling that execs into workloads may match; exclude verified service accounts and namespaces.
50
51### Response and remediation
52
53- If unauthorized, revoke the identity's tokens and kubeconfig and terminate the exec session.
54- Inspect the target pod for tampering, dropped tooling, or accessed secrets, and rotate any credentials it exposed.
55- Collect kube-audit and identity artifacts per incident response procedures.
56"""
57references = [
58 "https://kubernetes.io/docs/tasks/debug/debug-application/get-shell-running-container/",
59 "https://microsoft.github.io/Threat-Matrix-for-Kubernetes/",
60 "https://unit42.paloaltonetworks.com/hildegard-malware-teamtnt/",
61]
62risk_score = 47
63rule_id = "8f131efa-0284-465f-a360-da23e5562dd1"
64setup = "The Azure Fleet integration collecting AKS diagnostic logs with the `kube-audit` category forwarded through Event Hub into the `azure.platformlogs` data stream is required for this rule."
65severity = "medium"
66tags = [
67 "Domain: Cloud",
68 "Domain: Kubernetes",
69 "Data Source: Azure",
70 "Data Source: Azure Platform Logs",
71 "Data Source: Kubernetes",
72 "Use Case: Threat Detection",
73 "Tactic: Execution",
74 "Resources: Investigation Guide",
75 "Noise: Unknown",
76 "Performance: Fast",
77 "Rule Type: Custom Query (KQL)",
78 "Platform: Azure",
79 "Platform: Kubernetes",
80 "Domain: Containers",
81]
82timestamp_override = "event.ingested"
83type = "query"
84
85query = '''
86data_stream.dataset:azure.platformlogs and
87 event.action:"Microsoft.ContainerService/managedClusters/diagnosticLogs/Read" and
88 azure.platformlogs.category:"kube-audit" and
89 azure.platformlogs.properties.log.objectRef.resource:"pods" and azure.platformlogs.properties.log.objectRef.subresource:"exec" and
90 azure.platformlogs.properties.log.verb:("create" or "get") and
91 not azure.platformlogs.properties.log.user.username:(
92 system\:node\:* or "aksService" or "hcpService" or "readinessChecker" or
93 system\:serviceaccount\:kube-system\:*
94 )
95'''
96
97
98[[rule.threat]]
99framework = "MITRE ATT&CK"
100[[rule.threat.technique]]
101id = "T1609"
102name = "Container Administration Command"
103reference = "https://attack.mitre.org/techniques/T1609/"
104
105
106[rule.threat.tactic]
107id = "TA0002"
108name = "Execution"
109reference = "https://attack.mitre.org/tactics/TA0002/"
110
111[rule.investigation_fields]
112field_names = [
113 "@timestamp",
114 "event.action",
115 "azure.platformlogs.category",
116 "azure.platformlogs.properties.log.verb",
117 "azure.platformlogs.properties.log.user.username",
118 "azure.platformlogs.properties.log.sourceIPs",
119 "azure.platformlogs.properties.log.objectRef.resource",
120 "azure.platformlogs.properties.log.objectRef.subresource",
121 "azure.platformlogs.properties.log.objectRef.namespace",
122 "azure.platformlogs.properties.log.objectRef.name"
123]
Triage and analysis
Investigating Azure AKS Attempted User Exec into Pod
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. This rule alerts on a
pods/exec request by an identity that is not node, control-plane, or kube-system infrastructure. Exec into a pod grants
an interactive shell inside the workload, which adversaries use to read mounted secrets, pivot, and stage tooling.
Possible investigation steps
- Review the acting identity in
azure.platformlogs.properties.log.user.usernameand its groups inazure.platformlogs.properties.log.user.groups, and the target pod inazure.platformlogs.properties.log.objectRef.name/azure.platformlogs.properties.log.objectRef.namespace. - Determine whether the target pod holds sensitive data, cluster credentials, or a mounted service account token.
- Inspect the exec request path and command context in
azure.platformlogs.properties.log.requestURIand the client inazure.platformlogs.properties.log.userAgent(interactivekubectlvs a scripted client). - Evaluate the source in
azure.platformlogs.properties.log.sourceIPs. Pivot on it for related API activity, secret reads, or RBAC changes from the same identity.
False positive analysis
- Approved admin debugging; exclude stable operator or break-glass identities after review.
- CI/CD or platform tooling that execs into workloads may match; exclude verified service accounts and namespaces.
Response and remediation
- If unauthorized, revoke the identity's tokens and kubeconfig and terminate the exec session.
- Inspect the target pod for tampering, dropped tooling, or accessed secrets, and rotate any credentials it exposed.
- Collect kube-audit and identity artifacts per incident response procedures.
References
Related rules
- Azure AKS API Server Proxying Request to Kubelet
- Azure AKS Ephemeral Container Added to Pod
- Azure AKS Kubelet Proxy to Command Execution Endpoint
- Azure AKS Certificate Signing Request Created or Approved
- Azure AKS CoreDNS or Kube-DNS Configuration Modified