Kubernetes: what the audit log keeps, and what it throws away
Someone creates a privileged pod in the prod namespace. It mounts the node’s / into a container, turns on hostPID, asks for privileged: true. That is more or less the definition of a host escape. The cluster accepts it, and the audit log writes a line.
That line says a pod named debug-tools was created by the user admin, in prod, with status code 201. It does not say the pod is privileged. It does not say it mounts the node’s filesystem. Those fields are nowhere in the event, and no detection rule, however well written, can recover information that isn’t in the log.
This is the kind of detail you tend to discover too late, after the rule is written and deployed, when you start wondering why it never fired. I wanted to see it for myself, on a real control plane.
The lab
No managed cluster on hand, and in any case I wanted to control the audit configuration, which GKE and EKS don’t let you tune freely. So I stood up the bare minimum: etcd v3.7.2 and kube-apiserver v1.37.1, launched by hand, with an audit policy and a JSON output file. No kubelet, no node. The pods therefore never actually run, but that changes nothing for what I care about: auditing records the requests that reach the API, not what happens afterward on the node. A pod creation, an exec, an RBAC binding all leave their trace whether or not a container starts behind them.
The audit policy is the file that decides, for each request, how much detail to keep. There are four levels: None logs nothing, Metadata keeps the who, the what and the when, Request adds the request body, RequestResponse adds the API response on top. The choice is made rule by rule, per resource type.
The trap is in the level
I started with a policy that looked sensible: secrets at Metadata so their contents never land in the logs, the exec and attach subresources at Request, and everything else at Metadata. That is roughly what you see in many examples, and it already beats the default of many clusters, which is to log nothing at all.
Then I replayed the privileged pod creation and looked at the event. The requestObject field, the one that holds the pod spec, isn’t there. At Metadata level that’s expected: by definition you don’t keep the request body. But the consequence is brutal. The most dangerous pod you can create produces exactly the same event as a harmless nginx: same verb, same resource, same namespace. Only the name differs.

So I raised pods and RBAC bindings to RequestResponse and repeated the exact same creation. This time requestObject.spec is there in full: hostPID: true, hostNetwork: true, privileged: true on the container, and the hostPath volume pointing at /. The same event from the attacker’s side, two radically different logs from the defender’s.

exec behaves better. A kubectl exec leaves an event on the pods/exec subresource, and from Request level the full URI is there: /api/v1/namespaces/prod/pods/debug-tools/exec?command=id&container=shell&stderr=true&stdout=true. The command run and the target container are in the log. It’s one of the few pleasant surprises: the command executed inside a container is visible without enabling the most verbose level.
Three rules, and the condition for them to fire
From there, the rules write themselves. The first looks for a pod that is privileged or shares a host namespace. It targets T1611, escape to the node.
title: Privileged Or Host-Namespace Pod Created
id: 7e4d3c2b-1a09-4f8e-bc7d-6a5e4f3d2c1b
status: experimental
description: |
Detects creation of a Pod that is privileged, shares a host namespace (hostPID, hostIPC,
hostNetwork) or mounts a hostPath volume. These are the building blocks of a container
escape to the node. Requires the audit policy to log pods at RequestResponse (or at least
Request) level: at Metadata level the pod spec is absent and this rule cannot fire.
references:
- https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/
- https://attack.mitre.org/techniques/T1611/
author: PurpleLog
date: 2026-10-17
tags:
- attack.privilege-escalation
- attack.t1611
logsource:
product: kubernetes
service: audit
detection:
selection_create:
verb: 'create'
objectRef.resource: 'pods'
selection_fields:
- requestObject.spec.containers.securityContext.privileged: true
- requestObject.spec.hostPID: true
- requestObject.spec.hostIPC: true
- requestObject.spec.hostNetwork: true
- requestObject.spec.volumes.hostPath.path: '*'
condition: selection_create and selection_fields
falsepositives:
- Monitoring agents, CNI and storage DaemonSets legitimately run privileged or mount hostPath
- Scope the rule to application namespaces and exclude known system workloads
level: high
The second catches command execution inside a container, T1609. It’s short, because the subresource alone identifies it.
title: Command Execution In A Pod Via exec Or attach
id: 2f1e0d9c-8b7a-4653-9f21-0c3b2a1e4d5f
status: experimental
description: |
Detects use of the pods/exec or pods/attach subresource, i.e. an interactive command run
inside a running container. Visible from Request level upward; the executed command and
target container are in the request URI.
references:
- https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/
- https://attack.mitre.org/techniques/T1609/
author: PurpleLog
date: 2026-10-17
tags:
- attack.execution
- attack.t1609
logsource:
product: kubernetes
service: audit
detection:
selection:
objectRef.subresource:
- 'exec'
- 'attach'
condition: selection
falsepositives:
- Operators and CI pipelines that legitimately exec into pods for debugging
- Baseline the usual service accounts and users before alerting
level: medium
The third targets the granting of the cluster-admin role, a staple of post-foothold persistence, filed under T1098. As with the privileged pod, the roleRef only shows up from Request level: at Metadata level you know a binding was created, not which role it grants or to whom.
title: ClusterRoleBinding To cluster-admin Created
id: 9a8b7c6d-5e4f-4312-8d1c-0b9a8f7e6d5c
status: experimental
description: |
Detects creation of a (Cluster)RoleBinding that grants the built-in cluster-admin role.
A common persistence and privilege-escalation step after a foothold. Requires Request or
RequestResponse level: at Metadata level the roleRef is absent and this rule cannot fire.
references:
- https://kubernetes.io/docs/reference/access-authn-authz/rbac/
- https://attack.mitre.org/techniques/T1098/
author: PurpleLog
date: 2026-10-17
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098
logsource:
product: kubernetes
service: audit
detection:
selection:
verb: 'create'
objectRef.resource:
- 'clusterrolebindings'
- 'rolebindings'
requestObject.roleRef.name: 'cluster-admin'
condition: selection
falsepositives:
- Legitimate cluster bootstrap or operator installation granting cluster-admin
level: high
All three pass sigma check with no errors and no warnings. But “the rule is valid” doesn’t mean “the rule fires”. So I evaluated them with a small Python script against the real events the lab produced, with positive and negative cases. The one that matters most is the fourth: the same privileged pod, but whose event was captured at Metadata level. The rule must not fire, because the information isn’t there. It doesn’t.

Five out of five, including the deliberate non-detection. That’s exactly the point: the privileged-pod rule is correct, and yet it’s blind if the audit policy denies it its input. The bug isn’t in the rule, it’s upstream, in a line of configuration someone else wrote, often before the detection even existed.
What I’d put in the policy
My take, after this lab: aim for RequestResponse on a small set of resources where the body changes everything, and settle for Metadata on the rest. Pods, RBAC bindings (clusterrolebindings and rolebindings), serviceaccounts and admission webhooks deserve the full level, because the content carries the signal. The exec, attach and portforward subresources are fine at Request. And bulk reads (get, list, watch) can go to None for the most part, unless you want to detect enumeration, in which case keep at least the list calls at Metadata.
The cost is real and worth stating: moving pods to RequestResponse inflates log volume significantly, because a pod’s full spec isn’t small. It’s a trade-off, not a free setting. But between paying that volume and deploying a rule that will never fire, the choice looks easy to me.
The limits of this lab
These events come from a control plane I built, not a production cluster. The values are real, but the context is minimal: no load, no background noise, no dozens of controllers writing continuously. The lab proves what an event contains at each audit level, not what the volume looks like in real life.
One more thing: the field names I use in the rules (objectRef.resource, requestObject.spec…) are those of the raw audit API JSON. On a managed cluster, the log usually passes through an ingestion layer that renames or flattens these fields. GKE exposes them in Cloud Logging, EKS in CloudWatch, AKS in Azure diagnostic logs, and each has its own structure. The rules above test the right values; the mapping to your SIEM’s fields is yours to check. That’s actually the real first move when I’m plugged into a cluster: pull a sample of audit logs as they land in the SIEM, and look at whether a pod’s spec is really there, before writing a single rule.
References
- Kubernetes, Auditing: audit levels, event structure, policy.
- Kubernetes, Using RBAC Authorization.
- MITRE ATT&CK: T1611 Escape to Host, T1609 Container Administration Command, T1098 Account Manipulation.
- The three rules are downloadable as .yml.