Lesson 12 of 14 · 12m
User Namespaces and Rootless
User namespaces remap container root to an unprivileged host UID, rootless daemons demote the daemon itself, and the same feature arms nf_tables bugs.
The namespace that unmakes root
CLONE_NEWUSER does the one thing no other namespace does: it changes what root means. A user namespace carries a UID map — container UID 0 can be host UID 100000 — and the kernel charges capabilities against the namespace that owns the resource, not against raw UID. Root inside a user namespace is root over that namespace's resources. It can mount cgroupfs, but the resulting CAP_SYS_ADMIN holds only inside its own silo. Escape the container and you land as an unprivileged host user with nothing.
This is the strongest namespace available, and for most of Docker's history nobody used it, because Docker ran the whole stack as root and never bothered to remap.
userns-remap
Docker's switch is a daemon option:
{"userns-remap": "default"}The daemon creates a dockremap user with a subuid/subgid range carved out of /etc/subuid and /etc/subgid, then maps every container's UID 0 into that range. A container breakout — including one that gains CAP_SYS_ADMIN and mounts things — lands as dockremap, a user who can do nothing. The tradeoffs are real: userns-remap conflicts with --pid=host and other host modes (UID semantics stop making sense across shared namespaces), host bind mounts map to awkward ownership, and enabling it on a daemon with existing containers means redeploying them. It is worth it precisely when the workloads are semi-trusted — shared CI runners, partner code, anything you didn't write.
Rootless mode: demote the daemon
The deeper version removes root from the daemon itself. Podman runs daemonless and unprivileged by design; Docker's rootless mode runs dockerd inside a user namespace. Two walls move at once: container escapes land unprivileged and daemon compromises land unprivileged — a docker.sock handed to a rootless daemon is no longer root on the host, because the daemon isn't root. The costs: rootless networking goes through slirp4netns/pasta userspace TCP stacks (no real host networking, some perf tax), binding ports below 1024 needs net.ipv4.ip_unprivileged_port_start adjusted, and cgroup limits only apply if the user has cgroup delegation configured.
sysbox-runc is the third option — a runc fork that always enables user namespaces and adds the missing pieces (emulated /proc, inner mounts) so Docker-in-Docker and systemd-in-container work inside the remap. It exists because plain userns breaks workloads that want to act root-ish; sysbox lets them act root-ish in a box that stays a box.
The sharp edge
Same mechanism, opposite direction: unprivileged user namespaces are also how attackers reach CAP_NET_ADMIN to arm the nf_tables bugs — CVE-2021-22555, CVE-2024-1086 — and how the GameOver(lay) OverlayFS escalations worked. The feature that remaps root is also the feature that creates capability holders out of thin air. This is a genuine tradeoff, not a paradox: userns confinement for containers you launch is good; unprivileged userns creation for arbitrary host users widens the kernel's reachable surface.
The controls are two sysctls: kernel.unprivileged_userns_clone=0 (Debian's knob) blocks unprivileged creation outright — at the cost of Chrome's sandbox and rootless tooling for normal users — and user.max_user_namespaces=<n> caps how many can exist. Ubuntu enabled unprivileged userns by default when those overlayfs bugs landed, which is why they hit so hard — since 23.10 Ubuntu restricts unprivileged userns creation through AppArmor, on by default.
What to actually do
- On hosts running semi-trusted containers, enable
userns-remapon dockerd — it converts "escape gains root" into "escape gains dockremap" for every configuration mistake you haven't found yet. - For untrusted build/exec work, prefer rootless Podman or rootless Docker: a daemon that can't be root can't hand out root.
- Decide unprivileged-userns policy per host: development machines leave it on for rootless workflows; shared compute nodes lock it down.
- If you run DinD-style workloads, look at sysbox before reaching for
--privileged— it exists to make that exact workload safe.
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.