Kubernetes Pod Exec Cloud Instance Metadata Access
Detection of Kubernetes pod exec sessions accessing cloud instance metadata endpoints, indicating potential credential theft from AWS, GCP, or Azure.
This alert focuses on detecting Kubernetes pod exec sessions that attempt to access cloud instance metadata endpoints. The activity is flagged when the decoded command line of a pod exec session contains references to cloud instance metadata services across AWS, GCP, and Azure. Attackers may exploit this to harvest role credentials, tokens, or instance attributes from the underlying node or hypervisor. This is a high-risk behavior because it can expose short-lived cloud credentials to code running inside a container, particularly concerning in multi-tenant and regulated environments. This detection classifies the cloud target and whether the command indicates credential theft or reconnaissance.
Attack Chain
- Attacker gains initial access to a Kubernetes cluster.
- Attacker identifies a vulnerable pod within the cluster.
- The attacker uses
kubectl execto gain shell access to the pod. - Inside the pod, the attacker crafts a command-line request targeting the cloud instance metadata service (IMDS) endpoint.
- The command, often using
curlorwget, attempts to retrieve sensitive information such as IAM roles, tokens, or instance attributes. - The IMDS responds with the requested data, which may include credentials or configuration details.
- The attacker exfiltrates the stolen credentials or uses them to escalate privileges within the cloud environment.
- Attacker uses the harvested credentials to move laterally, compromise other cloud resources, or exfiltrate sensitive data.
Impact
Compromised credentials can lead to unauthorized access to sensitive data, lateral movement within the cloud environment, and potential data exfiltration. A successful attack could impact multiple organizations sharing the same Kubernetes cluster. The impact could include financial losses, reputational damage, and regulatory fines, depending on the type of data compromised and the extent of the breach.
Recommendation
- Deploy the Sigma rule
Kubernetes Pod Exec IMDS Accessto detect suspicious command-line activity within Kubernetes pods. - Block access to the cloud instance metadata endpoints (169.254.169.254) from within Kubernetes pods using network policies.
- Regularly review and tighten RBAC permissions related to
pods/execto limit the ability of attackers to gain shell access. - Monitor cloud audit logs for suspicious STS or token issuance events correlated with Kubernetes pod exec events.
- Implement workload identity solutions to avoid the need to expose instance metadata to pods.
- Baseline approved images and tune exclusions narrowly to avoid false positives.
Detection coverage 2
Kubernetes Pod Exec IMDS Access
highDetects Kubernetes pod exec sessions accessing cloud instance metadata endpoints.
Kubernetes Pod Exec with Potential Credential Theft
criticalDetects Kubernetes pod exec sessions accessing cloud instance metadata endpoints with credential theft patterns.
Detection queries are kept inside the platform. Get full rules →
Indicators of compromise
1
ip
| Type | Value |
|---|---|
| ip | 169.254.169.254 |