Skip to main content
Splunk Lantern

Google Kubernetes Engine service accounts with failed or forbidden status

You want to investigate failed or forbidden status accounts on your network to determine if they represent a threat. 

Required data

Procedure

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

sourcetype="google:gcp:pubsub:message" system:serviceaccounts data.protoPayload.response.status.allowed!=* 
| table src_ip src_user http_user_agent data.protoPayload.response.spec.resourceAttributes.namespace data.resource.labels.cluster_name data.protoPayload.response.spec.resourceAttributes.verb  data.protoPayload.request.status.allowed data.protoPayload.response.status.reason data.labels.authorization.k8s.io/decision 
| 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

sourcetype="google:gcp:pubsub:message" 

Search only GCP Pub/Sub messages.

system:serviceaccounts data.protoPayload.response.status.allowed!=*

Search for service accounts that do not have a response status of allowed.

| table src_ip src_user http_user_agent data.protoPayload.response.spec.resourceAttributes.namespace data.resource.labels.cluster_name data.protoPayload.response.spec.resourceAttributes.verb  data.protoPayload.request.status.allowed data.protoPayload.response.status.reason data.labels.authorization.k8s.io/decision 

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

| dedup src_ip src_user 

Remove duplicate results from the same IPs and users.

Next steps

You can extend this search by using top or rare operators to find trends or rarities in failure status, user agents, source IP addresses, and request URIs. Note that this search can give false positives as there might be inherent issues with authentications and permissions at cluster.

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

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