Sudo Chroot Privilege Escalation via NSSwitch File Manipulation (CVE-2025-32463)
Attackers can exploit CVE-2025-32463, a privilege escalation vulnerability in `sudo` when used with `chroot`, by creating a malicious `nsswitch.conf` file and associated Name Service Switch (NSS) modules within a controlled chroot environment to trick `sudo` into loading attacker-controlled code, leading to root privileges on Linux systems.
CVE-2025-32463 describes a critical privilege escalation vulnerability affecting the sudo utility when used with the chroot command on Linux systems. This vulnerability allows an attacker to gain root privileges by manipulating the Name Service Switch (NSS) configuration. Specifically, a malicious actor stages a fake root filesystem (e.g., in /tmp/chroot), which includes a specially crafted nsswitch.conf file and attacker-controlled NSS modules (e.g., libnss_*.so). When sudo executes a command within this chroot environment, it can be tricked into resolving names using the attacker's malicious NSS configuration. This forces sudo to load the attacker's libraries, which then execute arbitrary code with root privileges. The technique relies on the creation of nsswitch.conf in non-standard locations by shell processes, serving as an early indicator of this exploitation attempt.
Attack Chain
- An attacker establishes initial access to a Linux system as a low-privileged user.
- The attacker creates a temporary directory structure to serve as a fake root filesystem, for example,
/tmp/chroot. - The attacker places a crafted
nsswitch.conffile within this fake root, typically at/tmp/chroot/etc/nsswitch.conf, by using a shell process. - The attacker also places malicious Name Service Switch (NSS) modules (e.g.,
libnss_*.so) into appropriate library paths within the fake root, such as/tmp/chroot/libor/tmp/chroot/usr/lib. - The attacker then executes a
sudo chrootcommand, directing it to use thechrootenvironment they've created (e.g.,sudo chroot /tmp/chroot). - During the execution of
sudo chroot, if name resolution is triggered,sudoattempts to load NSS modules from the chrooted environment, inadvertently loading the attacker's malicious modules. - The malicious NSS module executes arbitrary code with root privileges, leading to a complete system compromise and full privilege escalation.
Impact
Successful exploitation of CVE-2025-32463 results in complete privilege escalation to root on the affected Linux system. This grants the attacker full control over the compromised machine, enabling them to install backdoors, exfiltrate sensitive data, disrupt services, or launch further attacks. While specific victim numbers are not available, the widespread use of sudo and chroot means a broad range of Linux environments are potentially vulnerable if not patched. Organizations using sudo with chroot functionality are at high risk.
Recommendation
- Deploy the provided Sigma rule to your SIEM to detect suspicious
nsswitch.conffile creations outside standard paths. - Patch CVE-2025-32463 immediately by updating
sudoandglibcto the latest versions provided by your Linux distribution vendor. - Enable comprehensive file creation and process execution logging to capture
file.path,process.name, andevent.typeto activate the rules above. - Configure
sudoersto disallowchrootif not explicitly required, and enforceenv_reset,noexec, andsecure_pathpolicies. - Mount
/tmpand/var/tmpfilesystems withnoexec,nosuid, andnodevoptions to prevent execution of attacker-controlled libraries or binaries from user-writable temporary directories.
Detection coverage 1
Detects CVE-2025-32463 Exploitation - Suspicious NSSwitch File Creation
highDetects CVE-2025-32463 exploitation - suspicious creation of the `nsswitch.conf` file by a shell process outside of the regular `/etc/nsswitch.conf` path, which is an early indicator of an attempt to stage a fake root to coerce `sudo chroot` and hijack NSS resolution.
Detection queries are available on the platform. Get full rules →