Join our Newsletter — 33% off our NHI Course
Home› Guides› How to Find Privileged Pods, hostPath Mounts and…
Guide Cloud Security

How to Find Privileged Pods, hostPath Mounts and Host Namespaces in a Cluster: Audit Every Path to the Node

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 18 November 2026 15 min read
On this page

A privileged container, a writable hostPath mount or a shared host namespace turns a single compromised pod into a compromised node, and with it every credential that node holds. This guide gives you a repeatable audit: list every pod that breaks the Kubernetes Baseline Pod Security Standard, work out which of those exceptions are real, and close the rest without breaking the platform components that genuinely need host access.

RBAC decides who can talk to the API server. Pod settings decide what a workload can reach once it is running. Both matter, and they fail together: a service account that can create pods in a namespace with no admission policy can simply ask for a privileged pod. If you have not yet reviewed who holds superuser rights, start with How to audit Kubernetes cluster admin bindings; this page covers the workload side and does not repeat that work.

Key takeaways

  • The Kubernetes Pod Security Standards define the Baseline level as a policy that prevents known privilege escalations. Baseline disallows privileged containers, hostPath volumes, sharing the host network, PID and IPC namespaces, host ports outside a known list and added Linux capabilities outside a fixed allowed set.
  • Kubernetes warns that access to the host filesystem through hostPath can expose privileged system credentials, such as those of the kubelet, and privileged APIs such as the container runtime socket, which can be used for container escape.
  • Audit running pods, not only manifests. Pods arrive from Helm charts, operators, DaemonSets created by cloud add-ons and ad hoc debugging sessions that never reach Git.
  • Pod Security Admission can report violations without blocking them. A server-side dry run of an enforce label shows which existing pods would fail before you change anything.
  • Every pod that keeps host access needs a named owner, a reason, a scoped service account and a review date. Treat it as a privileged non-human identity, because that is what it is.

When you need this

Run this audit in four situations. First, when you inherit a cluster or take over operations from another team and need to know where the escape hatches are. Second, before you turn on Pod Security Admission in enforce mode, so you know which workloads will be rejected. Third, after an incident or a suspicious alert involving a container, because the first containment question is whether the attacker could reach the node. Fourth, on a schedule, monthly for production clusters, because new charts and add-ons introduce host access quietly.

The audit is also the evidence you need for control reviews. NIST SP 800-53 Rev. 5 controls AC-6 Least Privilege and CM-7 Least Functionality both expect you to show that elevated rights exist only where justified. A table of host-access pods with owners and reasons is far easier to defend than a statement that admission control is "mostly on".

Before you start

  • Read access across namespaces. You need list on pods in every namespace. A read-only audit role is enough; do not run this with a cluster-admin kubeconfig left lying on a laptop.
  • Tools. kubectl and jq. Everything below works on any conformant cluster, managed or self-hosted.
  • A list of expected system components. CNI agents, storage drivers, log shippers, node monitoring agents and security sensors commonly need some host access. Write down what you expect before you look, so the results are compared against intent rather than accepted as normal.
  • A place to record findings. A spreadsheet with namespace, pod, owner kind, service account, the host settings used and a decision column is enough.

The settings that give a pod reach into the node

The Baseline level of the Pod Security Standards lists the fields that matter. Knowing why each one is dangerous helps you rank findings.

FieldWhat it grantsWhy it matters
securityContext.privileged: trueNear full access to host devices and kernel featuresA privileged container can usually mount the host disk and leave the container boundary.
spec.volumes[*].hostPathA file or directory from the node filesystemCan expose kubelet credentials, the runtime socket, other pods' volumes and node configuration.
spec.hostNetworkThe node's network namespaceBypasses pod network policy, can reach node-local services and the cloud metadata endpoint as the node.
spec.hostPIDVisibility of every process on the nodeAllows reading process environments and, with other rights, entering other processes.
spec.hostIPCThe node's shared memory and IPCAllows interference with other processes using shared memory.
ports[*].hostPortA port bound directly on the nodeExposes the pod outside normal Service and policy controls.
securityContext.capabilities.addExtra Linux capabilitiesCapabilities such as SYS_ADMIN or NET_ADMIN sit outside the Baseline allowed list and approach privileged mode.

The Pod Security Standards check these fields in containers, initContainers and ephemeralContainers. Your audit must check all three. Ephemeral containers are added by kubectl debug, and an init container that runs privileged for two seconds still had the node for two seconds.

Two related settings deserve a note. The Kubernetes volumes documentation explains that Bidirectional mount propagation lets a container's mounts propagate back to the host and is allowed only in privileged containers. Windows HostProcess containers give privileged access to the Windows host and are also disallowed at Baseline. Include both in your search if you run them.

Step-by-step

Step 1: export every pod once

Take a single snapshot so all later queries work on the same data and you are not hammering the API server.

kubectl get pods --all-namespaces -o json > pods.json

Keep the file. It is your evidence and your baseline for the next audit. It may contain environment variable values, so store it as you would any sensitive configuration, and delete it when the review closes.

Step 2: produce one row per risky pod

This query flags any pod using one or more host-access settings and prints the controlling owner and the service account, which you will need to judge blast radius.

jq -r '.items[] | [.spec.containers[]?, .spec.initContainers[]?, .spec.ephemeralContainers[]?] as $c | {ns: .metadata.namespace, pod: .metadata.name, owner: ((.metadata.ownerReferences // [])[0].kind // "none"), sa: (.spec.serviceAccountName // "default"), priv: any($c[]; .securityContext.privileged == true), net: (.spec.hostNetwork // false), pid: (.spec.hostPID // false), ipc: (.spec.hostIPC // false), paths: [.spec.volumes[]? | select(.hostPath) | .hostPath.path], ports: [$c[] | .ports[]? | select(.hostPort) | .hostPort], caps: ([$c[] | .securityContext.capabilities.add[]?] | unique)} | select(.priv or .net or .pid or .ipc or (.paths|length > 0) or (.ports|length > 0) or (.caps|length > 0)) | [.ns, .pod, .owner, .sa, .priv, .net, .pid, .ipc, (.paths|join(";")), (.ports|map(tostring)|join(";")), (.caps|join(";"))] | @tsv' pods.json

The output columns are namespace, pod, owner kind, service account, privileged, hostNetwork, hostPID, hostIPC, hostPath paths, host ports and added capabilities. Paste it into your findings sheet. Pods created by the same ReplicaSet or DaemonSet will repeat; group them by owner when you review.

The capability column lists everything added. The Baseline allowed list is AUDIT_WRITE, CHOWN, DAC_OVERRIDE, FOWNER, FSETID, KILL, MKNOD, NET_BIND_SERVICE, SETFCAP, SETGID, SETPCAP, SETUID and SYS_CHROOT. Anything else in that column is a Baseline violation.

Step 3: check whether each hostPath is writable

Whether a hostPath mount is read-only is decided on the container's volumeMounts, not on the volume. Kubernetes states that restricting which host directories may be mounted only works if you also require those mounts to be read-only, because a read-write mount can be used to subvert the restriction. This query joins volumes to mounts and prints the mode.

jq -r '.items[] | .metadata as $m | ([.spec.volumes[]? | select(.hostPath) | {(.name): .hostPath.path}] | add // {}) as $hp | [.spec.containers[]?, .spec.initContainers[]?, .spec.ephemeralContainers[]?][] | .name as $c | .volumeMounts[]? | select($hp[.name] != null) | [$m.namespace, $m.name, $c, $hp[.name], .mountPath, (if .readOnly == true then "ro" else "rw" end)] | @tsv' pods.json

Step 4: rank the paths

Not every hostPath carries the same risk. Rank them so the review starts with what an attacker would want.

  • Critical: /, /etc, /root, /var/lib/kubelet, /etc/kubernetes, the container runtime socket (for example /run/containerd/containerd.sock, /var/run/crio/crio.sock or /var/run/docker.sock) and /proc or /sys when writable. These expose kubelet credentials, other pods' secrets and the ability to start new containers outside Kubernetes.
  • High: /var/lib/containerd, /var/lib/docker, /var/log when writable, and /dev. They give access to other workloads' file layers and allow log tampering.
  • Moderate: read-only mounts of narrow paths such as /var/log/pods for a log shipper or a single configuration file for a static pod. Kubernetes itself lists read-only /var/log for log transfer as a typical legitimate use.

A quick filter for the critical set:

jq -r '.items[] | .metadata as $m | .spec.volumes[]? | select(.hostPath) | .hostPath.path as $p | select($p == "/" or ($p | test("^/(etc|root|proc|sys|dev)(/|$)|kubelet|containerd|crio|docker|/etc/kubernetes"))) | "\($m.namespace)/\($m.name) \($p)"' pods.json

Step 5: find namespaces without Pod Security labels

Pod Security Admission applies a level per namespace using labels in the form pod-security.kubernetes.io/<mode>=<level>, where the mode is enforce, audit or warn. Namespaces without an enforce label rely on whatever cluster default is configured, which is often privileged.

kubectl get namespaces --selector='!pod-security.kubernetes.io/enforce'

Then test what Baseline enforcement would reject, without changing anything. The Kubernetes documentation recommends a server-side dry run for exactly this purpose:

kubectl label --dry-run=server --overwrite ns --all pod-security.kubernetes.io/enforce=baseline

The warnings name each namespace and the pods that would violate the level. Compare that list with your Step 2 output; anything in one and not the other usually points to an exemption or a third-party admission policy you did not know about.

Step 6: check exemptions and other admission policy

Pod Security Admission exemptions can be configured by username, runtime class and namespace, and exempt requests skip enforce, audit and warn entirely. They live in the admission controller configuration on the API server, or are set by your managed provider, so ask the platform team for the file. Kubernetes cautions that exempting a controller's service account implicitly exempts anyone who can create the workload that controller manages. If you also run a policy engine, list its policies and exceptions too; the Kubernetes Admission Control Guide covers how those engines fit together.

Step 7: decide on each finding

For every owner (Deployment, DaemonSet, StatefulSet, Job or bare pod), record one of three decisions.

  • Remove: the setting is not needed. Common examples are application charts that set privileged: true as a shortcut, hostNetwork left over from early testing, and debug pods nobody deleted.
  • Reduce: the workload needs some host access, but less. Replace privileged mode with one named capability, make a hostPath read-only, narrow it from /var/log to /var/log/pods, or use a local PersistentVolume, which Kubernetes recommends over hostPath where possible.
  • Accept: the access is required, typically for CNI, CSI or node agents. Record the owner, the reason and a review date, and move the workload into a dedicated namespace that runs at the privileged level while every other namespace enforces Baseline or Restricted.

Where identity fits

A pod with host access is a privileged identity in two ways. Its own service account token is mounted into it, and through the node it can usually reach other identities: the kubelet's client credentials, tokens projected into other pods on the same node, and on cloud clusters the node's instance role through the metadata service. MITRE ATT&CK describes the escape path as T1611 Escape to Host and the metadata route as T1552.005 Cloud Instance Metadata API.

So the review does not end with the pod spec. For each accepted host-access workload:

  • Check what its service account can do. A node agent with a hostPath to the runtime socket and a service account that can read Secrets cluster-wide is a far worse finding than either alone. Use kubectl auth can-i --list --as=system:serviceaccount:<ns>:<sa>.
  • Give it its own service account. Shared accounts make it impossible to tell which workload used a credential.
  • Disable automatic token mounting where the agent does not call the API server. The Kubernetes Service Account Token Guide explains the options.
  • On cloud clusters, block pod access to the node metadata endpoint unless the agent needs it, and prefer workload identity over the node role.

Verify it worked

  • Re-export pods and rerun the Step 2 query. The only rows left should be the workloads you accepted, and each should match an entry in your findings sheet.
  • Rerun the namespace selector from Step 5. Every namespace should carry an enforce label, with privileged set only on the namespaces you deliberately reserved for system agents.
  • Try to create a test pod with hostPID: true in an ordinary application namespace using a non-admin identity. With Baseline enforced it should be rejected with a message naming the violated field.
  • Remember that enforce applies to pods, not to workload objects. Kubernetes applies audit and warn to Deployments and other templates, but a bad Deployment is accepted and only its pods are rejected. Check controller events and ReplicaSet status, not only the apply output.

Rollback and common errors

  • A system agent stopped working after you removed a setting. Restore the previous manifest from Git or Helm history, then reduce rather than remove. Log shippers commonly need read-only log paths; CNI agents commonly need hostNetwork and specific capabilities.
  • Pods fail with a "path does not exist" error after a change. The hostPath type field (such as Directory) makes the kubelet check the path. Nodes differ, so confirm the path on every node pool.
  • The dry run shows nothing but you know there are violations. The namespace may be exempt, or the cluster may run a version where the pods were admitted before labels existed. Check exemptions first.
  • Rejected pods after enforcing, but the Deployment looks healthy. This is the workload-versus-pod behaviour above. Look at kubectl get events -n <ns> for the FailedCreate reason.
  • Enforcing broke a namespace you did not expect. Remove the enforce label, keep audit and warn, and fix the workloads before trying again. Labels change immediately and are the safest rollback lever.

Hardening afterwards

  • Enforce Baseline on every namespace by default and Restricted on application namespaces where the workloads allow it. Pin the policy version with the enforce-version label if you want upgrades to be predictable.
  • Keep privileged namespaces few, named and owned by the platform team. Limit who can create pods in them through RBAC.
  • Block pods/ephemeralcontainers and pods/exec in privileged namespaces for everyone except break-glass roles, so debugging does not reopen the door.
  • Alert on host-access pod creation. The Kubernetes Audit Log Detection Guide shows how to watch create requests for privileged, hostPath and host namespace fields, and Pod Security Admission in audit mode adds annotations to audit events that make this simpler.
  • Add the Step 2 query to CI against rendered Helm and Kustomize output, so new host access is caught at review rather than in production.

Common failure patterns

  • Auditing Git, not the cluster. Operators, cloud add-ons and manual debugging create pods that never appear in a repository.
  • Checking only containers. Privileged init containers and ephemeral debug containers are missed.
  • Allow-listing paths without requiring read-only. Kubernetes warns that the restriction does not hold if the mount is writable.
  • Treating the runtime socket as a log path. A mounted runtime socket lets the pod start new containers on the node with any settings, outside admission control.
  • Exempting a controller service account. Anyone who can create Deployments then inherits the exemption.
  • Accepting a finding without an owner. Exceptions with no named owner and no review date become permanent.
  • Ignoring the node identity. Host access plus a broad node cloud role turns a cluster finding into a cloud account finding.

Practitioner checklist

  • Export all pods once and keep the snapshot as evidence.
  • Run the risky pod query across containers, init containers and ephemeral containers.
  • List every hostPath mount with its read-only or read-write mode.
  • Rank paths, starting with root, kubelet, Kubernetes configuration and runtime sockets.
  • List namespaces without a Pod Security enforce label and run a server-side dry run at Baseline.
  • Obtain and review Pod Security Admission exemptions and policy engine exceptions.
  • Record remove, reduce or accept for every owner, with a named owner and review date for each exception.
  • Check the RBAC rights and token mounting of every accepted host-access service account.
  • Enforce Baseline everywhere and Restricted where possible; reserve privileged namespaces for platform agents.
  • Alert on new host-access pods and repeat the audit monthly.

Standards and references

Related NHI Mgmt Group resources: How to audit Kubernetes cluster admin bindings · Kubernetes Admission Control Guide · Kubernetes Audit Log Detection Guide · Kubernetes Security Guide

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 18 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org