Detection of Unauthorized Kubernetes API Interaction via CLI Tools
Adversaries leverage standard command-line tools like curl or wget to perform unauthorized discovery and credential access by querying sensitive Kubernetes API endpoints directly, bypassing legitimate management tooling.
What's new
- 1. new product Sep 19, 13:13 via elastic
Adversaries often attempt to interact with Kubernetes environments by directly querying the Kubernetes API server using native command-line tools like curl or wget. This technique allows attackers to evade monitoring associated with legitimate Kubernetes administration tools like kubectl and facilitates the discovery of cluster resources, including pods, deployments, and sensitive configurations such as secrets and config maps. This unauthorized interaction is used for both situational awareness within the target cluster and the direct exfiltration of sensitive material. Detecting these attempts requires visibility into process execution command lines that specifically target sensitive paths within the Kubernetes API. The activity poses a significant risk to the confidentiality and integrity of the containerized environment.
Attack Chain
- Attacker gains initial execution capability within a container or a host with network access to the internal Kubernetes API.
- Attacker performs reconnaissance to identify the local network configuration and the address of the Kubernetes API server.
- Attacker uses a native utility, such as curl or wget, to initiate an HTTP request directed at the Kubernetes API.
- The request is crafted to target sensitive endpoints such as /api/v1/secrets or /apis/rbac.authorization.k8s.io/.
- The API server processes the request, potentially returning sensitive configuration data or credentials if authentication is not strictly enforced or if the attacker has obtained a token.
- Attacker exfiltrates the discovered secrets or metadata back to their infrastructure or uses the discovered information for lateral movement within the cluster.
Impact
Successful exploitation of this technique can lead to the exposure of sensitive cluster secrets, service account tokens, and configuration data. This unauthorized access enables further compromise, including lateral movement, privilege escalation, and potential takeover of cluster-level resources, impacting the security posture of the entire containerized infrastructure.
Recommendation
- Deploy the provided Sigma rule to detect suspicious process command lines that indicate direct interaction with Kubernetes API endpoints.
- Baseline authorized tools and scripts (such as CI/CD pipelines or automated health checks) that require access to the API to reduce false positives.
- Enforce strict Kubernetes RBAC and network policies to restrict internal pod access to the API server.
- Monitor Kubernetes audit logs for anomalous or unauthorized API requests, correlating them with process execution telemetry on the source host.
Immediate actions
Deploy detection rule to identify direct API access
Threat Hunt
Search for curl/wget process executions containing /api/v1/ in command line
Data: Process command line
Detection coverage 1
Detect Unauthorized Kubernetes API Interaction via Curl or Wget
mediumDetects the use of curl or wget to directly query sensitive Kubernetes API endpoints.
Detection queries are available on the platform. Get full rules →