DNS Enumeration in Linux Containers by Adversaries
Adversaries leverage DNS enumeration tools such as nslookup, dig, host, or getent hosts inside compromised Linux containers to discover internal Kubernetes services and network configuration, facilitating lateral movement and further exploitation.
This brief details how adversaries perform reconnaissance within compromised Linux containers by executing DNS enumeration tools like nslookup, dig, host, or getent hosts. This activity, detected by Elastic Defend for Containers, aims to map the internal network configuration of the container, identify Kubernetes services, and discover domains within the cluster. By querying internal Kubernetes names such as kubernetes.default, *.svc.cluster.local, or *.cluster.local, attackers gain crucial information about reachable endpoints. This post-compromise activity is a key precursor to lateral movement, privilege escalation, and access to sensitive resources like the Kubernetes API server or service account tokens, ultimately enabling further malicious actions within the environment. This technique is often observed after an initial compromise, when an attacker has obtained interactive shell access to a pod.
Attack Chain
- Initial Compromise: An adversary successfully compromises a Linux container within a Kubernetes environment, typically through a vulnerable application or misconfiguration.
- Interactive Shell Access: The attacker establishes interactive shell access to the compromised pod, allowing direct command execution within the container.
- DNS Enumeration Tool Execution: The adversary executes standard DNS enumeration utilities like
nslookup,dig,host, orgetent hostsfrom within the container's shell. - Kubernetes Service Discovery: These tools are used to query internal Kubernetes-specific hostnames and domain patterns, such as
kubernetes.default,*.svc.cluster.local, or*.cluster.local. - Network Mapping and Reconnaissance: The results of these queries provide the attacker with information about the cluster's network configuration, available internal services, and reachable endpoints.
- Credential Access Attempt: The adversary may attempt to access sensitive files like
/var/run/secrets/kubernetes.io/serviceaccountto retrieve service account tokens, which can be used for authentication and privilege escalation. - Lateral Movement Staging: Based on the gathered intelligence, the attacker plans and executes lateral movement towards the Kubernetes API server, internal dashboards, or other high-value pods, expanding their control over the cluster.
Impact
Successful DNS enumeration within a compromised container allows adversaries to gain a detailed understanding of the Kubernetes cluster's internal network and service topology. This knowledge enables attackers to identify critical internal services, map potential targets for further exploitation, and circumvent security controls. The ultimate impact can include unauthorized access to the Kubernetes API server, exfiltration of sensitive data, deployment of malicious workloads, or complete compromise of the cluster leading to widespread service disruption or data breaches. While this specific activity is a reconnaissance phase, it is a critical step towards more severe consequences.
Recommendation
- Deploy the Sigma rule "Detect DNS Enumeration in Linux Containers" to your SIEM for real-time monitoring of suspicious activity.
- Configure Kubernetes audit logs to capture
kubectl exec/attachor ephemeral container launches, and correlate with thecontainer.idfrom alerts. - Review DNS and network telemetry from affected pods (e.g., CoreDNS logs, CNI flow logs) to trace queried hostnames and subsequent connections to internal services or the API server.
- Isolate any affected pods immediately by applying a deny-egress NetworkPolicy to the CoreDNS service and cluster service CIDRs, and consider rotating affected service account tokens.
- Harden your Kubernetes environment by restricting
exec/attachcapabilities via RBAC, enforcing Pod Security Standards to disallow unauthorized ephemeral containers, limiting egress from pods with NetworkPolicies, and utilizing distroless or stripped-down container images that omit unnecessary utilities like DNS enumeration tools.
Detection coverage 1
Detect DNS Enumeration in Linux Containers
lowDetects the execution of DNS enumeration tools (nslookup, dig, host, getent hosts) inside a Linux container querying internal Kubernetes names (kubernetes.default, *.svc.cluster.local). This indicates post-compromise reconnaissance.
Detection queries are available on the platform. Get full rules →
Indicators of compromise
3
domain
1
filepath
1
url
| Type | Value |
|---|---|
| domain | kubernetes.default |
| domain | *.svc.cluster.local |
| domain | *.cluster.local |
| filepath | /var/run/secrets/kubernetes.io/serviceaccount |
| url | https://kubernetes.default |