Containers Sharing Host Namespaces

Pods share the node's process, network or IPC namespace, so their containers can see and interact with the node's processes and network traffic.

SeverityHigh
CVSS 3.17.9 CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:L Open in the calculator
CVSS 4.08.3 CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:L/VA:L/SC:H/SI:L/SA:L Open in the calculator
CWECWE-653: Improper Isolation or Compartmentalization
OWASP Top 10A06:2025 Insecure Design
MITRE ATT&CKT1611 Escape to Host, T1057 Process Discovery, T1040 Network Sniffing
CategorySecurity Misconfiguration

Description

Containers are normally isolated from the node through Linux namespaces. Setting hostPID: true, hostNetwork: true or hostIPC: true in a pod specification, or --pid=host, --network=host or --ipc=host with Docker, removes that isolation for the corresponding resource, so the pod shares it with the node itself.

In the node's process namespace, a container can see every process on the node with its command line and, with enough privileges, read process memory and environments or enter other processes' namespaces, so an attacker who compromises it can collect credentials and other secrets from the command lines and environments of the node's processes. Combined with privileged mode or added capabilities, the host process namespace allows a direct escape to the node, for example by entering the namespaces of a host process with nsenter.

In the node's network namespace, a container uses the node's interfaces directly. It can reach services listening only on the node's loopback address, as well as cloud instance metadata services that may be blocked for ordinary pods; if it holds the NET_RAW capability, which Docker and containerd grant by default, it can capture the node's traffic, including unencrypted traffic to and from other pods on the node; and it may not be subject to network policies, depending on the network plugin. The node's IPC namespace exposes shared memory used by processes on the node.

The settings can be found in pod specifications or with configuration scanners. They are common on node agents for monitoring, logging and networking, where they may be justified, and are rarely needed by application workloads.

Remediation

  • Remove hostPID, hostNetwork and hostIPC from every workload that does not need them; application workloads almost never do.
  • Where a workload needs to receive traffic on the node's address, publish it through a Service, for example of type NodePort or LoadBalancer, instead of using the host network.
  • For node agents that genuinely need host namespaces, document the exception, run them in a dedicated namespace that few people can deploy to, do not combine host namespaces with privileged mode or added capabilities, and drop NET_RAW where packet capture is not needed.
  • Enforce the Baseline or Restricted Pod Security Standard, both of which forbid host namespaces, on all other namespaces.

Confirm the fix by listing pods that set any of the three fields to true and checking that only documented exceptions remain.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Containers and Kubernetes Findings

Every Containers and Kubernetes finding