Kubernetes workload shares the host PID namespace

Using hostPID shares the node’s process namespace with a container and weakens isolation.

Description

Remove hostPID or set it to false unless the Pod needs to observe node processes. With true, processes on the node and in other workloads may be visible.

Potential impact

Command arguments can contain sensitive information. Sending signals or tracing another process requires additional permissions determined by the user ID and Linux capabilities.

Remediation

Limit host PID access to approved diagnostic or operations tools and the people who may use them. Check the deployed Pod’s hostPID, hostIPC, hostNetwork, privileged mode and additional capabilities.

Examples

Set the example’s image and command for the intended tool.

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: security-context-demo
spec:
  hostPID: true
  containers:
    - name: sec-ctx-demo
      image: busybox

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: security-context-demo
spec:
  hostPID: false
  containers:
    - name: sec-ctx-demo
      image: busybox

To disable host PID sharing as shown, roll out new Pods from the updated workload template or replace a standalone Pod. Manage permissions on mounted files separately.

References