CVE-2024-40635

4.6 MEDIUM

📋 TL;DR

A vulnerability in containerd allows containers launched with UID/GID values exceeding 32-bit signed integer limits to overflow and run as root (UID 0) instead of the intended non-root user. This affects environments using containerd versions before 1.6.38, 1.7.27, or 2.0.4 where containers are configured to run as non-root users. The issue could lead to privilege escalation within container environments.

💻 Affected Systems

Products:
  • containerd
Versions: All versions before 1.6.38, 1.7.27, and 2.0.4
Operating Systems: Linux
Default Config Vulnerable: ✅ No
Notes: Only affects containers configured with User set to UID:GID values greater than 2147483647

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Container processes gain root privileges unexpectedly, potentially allowing container escape, host system compromise, or lateral movement within Kubernetes clusters.

🟠

Likely Case

Containers run with elevated privileges contrary to security policies, violating least-privilege principles and potentially exposing sensitive data or services.

🟢

If Mitigated

Containers run with intended user permissions, maintaining proper isolation and security boundaries as configured.

🌐 Internet-Facing: MEDIUM
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Requires ability to create or modify container configurations with specific UID/GID values

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.6.38, 1.7.27, or 2.0.4

Vendor Advisory: https://github.com/containerd/containerd/security/advisories/GHSA-265r-hfxg-fhmg

Restart Required: Yes

Instructions:

1. Stop all containers using containerd. 2. Update containerd to version 1.6.38, 1.7.27, or 2.0.4 using your package manager. 3. Restart containerd service. 4. Verify the update was successful.

🔧 Temporary Workarounds

Restrict container image sources

linux

Only allow trusted container images from verified registries

# Configure containerd to only pull from trusted registries
# Edit /etc/containerd/config.toml to restrict registries

Enforce UID/GID validation

linux

Implement admission controllers or policies to validate container UID/GID values

# Use Kubernetes PodSecurityPolicy or OPA/Gatekeeper to validate UID ranges
# Example: Ensure runAsUser < 2147483647

🧯 If You Can't Patch

  • Implement strict image scanning and validation to prevent containers with UID/GID > 2147483647
  • Use runtime security tools (Falco, Tracee) to detect containers running as root unexpectedly

🔍 How to Verify

Check if Vulnerable:

Check containerd version: containerd --version. If version is earlier than 1.6.38, 1.7.27, or 2.0.4, system is vulnerable.

Check Version:

containerd --version

Verify Fix Applied:

After update, run: containerd --version and confirm version is 1.6.38, 1.7.27, or 2.0.4 or later.

📡 Detection & Monitoring

Log Indicators:

  • Containers starting with UID 0 when configured with non-root user
  • Audit logs showing container user ID changes

Network Indicators:

  • Unexpected network connections from containers running as root

SIEM Query:

container.runtime=containerd AND container.user.uid=0 AND container.config.user EXISTS

🔗 References

📤 Share & Export