sroman0/explotability_analysis_ebpf

GitHub: sroman0/explotability_analysis_ebpf

针对 Linux eBPF verifier 的多个内核 CVE 进行漏洞利用性分析与本地权限提升研究,提供 PoC、exploit 原语及 Buildroot/QEMU 复现环境。

Stars: 1 | Forks: 0

# eBPF Verifier 漏洞利用研究 — s344024 Romano Simone 安全验证与测试(SVT)课程的研究项目 — 针对 Linux 内核中 eBPF verifier 漏洞的分析与漏洞利用开发。 主要重点是识别 `kernel/bpf/verifier.c` 中未修复或未被利用的 CVE, 编写概念验证(PoC),并开发适用于本地权限提升(LPE)的内存读写原语。 ## 项目结构 ``` s344024_Romano_Simone/ │ ├── test/ ← Buildroot-based build & test environment │ ├── build.sh ← Interactive build script (CVE + kernel selection) │ ├── buildroot/ ← Buildroot source tree │ ├── configs/ ← Shared/base buildroot configs │ ├── patches/ ← Per-kernel patch sets (linux-4.x ... 5.9.x) │ ├── linux-6.8/kernel/bpf/ ← Reference verifier source for diff/analysis │ └── CVEs/ ← One folder per CVE under test │ ├── CVE-2023-39191/ │ │ ├── configs/ ← Per-kernel buildroot + kernel configs │ │ │ ├── v6.0/ │ │ │ └── v6.1/ │ │ ├── exploit_overlay/ │ │ └── src/ │ ├── CVE-2024-42072/ │ │ ├── configs/ │ │ ├── exploit_overlay/ │ │ └── src/ │ ├── CVE-2024-43838/ │ │ ├── configs/ │ │ ├── exploit_overlay/ │ │ └── src/ │ ├── CVE-2024-45020/ │ │ ├── configs/ │ │ ├── exploit_overlay/ │ │ └── src/ │ └── CVE-2024-58100/ │ ├── configs/ │ ├── exploit_overlay/ │ └── src/ │ ├── exploits/ ← Standalone exploit sources (outside Buildroot flow) │ ├── CVE-2023-39191/src/ ← poc.c, exploit.c │ ├── CVE-2024-42072/src/ │ ├── CVE-2024-45020/src/ │ └── CVE-2024-58100/src/ │ ├── report/ ← LaTeX report │ ├── main.tex │ ├── compile.sh │ ├── src/ ← Per-CVE chapter sources │ │ ├── CVE-2023-39191.tex │ │ ├── CVE-2024-42072.tex │ │ ├── CVE-2024-45020.tex │ │ └── CVE-2024-58100.tex │ ├── img/ │ ├── out/ ← Build artifacts (aux, log, ...) │ └── SVT_report.pdf ← Compiled PDF │ └── presentation/ ← LaTeX slides ├── main.tex ├── compile.sh ├── img/ ├── out/ └── SVT_presentation.pdf ← Compiled PDF ``` ## CVE | CVE | 内核版本范围 | 漏洞类型 | 内存原语 | LPE 状态 | |-----|-------------|-----------|-----------------|------------| | CVE-2023-39191 | ≤ 6.1.19 / ≤ 6.2.6 | Dynptr 类型混淆(通过 BPF stack 上重叠的 dynptr 导致 OOB) | 通过损坏的 dynptr 大小实现任意 OOB 读写 | 完整 LPE(自适应校准 + cred spray) | | CVE-2024-42072 | < 6.10.2 | Verifier 寄存器状态在 subprog 调用间泄漏 | OOB 读取原语 | 原语已确认,LPE 正在进行中 | | CVE-2024-45020 | < 6.11 | 对 stack 上分配的 dynptr 进行错误的边界检查 | 潜在的 OOB 读写 | PoC 已确认,漏洞利用分析进行中 | | CVE-2024-58100 | 5.6 – 6.6.89 / 6.7 – 6.12.24 | Verifier 忽略了通过 GLOBAL subprog 传播的 `changes_pkt_data` → 在执行 `bpf_skb_change_head` 后产生过期的 `PTR_TO_PACKET` | 在已释放的 `kmalloc-1024` slab 上进行 UAF 读写 | UAF 读写已确认,完整 LPE(篡改了 modprobe_path) | ## 测试环境 本项目使用基于 Buildroot 的 QEMU 环境。`test/build.sh` 负责内核 选择、配置准备、遗留选项剥离以及构建编排。 ``` cd test/ ./build.sh # Interactively select CVE + kernel, then build ``` 构建完成后,使用以下命令启动 QEMU: ``` cd buildroot/ output/images/start-qemu.sh --serial-only -- -m 9216 ``` | 虚拟机详情 | 值 | |-----------|-------| | Rootfs | Buildroot 最小化镜像 | | Kernel | 每个 CVE 独立对应,可在构建脚本中选择 | | Virtualization | QEMU(无需 KVM) | | Login | `root`(无密码) | | BPF | 已启用,允许非特权 BPF | | KASLR / RANDOMIZE_MEMORY | 禁用(为了保证漏洞利用的可复现性) | | 二进制文件分发 | 通过 Buildroot overlay → 发送至虚拟机中的 `/root/` 目录 | ## 构建与运行 ### CVE-2023-39191 — Dynptr 类型混淆 LPE ``` # 构建适用于 kernel 5.19 的 Buildroot 镜像(存在漏洞) cd test/ ./build.sh # select CVE-2023-39191, kernel v5.19 # 启动具有 9 GB RAM 的 VM cd buildroot/ output/images/start-qemu.sh --serial-only -- -m 9216 # 在 VM 内部: /root/poc # Verify OOB R/W primitive /home/user/exploit # Full LPE → creates /tmp/rootsh /tmp/rootsh # Spawn root shell ``` ### CVE-2024-42072 ``` cd test/ ./build.sh # select CVE-2024-42072 cd buildroot/ output/images/start-qemu.sh --serial-only # 在 VM 内部: /root/poc # OOB read primitive demo /root/exploit # Exploitation attempt ``` ### CVE-2024-45020 ``` cd test/ ./build.sh # select CVE-2024-45020 cd buildroot/ output/images/start-qemu.sh --serial-only # 在 VM 内部: /root/poc # Dynptr OOB trigger /root/exploit # Exploitation attempt ``` ### CVE-2024-58100 — 过期的 PTR_TO_PACKET UAF ``` cd test/ ./build.sh # select CVE-2024-58100, kernel v6.12.24 cd buildroot/ output/images/start-qemu.sh -- -smp 4 # 在 VM 内部(以 user 身份登录,uid=1000): /home/user/poc # Verifier-accept demo (stale PTR_TO_PACKET load) /home/user/exploit # UAF R/W primitive + PE attempt via pipe_buffer.ops ``` ## 报告 完整的技术报告(LaTeX + PDF)位于 `report/` 目录下。内容涵盖: - 从 eBPF verifier 漏洞类型中筛选 CVE 的方法论 - 对每个 CVE 的技术分析(补丁对比、根本原因、漏洞利用路径) - 漏洞利用设计决策及失败的方法尝试 - 结果与结论 都灵理工大学 — 网络安全(SVT)— 2025/2026 学年
标签:Docker镜像, Linux内核, Web报告查看器, 安全测试环境, 安全渗透, 客户端加密, 应用安全, 情报收集, 本地提权, 漏洞研究, 身份验证强制