Kubernetes Ephemeral Container Added to Pod
Detects allowed updates to the pods/ephemeralcontainers subresource by a non-system identity. Ephemeral containers are commonly used for debugging (kubectl debug) but can also be abused to inject tooling into a running pod, access mounted secrets, and execute commands in the target pod context. Attackers with sufficient RBAC may use ephemeral containers to escalate privileges, move laterally, or establish persistence without deploying a new workload.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2026/05/07"
3integration = ["kubernetes"]
4maturity = "production"
5updated_date = "2026/09/18"
6
7[rule]
8author = ["Elastic"]
9description = """
10Detects allowed updates to the pods/ephemeralcontainers subresource by a non-system identity. Ephemeral containers are
11commonly used for debugging (kubectl debug) but can also be abused to inject tooling into a running pod, access mounted
12secrets, and execute commands in the target pod context. Attackers with sufficient RBAC may use ephemeral containers to
13escalate privileges, move laterally, or establish persistence without deploying a new workload.
14"""
15false_positives = [
16 """
17 Cluster operators or SREs may legitimately use ephemeral containers for debugging production workloads. Baseline
18 approved admin identities and tune exclusions for known automation.
19 """,
20]
21from = "now-9m"
22index = ["logs-kubernetes.audit_logs-*"]
23language = "kuery"
24license = "Elastic License v2"
25name = "Kubernetes Ephemeral Container Added to Pod"
26note = """## Triage and analysis
27
28> **Disclaimer**:
29> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
30
31### Investigating Kubernetes Ephemeral Container Added to Pod
32
33Ephemeral containers allow adding a container to an existing pod for troubleshooting. When abused, they can be used to
34gain interactive access to a workload, read sensitive files, and run tools that were not present in the original image.
35
36### Possible investigation steps
37
38- Review the actor (user.name, groups), source.ip, and user_agent.original and confirm the identity is authorized to use ephemeral containers.
39- Inspect kubernetes.audit.objectRef (namespace, name) to identify the targeted pod and workload owner.
40- If request bodies are captured, review the ephemeral container image, command, and securityContext for privilege indicators.
41- Correlate with follow-on audit activity such as pod exec, secret reads, TokenRequest, or RBAC modifications.
42
43### Response and remediation
44
45- If unauthorized, remove excessive RBAC that grants update/patch on pods/ephemeralcontainers and rotate exposed credentials.
46- Quarantine or redeploy impacted workloads and hunt for additional compromised pods or identities.
47"""
48references = [
49 "https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/",
50]
51risk_score = 47
52rule_id = "c62733ff-9373-4fdf-9733-3d992e148c93"
53severity = "medium"
54tags = [
55 "Data Source: Kubernetes",
56 "Domain: Kubernetes",
57 "Use Case: Threat Detection",
58 "Tactic: Privilege Escalation",
59 "Tactic: Execution",
60 "Resources: Investigation Guide",
61 "Noise: Unknown",
62 "Performance: Fast",
63 "Rule Type: Custom Query (KQL)",
64 "Platform: Kubernetes",
65 "Domain: Containers",
66 "Domain: Cloud",
67]
68timestamp_override = "event.ingested"
69type = "query"
70query = '''
71data_stream.dataset:"kubernetes.audit_logs" and
72kubernetes.audit.objectRef.resource:"pods" and
73kubernetes.audit.objectRef.subresource:"ephemeralcontainers" and
74kubernetes.audit.verb:("update" or "patch") and
75kubernetes.audit.annotations.authorization_k8s_io/decision:"allow" and
76not user.name:(
77 system\:node\:* or
78 system\:serviceaccount\:kube-system\:*
79)
80'''
81
82[[rule.threat]]
83framework = "MITRE ATT&CK"
84
85[[rule.threat.technique]]
86id = "T1611"
87name = "Escape to Host"
88reference = "https://attack.mitre.org/techniques/T1611/"
89
90[rule.threat.tactic]
91id = "TA0004"
92name = "Privilege Escalation"
93reference = "https://attack.mitre.org/tactics/TA0004/"
94
95[[rule.threat]]
96framework = "MITRE ATT&CK"
97
98[[rule.threat.technique]]
99id = "T1609"
100name = "Container Administration Command"
101reference = "https://attack.mitre.org/techniques/T1609/"
102
103[rule.threat.tactic]
104id = "TA0002"
105name = "Execution"
106reference = "https://attack.mitre.org/tactics/TA0002/"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating Kubernetes Ephemeral Container Added to Pod
Ephemeral containers allow adding a container to an existing pod for troubleshooting. When abused, they can be used to gain interactive access to a workload, read sensitive files, and run tools that were not present in the original image.
Possible investigation steps
- Review the actor (user.name, groups), source.ip, and user_agent.original and confirm the identity is authorized to use ephemeral containers.
- Inspect kubernetes.audit.objectRef (namespace, name) to identify the targeted pod and workload owner.
- If request bodies are captured, review the ephemeral container image, command, and securityContext for privilege indicators.
- Correlate with follow-on audit activity such as pod exec, secret reads, TokenRequest, or RBAC modifications.
Response and remediation
- If unauthorized, remove excessive RBAC that grants update/patch on pods/ephemeralcontainers and rotate exposed credentials.
- Quarantine or redeploy impacted workloads and hunt for additional compromised pods or identities.
References
Related rules
- Azure AKS API Server Proxying Request to Kubelet
- Azure AKS Attempted User Exec into Pod
- Azure AKS Ephemeral Container Added to Pod
- Azure AKS Kubelet Proxy to Command Execution Endpoint
- GKE Ephemeral Container Added to Pod