Lesson 8 of 14 · 14m
Shared Namespaces and Bad Mounts
--pid=host, --network=host, hostPath mounts, and writable /proc or cgroupfs each delete a specific wall, including the loopback-is-private assumption.
Host modes delete the boundary
Each namespace flag is a wall built by clone(2). Docker ships flags that build no wall at all: --pid=host, --network=host, --ipc=host. Kubernetes ships the same ones spelled hostPID, hostNetwork, hostIPC. Setting one does not weaken isolation; it means that namespace was never created — the container's /proc/<pid>/ns/* links have the host's inode numbers, provably, with readlink.
--pid=host hands the container the host's process table. /proc/<pid>/cmdline shows every command line on the node; /proc/<pid>/environ shows environment variables — the place databases URLs and API tokens live. Processes run as different users, but a root-in-container reading a same-user process's environ succeeds, and a lot of daemons run as root. Add CAP_SYS_PTRACE and it's attach-and-inject into arbitrary host processes. The legitimate uses are monitoring agents — node-exporter-style tools that genuinely need host procfs — and that legitimacy is why the flag survives.
--network=host merges the stacks. The container binds any port on any interface and reaches every service bound to loopback. It also changes sniffing scope: it sees the host's interfaces and, with NET_RAW — which the default capability set includes — can craft raw packets on the node's segment. And it was the precondition for CVE-2020-15257, the containerd-shim abstract-socket bug: the sockets lived in the host net namespace, so host-net containers could reach them without any mount at all.
--ipc=host shares SysV shared memory and message queues. Less glamorous, real anyway: a container reading host shm segments reads whatever processes put there.
The mounts that are doors
Bind mounts and hostPath are holes drilled on purpose — the question is which ones become doors:
-v /:/hostorhostPath: "/". Full stop, the host filesystem is inside. This is the "why bother with exploits" configuration./procmounted writable./proc/sys/kernel/core_patternaccepts a|/path/to/scripthandler — the kernel runs that script as root when a process core-dumps. Write it, crash something trivial, collect host execution. A documented escape primitive that requires nothing but the mount./sys/fs/cgroupwritable. The release_agent chain again — writable cgroupfs plus any task you can spawn and kill.- Kubelet credentials.
hostPathonto/var/lib/kubelet/pkior the kubelet config leaks node identity: the kubelet's client certs authenticate to the API server as the node, and what a node identity can do escalates further — Siloscape demonstrated CSR-based privilege escalation on managed clusters. mountPropagation: Bidirectionalon a volume. Mounts created inside the container propagate to the host's tree — you canmounta tmpfs over a host path, or leave host-visible artifacts, by mounting into a bidirectional mount. Almost nothing needs it; it exists for CSI driver use cases, not applications.
The loopback trap, one more time
It bears repeating because it is the most exploited non-exploit: --network=host plus "the service only listens on localhost" equals no authentication. Prometheus exporters, Redis, Docker stats endpoints, local admin consoles — every loopback-bound service becomes reachable from every host-network container. Audits find this combination weekly. If the service requires "same machine" semantics, the correct primitive is a Unix socket with file permissions or mTLS, not a TCP port on 127.0.0.1.
What to actually do
Inventory by flag, not by vibes:
docker inspect --format '{{.HostConfig.PidMode}} {{.HostConfig.NetworkMode}} {{.HostConfig.IpcMode}}' <ctr>
kubectl get pods -o json | jq '.. | .hostPID?, .hostNetwork?, .hostIPC?, .hostPath?'Every host mode is a wall that was never built; every hostPath is a hole someone drilled. For host-network monitoring agents, prefer the minimal shape — read-only procfs mount, dropped caps, no-write tmpfs — over the full stack. And treat "needed host networking" as a design smell worth one hard question: which specific thing does it reach that a sidecar or a real interface couldn't?
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
A 257-Byte Password Is the Key: Inside the OpenSSH musl Bypass
CVE-2026-123158 lets an attacker log into a locked account on musl-based systems like Alpine by sending a password nobody set. The trigger is one number, 257, and the reason is a C library returning a single asterisk. I reproduced the exact boundary against musl 1.2.4 and read the fix.
A Password-Free Path to Root: Inside the macOS Screen Sharing Vulnerability Now Under Attack
A logic bug in screensharingd let attackers skip authentication entirely and land as root — no password required. Here's how it was found, patched, reverse-engineered, and finally weaponized.
CVE-2026-31431 "Copy Fail": How a 9-Year-Old Linux Kernel Bug Gives Any Local User Root in 732 Bytes
CVE-2026-31431 chains AF_ALG, splice(), and authencesn's ESN scratch write into a deterministic 4-byte page cache write that gives an unprivileged local user root. Full technical breakdown, exploit mechanics, detection, mitigation, and patch status per distro.
BlueHammer: The Unpatched Windows Zero-Day That Weaponizes Microsoft Defender Against Your Own System
BlueHammer is an unpatched, publicly released Windows local privilege escalation exploit that chains Microsoft Defender's update workflow, Volume Shadow Copy, Cloud Files callbacks, and opportunistic locks to reach NT AUTHORITY\SYSTEM from a standard user account.