yangh-beep/CVE-2026-31431-C

GitHub: yangh-beep/CVE-2026-31431-C

Stars: 0 | Forks: 0

# copy-fail CVE-2026-31431(Copy Fail)C 语言 PoC,逻辑对齐 [theori-io/copy-fail-CVE-2026-31431](https://github.com/theori-io/copy-fail-CVE-2026-31431) 原版 Python exploit。 **仅用于已授权的安全研究与实验环境。禁止在未授权系统上使用。** ## 原理简述 Linux `AF_ALG` 中 `authencesn(hmac(sha256),cbc(aes))` 在 `splice` + AEAD 路径下,可将 AAD 里 4 字节写入目标文件**页缓存**(磁盘内容不变)。 本仓库 exploit 行为与原版一致: 1. 对 `/usr/bin/su` 页缓存逐 4 字节写入 zlib 解压后的微型 ELF 2. 执行 `su`,由被篡改的页缓存加载假 `su`,通常**无需密码**即可获得 root shell ## 目录结构 copy-fail/ ├── include/ │ ├── copy_fail.h │ └── su_payload_zlib.h ├── src/ │ ├── alg.c # AF_ALG / splice 原语 │ ├── util.c # 前置检查 │ ├── test_main.c # 漏洞检测 │ └── exploit_main.c # 提权 ├── Makefile └── README.md ## 依赖 Ubuntu / Debian: sudo apt install build-essential zlib1g-dev ## 编译 cd copy-fail make 生成: | 产物 | 说明 | |------|------| | `bin/copy-fail-test` | 漏洞检测(临时 sentinel 文件,不修改系统文件) | | `bin/copy-fail-exploit` | 提权(修改 `/usr/bin/su` 页缓存后 `exec su`) | ### 静态编译(拷到 glibc 较旧机器) 在高版本系统上编译后,若出现 `GLIBC_2.34` / `GLIBC_2.38 not found`,在**编译机**执行: make static 将 `bin/copy-fail-test`、`bin/copy-fail-exploit` 拷到目标机运行。也可在**目标机**上对源码执行 `make`(动态链接,体积更小)。 ## 使用 ### 检测 ./bin/copy-fail-test echo $? | 退出码 | 含义 | |--------|------| | 0 | 未表现出漏洞特征 / 前置条件不满足 | | 2 | 存在漏洞特征 | | 1 | 测试过程出错 | ### 提权 ./bin/copy-fail-exploit id 无输出为正常设计;成功则进入 root shell。失败时 `echo $?` 一般为 `1`。 ## 前置条件 - 内核可创建 `AF_ALG` socket - 可 `bind` 算法 `authencesn(hmac(sha256),cbc(aes))` - 对 `/usr/bin/su` 有读权限 - `splice` 可写入 AF_ALG socket 若检测器提示 `cannot be instantiated (No such file or directory)`: grep -r algif_aead /etc/modprobe.d/ sudo modprobe algif_aead grep authencesn /proc/crypto 部分发行版通过 modprobe 禁用 `algif_aead`(如 Ubuntu USN 缓解),需在有 root 的实验机上解除后再测。 ## 清理 提权测试后(root shell 中)可丢弃页缓存污染: echo 3 > /proc/sys/vm/drop_caches 或重启虚拟机。 ## 参考 - [CVE-2026-31431](https://copy.fail/) - [theori-io/copy-fail-CVE-2026-31431](https://github.com/theori-io/copy-fail-CVE-2026-31431)
标签:客户端加密