Kubelet Pod Discovery Detected via Defend for Containers
This rule detects the use of common Linux utilities such as du, nice, find, locate, and ls to repeatedly enumerate the /var/lib/kubelet/pods directory on a Kubernetes cluster, indicating an attacker attempting to discover running pods, their IDs, volumes, and runtime artifacts from a compromised container or node.
This brief details detection of Kubelet pod discovery, typically performed by an attacker who has gained initial access to a Kubernetes container or node. The attack involves the repeated use of standard Linux utilities like ls, find, du, locate, and nice to query the /var/lib/kubelet/pods directory. This directory is the default location where Kubelet stores critical information about running pods, including their IDs, associated volumes, and other runtime artifacts. Attackers leverage this behavior to map the cluster's workload distribution, identify potential targets, and locate sensitive data such as mounted secrets, service account tokens, or kubeconfig files. This discovery phase is a crucial step in preparing for further compromise, such as credential harvesting, privilege escalation, or lateral movement within the Kubernetes environment or to the underlying host. The activity can originate from an interactive session via kubectl exec, SSH to the node, or a compromised container using container runtime attach.
Attack Chain
- An attacker gains initial access to a Kubernetes container or node, potentially through a compromised application, exposed service, or misconfigured access.
- From the compromised environment, the attacker executes a built-in Linux utility such as
ls,find,du,locate, ornice. - The chosen utility is directed to enumerate or inspect the
/var/lib/kubelet/podsdirectory, which contains details about active pods. - The attacker may use recursive commands like
find /var/lib/kubelet/pods -maxdepth 2to systematically explore pod subdirectories and their contents. - The attacker collects information on pod IDs, volume mounts, and other runtime artifacts to understand the cluster's architecture and running workloads.
- Discovered information is correlated to identify sensitive areas, such as pods with privileged settings or specific application data.
- The attacker searches for sensitive files like mounted secrets, service account tokens, or
kubeconfigfiles within the enumerated pod directories. - This discovery phase prepares the attacker for subsequent actions, including credential harvesting, privilege escalation, or lateral movement within the Kubernetes cluster.
Impact
Successful Kubelet pod discovery can provide attackers with a detailed map of the Kubernetes cluster's running workloads and their configurations. This information is invaluable for identifying targets for privilege escalation, locating sensitive data, and planning lateral movement. If attackers gain access to /var/lib/kubelet via hostPath or privileged containers, they can read mounted secrets, service account tokens, and kubeconfig files, leading to credential harvesting. This can result in further compromise of the cluster, unauthorized access to cloud resources, data exfiltration, or complete control over the Kubernetes environment, potentially impacting numerous applications and services hosted within the cluster.
Recommendation
- Deploy the Sigma rule in this brief to your SIEM and tune for your environment, specifically for
process_creationevents involving the listed utilities and directory. - Monitor
process_creationandfile_eventlogs for repeated access or execution attempts targeting the/var/lib/kubelet/podsdirectory, which is referenced in the detection rule. - Restrict unnecessary hostPath mounts to
/var/lib/kubeletand other critical node paths to prevent attackers from accessing sensitive host directories. - Implement admission controls to block privileged or
hostPIDcontainers, and enforce non-root and read-only root filesystems for containers. - Validate the actor's permissions and activity by correlating with Kubernetes API audit logs, particularly for users or service accounts involved in activity against
/var/lib/kubelet/pods.
Detection coverage 1
Kubelet Pod Discovery via Built-in Utilities
lowDetects the use of common Linux utilities (du, nice, find, locate, ls) to enumerate the /var/lib/kubelet/pods directory, indicating Kubernetes pod discovery.
Detection queries are available on the platform. Get full rules →
Indicators of compromise
1
filepath
| Type | Value |
|---|---|
| filepath | /var/lib/kubelet/pods |