Lesson 6 of 14 · 11m
--privileged Means Host
Privileged mode disables capabilities, seccomp, MAC, and the device filter all at once, making escape a menu instead of an exploit.
What --privileged actually flips
docker run --privileged is not a stronger container. It is the isolation switches turned off in one flag:
- All capabilities added. The bounding set goes from fourteen to everything —
CAP_SYS_ADMIN,CAP_SYS_MODULE,CAP_SYS_PTRACE,CAP_DAC_READ_SEARCH,CAP_SYS_RAWIO,CAP_NET_ADMIN,CAP_SYS_BOOT. - Seccomp off. The syscall allowlist is replaced with
unconfined.mount,bpf,init_module,keyctl— all reachable. - AppArmor and SELinux off. Docker's
docker-defaultAppArmor profile and any SELinux confinement drop away. - All host devices. The cgroup device filter opens wide — every device node the host knows can be created and opened.
/devinside the container can be populated with real nodes for the host's block devices,kvm,/dev/memwhere it exists. - Writable
/sysand/proc/sys. Sysctl knobs and kernel filesystems become writable.
The mental model to attack is "privileged is like sudo inside the container." Sudo changes who the process is. --privileged changes what the kernel enforces. A privileged container is host code with extra bookkeeping.
Three exits, pick one
Given a privileged container, the escapes are a menu:
Mount the host. The device filter is open, so the host's disks exist:
mknod /dev/sda b 8 0 && mount /dev/sda /mntThe release_agent trick. CAP_SYS_ADMIN mounts cgroupfs; on a cgroup v1 host, write a path to release_agent, set notify_on_release on a cgroup you made, run a task, let it exit — the kernel executes your binary on the host. This is the CVE-2022-0492 primitive and the core of Azurescape, where Unit 42 crossed from a customer container to the shared ACI node in September 2021. The kernel fix (writing release_agent requires CAP_SYS_ADMIN in the init user namespace) closes the user-namespace route — it does nothing for a privileged container, which holds real CAP_SYS_ADMIN.
A kernel module or BPF program. CAP_SYS_MODULE + init_module, or bpf(2) with the syscall unblocked. Either is arbitrary host code in ring 0.
Notice the shape: none of these are clever. Privileged mode is not an escape that requires finding; it is a container that was never closed.
Why the flag exists at all
The honest reasons are narrow. Docker-in-Docker CI builders needed to mount overlay filesystems and manage inner cgroupfs — the classic DinD justification. GPU and device workloads want specific /dev nodes. Some storage daemons genuinely mount filesystems. Kubernetes carries the same flag as securityContext.privileged: true, and plenty of daemonset YAML in the wild sets it because an author didn't want to enumerate capabilities.
The wrong reasons dominate: "the app needed to bind a port" (that's NET_BIND_SERVICE), "it needed to write somewhere" (a volume), "it wouldn't start otherwise" (find the denied syscall or missing cap, don't remove all of them).
The debugging recipe for "won't start unprivileged" is short: run it with seccomp logging or strace, look at the EPERM/EACCES, identify the one syscall or capability, and grant that. A storage daemon wanting mount needs SYS_ADMIN alone — still dangerous, but one dangerous bit with a reason attached beats forty bits with none. If the workload's requirement list grows past two or three capabilities, that is the workload telling you it isn't a container workload — it wants a host agent, a VM, or sysbox.
What to actually do
Never run untrusted code privileged — under that constraint the flag is just remote code execution on your node with extra YAML. When a workload legitimately needs a slice, grant the slice: --cap-add=SYS_ADMIN, --device=/dev/kvm, a specific bind mount. Audit what exists with docker inspect --format '{{.HostConfig.Privileged}}' across running containers, and grep manifests for privileged: true. If you find one, the follow-up question is not "is this safe" but "which capability did they actually need."
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.