Kubernetes Ephemeral Container Added to Pod

Last updated 8 days ago on 2026-05-07
Created 8 days ago on 2026-05-07

About

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.
Tags
Data Source: KubernetesDomain: KubernetesUse Case: Threat DetectionTactic: Privilege EscalationTactic: ExecutionLanguage: kuery
Severity
medium
Risk Score
47
MITRE ATT&CK™

Privilege Escalation (TA0004)(external, opens in a new tab or window)

Execution (TA0002)(external, opens in a new tab or window)

False Positive Examples
Cluster operators or SREs may legitimately use ephemeral containers for debugging production workloads. Baseline approved admin identities and tune exclusions for known automation.
License
Elastic License v2(external, opens in a new tab or window)

Definition

Rule Type
Query (Kibana Query Language)
Integration Pack
Prebuilt Security Detection Rules
Index Patterns
logs-kubernetes.audit_logs-*
Related Integrations

kubernetes(external, opens in a new tab or window)

Query
text code block:
data_stream.dataset:"kubernetes.audit_logs" and kubernetes.audit.objectRef.resource:"pods" and kubernetes.audit.objectRef.subresource:"ephemeralcontainers" and kubernetes.audit.verb:("update" or "patch") and kubernetes.audit.annotations.authorization_k8s_io/decision:"allow" and not user.name:( system\:node\:* or system\:serviceaccount\:kube-system\:* )

Install detection rules in Elastic Security

Detect Kubernetes Ephemeral Container Added to Pod in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).