Hardening off, namespaces on: container escape and CVE-2022-0492
A container escape is rarely about breaking a sandbox. It is about a capability or a mount the container should never have held. CVE-2022-0492 let a container without CAP_SYS_ADMIN obtain it inside new namespaces and reach root on the host through the cgroups release_agent.
By Ahmed PingerPublished
8 min read21 views
A container is a normal process that the kernel has been talked into isolating with namespaces, cgroups, capabilities and a seccomp filter. Nothing about it is a wall. So a container escape is almost never "the attacker broke out of the sandbox." It is "the container was handed a capability or a mount it never needed, and that capability reaches the host."
That reframing decides where you look. Draw one line before anything else:
- The privileged container. Started with
--privilegedor the equivalent, it holds every capability, sees host devices, and often drops the seccomp filter. Escape from here is not clever, it is expected. This is a policy failure. - The merely over-capable container. It looks constrained. It runs as a non-root user, it is not privileged, but it holds one dangerous capability, or one host path, or shares one host namespace. Escape from here is the interesting case, because the manifest looks reasonable at a glance.
CVE-2022-0492 is a close example of the second kind: a container that looks constrained, and root on the host.
Why "privileged" is the wrong thing to check
The word privileged is a summary, and summaries hide the parts that matter. What actually governs escape is the specific set of Linux capabilities the container holds, the mounts it can see, and the namespaces it shares. A container can be non-privileged and still hold CAP_SYS_ADMIN, which is close to root in effect. It can share the host PID namespace, or mount a host path, or expose a writable /sys. Each of those is a plank, and escapes are built from a plank or two, not from the privileged flag alone.
CAP_SYS_ADMIN is the one to fear, because it is the kitchen-sink capability: mounting filesystems, manipulating namespaces, and the cgroup operation at the heart of the CVE below. Grant it "so the container can mount something once" and you have granted most of the way to the host.
The real one: CVE-2022-0492
The cgroups v1 subsystem has a feature called release_agent: a program the kernel runs, on the host and as root, when the last process leaves a cgroup. Writing the path of that program is meant to be a privileged operation. The Red Hat advisory describes what went wrong:
This flaw, under certain circumstances, allows the use of the cgroups v1 release_agent feature to escalate privileges and bypass the namespace isolation unexpectedly.
That is CVE-2022-0492 in kernel/cgroup/cgroup-v1.c. The cgroup_release_agent_write handler did not verify that the process writing release_agent was privileged with respect to the host, so a process able to create its own user and cgroup namespaces, and so obtain CAP_SYS_ADMIN inside them, could mount a cgroup v1 hierarchy and set the release agent to a script of its choosing. When the cgroup emptied, the kernel ran that script on the host as root. Red Hat scored it 7.0 and classed it as a missing authorization check (CWE-862); the fix was a single commit adding the privilege check that was absent. CISA added CVE-2022-0492 to the Known Exploited Vulnerabilities catalog on 2026-06-02.
The precondition is the whole story. Default hardening in most container environments, such as seccomp, AppArmor or SELinux, blocks the path. Remove that hardening on a host that allows unprivileged user namespaces, and the same kernel bug becomes a host takeover. The vulnerability was in the kernel; the exposure was in the container configuration.
The working escape is public and is not reproduced here. A defender does not need the exploit to defend against it. A defender needs to know the precondition (a container that can write release_agent) and to be able to see it, which the lab below does without ever running the exploit.
A lab you can build without Docker
Build this on a throwaway Linux VM. You do not need Docker or Docker Desktop; rootless Podman is enough, and it is a single package on most distributions. The point of the lab is to inspect the escape surface from inside a container, not to run an escape.
# On a disposable Linux VM, as a normal user. Rootless, no daemon.
podman run --rm -it --cap-add=SYS_ADMIN alpine sh
Inside that shell, enumerate what you were handed:
# What capabilities does this process actually hold?
grep CapEff /proc/self/status # decode with: capsh --decode=<hex>
apk add -q libcap-utils; capsh --print # human-readable list
# Is a cgroup v1 hierarchy mounted and writable, and does release_agent exist?
cat /proc/filesystems | grep cgroup
ls -l /sys/fs/cgroup # v1 shows named controllers; v2 shows a unified tree
find /sys/fs/cgroup -name release_agent 2>/dev/null
Two questions answer whether the classic release_agent escape precondition exists: does the container hold CAP_SYS_ADMIN, and can it reach a writable cgroup v1 release_agent file. Run the same enumeration in a container started without --cap-add=SYS_ADMIN and the capability disappears from CapEff. Run it on a cgroups v2 host and there is no release_agent at all, because v2 removed it. That contrast is the defensive lesson: the escape needs a specific capability and a specific legacy interface, and both are things you control.
To connect it to Kubernetes without leaving the VM, the equivalent smell in a manifest is a securityContext that adds SYS_ADMIN or sets privileged: true. The enumeration above is what that manifest buys an attacker who lands in the pod.
Finding it in manifests
The over-capable container is visible in configuration long before it is visible at runtime.
# Kubernetes pod specs
grep -rniE "privileged:\s*true|allowPrivilegeEscalation:\s*true" .
grep -rniE "add:\s*\[?.*(SYS_ADMIN|DAC_READ_SEARCH|SYS_PTRACE|SYS_MODULE)" .
grep -rniE "hostPID:\s*true|hostNetwork:\s*true|hostPath" .
# Compose and Podman/Docker run flags in scripts and CI
grep -rniE "privileged|--cap-add|--pid=host|--security-opt.*seccomp[:=]unconfined|/var/run/docker.sock" .
The single highest-value grep is for SYS_ADMIN in a capability-add list, and the second is for a mounted container socket (docker.sock), which is a different but equally direct route to the host. A container that both drops ALL and adds back only NET_BIND_SERVICE is doing it right; a container that adds SYS_ADMIN needs a written justification or it should not ship.
Fixing it
Drop all capabilities, add back the few you need. Start from capabilities: { drop: ["ALL"] } and add only the specific capabilities a workload requires. Most web workloads need none. This alone removes the classic CAP_SYS_ADMIN route to release_agent for the vast majority of containers.
Do not run privileged, and block privilege escalation. Set allowPrivilegeEscalation: false, privileged: false, run as a non-root user, and make the root filesystem read-only. Enforce the first three cluster-wide with the restricted Pod Security Standard rather than trusting each author.
Keep the default seccomp profile. The default profile blocks syscalls that many escapes rely on. seccomp: unconfined throws that away; treat it as a red flag in review.
Prefer cgroups v2 and keep the kernel patched. cgroups v2 removed the release_agent mechanism entirely, so this specific escape does not exist there. Patch the kernel regardless, because the next release-agent-shaped bug will land on the same containers that were over-capable this time.
Use user namespaces. Mapping container root to an unprivileged host user means a capability held inside the container is not the same capability on the host, which blunts a whole category of escapes.
Detecting it
Runtime detection for this class watches the host, not the container, because the escape's payoff happens on the host.
- Writes to
release_agent. A write to any.../cgroup/.../release_agentpath from a container process is almost never legitimate. This is the single most specific signal for CVE-2022-0492 and its relatives. - Unexpected mounts. A container process calling
mount, especially mounting cgroupfs or a host path, is worth an alert when the workload has no reason to mount anything. - Host processes with a container parent. A process running on the host whose cgroup or parentage traces back to a container is the shape of a successful escape. Runtime tools such as the Falco ruleset express exactly this.
- Capability inventory as posture, not just detection. Periodically enumerate the capabilities of running containers and diff against policy. A container that acquired
CAP_SYS_ADMINsince last week is a finding before anything has been exploited.
Take this away
Privileged is not a checkbox, it is a spectrum, and a single capability can sit at the far end of it. CVE-2022-0492 turned a container that looked otherwise reasonable into root on the host through a legacy cgroup feature, once seccomp, AppArmor or SELinux were out of the way. Enumerate the capabilities and mounts your containers actually hold, drop everything you cannot justify, move to cgroups v2, and watch the host for the writes that only an escape would make. The escape is in the configuration long before it is in the kernel.
Further reading
- Red Hat: CVE-2022-0492: the vendor description, CVSS and affected packages
- Red Hat Bugzilla 2051505: the tracking bug and analysis
- Kernel fix commit 24f60085: the added privilege check
- CISA Known Exploited Vulnerabilities Catalog: CVE-2022-0492, added 2026-06-02
- Linux capabilities(7) man page: what each capability actually grants
- Kubernetes docs: user namespaces for pods: the user-namespace mitigation
Was this useful?
Get the next write-up by email
New technical write-ups by email when we publish. No sales sequence, and every email has an unsubscribe link.
Prefer a feed? RSS. How we handle your address: privacy notice.
Comments
Loading comments…