Skip to main content
Splunk Lantern

Suspicious kubectl calls (Google Kubernetes Engine)

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. 

Required data 


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

sourcetype="google:gcp:pubsub:message" data.protoPayload.requestMetadata.callerSuppliedUserAgent=kubectl* src_user=system:unsecured OR src_user=system:anonymous 
| table src_ip src_user data.protoPayload.requestMetadata.callerSuppliedUserAgent data.protoPayload.authorizationInfo{}.granted object_path 
| dedup src_ip src_user 

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 GCP Pub/Sub messages.


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

src_user=system:unsecured OR src_user=system:anonymous

Search for unsecured or anonymous users.

| table src_ip src_user data.protoPayload.requestMetadata.callerSuppliedUserAgent data.protoPayload.authorizationInfo{}.granted object_path 

Display the results in a table with columns in the order shown. Values from source IP addresses, source users, user agent, authorization granted information and the path of the object accessed via kubectl calls

| dedup src_ip src_user 

Remove duplicate results from the same IPs and users.

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.