Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1359 CNY

100%

CVE-2025-32463 PoC — Sudo 安全漏洞

Source
Associated Vulnerability
Title: Sudo 安全漏洞 (CVE-2025-32463)
Description:Sudo before 1.9.17p1 allows local users to obtain root access because /etc/nsswitch.conf from a user-controlled directory is used with the --chroot option.
Description
# cve-2025-32463 - Local Privilege Escalation to Root via Sudo chroot in Linux
Readme
# cve-2025-32463

### chroot

`sudo chroot <dir name> <command>`

在选定的dir name中执行命令command

### 形成原理

这个问题是在 sudo v1.9.14引入的,这个版本升级了chroot特性被使用时的匹配处理代码

![](./image/sudo1-9-16.png)

这一新的改动,使得执行命令`chroot`匹配前改变根目录的id。具体函数规定在`plugins/sudoers/pivot.c`中。这个文件(现已被删除)中定义了`pivot_root()`和`unpivot_root()`函数用于处理chroot的匹配逻辑。调用这两个函数,将触发名称服务切换(NSS)操作,导致系统从不受信任的环境中加载` /etc/nsswitch.conf `配置文件(因为chroot已经改变到当前根目录的id了)。该配置文件包含指令,指示系统如何检索有关用户、组和主机的信息,其中可以列出多个来源,并按顺序搜索,直到找到匹配项。

由于`/etc/nsswitch.conf` 包含很多行条目,搜寻信息的时候会根据行条目的顺序进行查找。**漏洞重要的点在于**:对文件`nsswitch.conf`中进行源查找的时候,源名称会被用作共享对象路径的一部分,例如:`ldap`源转换为了`libnss_ldap.so`。当NSS函数使用ldap源的时候,就会加载该库。

对于攻击者,调用这`pivot_root()`和`unpivot_root()`会触发NSS操作。所以攻击者就可以在可控路径下构造chroot根目录,其中包含`/etc/nsswitch.conf`文件以及恶意库文件。名称服务可以指向自定义的NSS模块,在这个模块中可以伪造恶意的共享库。

当攻击者运行`sudo -R <fake_root_dir> <command>`尝试以chroot模式执行命令,sudo尚未完全验证权限就调用了系统的NSS去解析用户/组信息,读取伪造的`/etc/nsswitch.conf`,指示恶意NSS模块。这个时候sudo进程已切换到了伪根目录,并且仍然以root权限运行,因此会以root权限加载并且执行攻击者的恶意共享库代码。

### 复现步骤
```bash
git clone https://github.com/Spongebob-369/cve-2025-32463.git

cd cve-2025-32463
chmod +x run.sh
./run.sh

# after entering the contain Ubuntu

./sudo-chroot.sh
id
```

File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →