Summary
A privilege context bypass in containerd causes certain numeric User directives that overflow 32-bit parsing to be interpreted as usernames instead of UIDs.
When a crafted image maps this large numeric string to root in /etc/passwd, Kubernetes runAsNonRoot restrictions can be silently evaded and containers may run as UID 0.
Affected context
This vulnerability appears in Kubernetes environments using containerd as the runtime, where:
- Pod or container specifications rely on the
runAsNonRootsecurityContext to enforce non-root execution - Images specify a
Userdirective using a large numeric string that cannot be parsed as a 32-bit integer - The image is able to control
/etc/passwdcontent inside the container filesystem
Under these conditions, containerd misinterprets the large numeric value as a username and may resolve it to UID 0, undermining the expected non-root guarantees.
Exploit preconditions
- Attack surface: Kubernetes workloads scheduled onto nodes running vulnerable versions of containerd.
- Required access: Ability to supply or control the container image or its
Userdirective (e.g., as a workload author or via a compromised image registry). - Trigger point: Container start-up, when containerd resolves the configured
Userinto a runtime UID/GID. - Why exploitation is possible: The user resolution logic fails to consistently treat large numeric strings as invalid UIDs. When 32-bit parsing fails, the value is treated as a username and then mapped via
/etc/passwd, allowing an attacker-controlled mapping to root and bypass ofrunAsNonRoot.
Why this happens
The root cause is a flawed user identity resolution algorithm in containerd that mishandles numeric-looking User values that exceed 32-bit integer limits.
Instead of rejecting such values or consistently treating them as invalid numeric UIDs, the code falls back to interpreting them as usernames and consults /etc/passwd inside the image.
This behavior corresponds to CWE-269: Improper Privilege Management, because it allows untrusted workload configuration to undermine policy-enforced non-root execution and escalate to root within the container.
Potential impact
- Containers that appear to comply with
runAsNonRootcan actually run as UID 0. - Bypass of Kubernetes security policies that rely on non-root enforcement.
- Increased blast radius for container breakouts or in-container vulnerabilities due to elevated privileges.
- Violation of compliance expectations where workloads must not execute as root.
- Confusing or misleading audit and security posture assessments that assume non-root enforcement is effective.
General mitigation guidance
Mitigation strategies generally focus on hardening identity resolution and reducing trust in image-controlled user mappings:
- Ensure user resolution logic treats unparseable numeric
Uservalues as invalid and fails closed rather than falling back to username lookups. - Enforce consistent policy that numeric-looking
Userfields must resolve to valid non-root UIDs or be rejected outright. - Prefer runtime-level admission policies that validate the effective UID inside containers, not just the presence of
runAsNonRoot. - Isolate or restrict the ability of workloads to control
/etc/passwdor identity mapping files where feasible. - Apply least-privilege principles for container capabilities and filesystem permissions so that unexpected root execution has constrained impact.
How teams detect issues like this
Detection can leverage both configuration analysis and runtime observation:
- Use static checks or policy-as-code (e.g., admission controllers, OPA, Kyverno) to flag pod specs whose
Userdirectives use unusually large numeric values. - Add CI/CD validation for container images that examine
/etc/passwdfor suspicious mappings, such as non-standard usernames or numeric strings mapped to UID 0. - Employ runtime security tooling to monitor effective UIDs of containers labeled or expected to run as non-root, and alert when they start as root despite
runAsNonRoot. - During code review of container runtimes or orchestration tooling, scrutinize user/UID parsing logic for fallback behaviors, type overflows, or ambiguous interpretation of numeric fields.

