Skip to main content
Splunk Lantern

Suspicious kubectl calls (Amazon EKS)

Kubectl calls are not malicious by nature. However, examining the source IP addresses, source users, user agents, object paths, and authorizations of these calls can reveal potentially malicious activity, especially if you find anonymous, suspicious IP addresses trying to access sensitive objects, such as configmaps or secrets. You want to investigate anonymous kubectl calls on your network to determine if they represent a threat. 


Run the following search. You can optimize it by specifying an index and adjusting the time range. 

sourcetype="aws:cloudwatchlogs:eks" userAgent=kubectl* sourceIPs{}!=<valid IP address> sourceIPs{}!=::1 src_user=system:anonymous  
| table src_ip src_user verb userAgent requestURI  
| stats count BY src_ip src_user verb userAgent requestURI 

Search explanation

The table provides an explanation of what each part of this search achieves. You can adjust this query based on the specifics of your environment.

Splunk Search Explanation


Search only AWS EKS Kubernetes data.


Find the string kubectl* to reveal the use of kubectl application, which carries out HTTP requests to the Kubernetes API.

sourceIPs{}!=<valid IP address> 


Exclude a legitimate IP address or range of addresses from the search.


Search for anonymous users.

| table src_ip src_user verb userAgent requestURI 

Display the results in a table with columns in the order shown. 

| stats count BY src_ip src_user verb userAgent requestURI 

Count the number of each unique combination of source IP address, user, user agent, and requests URI.

Next steps

Kubectl is a tool that can do almost anything on a cluster, so it needs to be monitored. Unauthenticated calls indicate exposure of the API. Establishing security groups can limit API calls. Kubectl command strings can reveal malicious intent and likely access key compromise. Look at data such as geolocation, unusual users, unusual commands, request verbs, and object path.

For additional information about this search, such as its applicability to common frameworks and standards, see this project on GitHub.

Finally, you might be interested in other processes associated with the Monitoring Kubernetes sensitive object access use case.