0xFuffM3/CVE-2026-31431-CopyFail
GitHub: 0xFuffM3/CVE-2026-31431-CopyFail
针对 CVE-2026-31431 Linux 内核页缓存损坏本地提权漏洞的完整研究仓库,包含 PoC 利用代码、检测规则、缓解方案及可复现的实验环境。
Stars: 0 | Forks: 0
```
██████╗ ██████╗ ██████╗ ██╗ ██╗ ███████╗ █████╗ ██╗██╗
██╔════╝██╔═══██╗██╔══██╗╚██╗ ██╔╝ ██╔════╝██╔══██╗██║██║
██║ ██║ ██║██████╔╝ ╚████╔╝ █████╗ ███████║██║██║
██║ ██║ ██║██╔═══╝ ╚██╔╝ ██╔══╝ ██╔══██║██║██║
╚██████╗╚██████╔╝██║ ██║ ██║ ██║ ██║██║███████╗
╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝
```
# CVE-2026-31431 — "Copy Fail"
### 通过 `algif_aead` 页缓存损坏实现 Linux 内核本地提权
[](https://nvd.nist.gov/vuln/detail/CVE-2026-31431) [](https://nvd.nist.gov/vuln/detail/CVE-2026-31431) [-yellow?style=for-the-badge&logo=linux&logoColor=black)](https://kernel.org) [](LICENSE) [](mitigation/)
## 📖 目录
| # | 章节 | 描述 |
|---|---------|-------------|
| 1 | [什么是 Copy Fail?](#-what-is-copy-fail) | 漏洞概述 |
| 2 | [技术深入解析](#-technical-deep-dive) | 根本原因分析 |
| 3 | [受影响的系统](#-affected-systems) | 发行版与内核矩阵 |
| 4 | [仓库结构](#-repository-structure) | 文件布局 |
| 5 | [实验环境搭建](#-lab-setup) | 安全复现 |
| 6 | [漏洞利用用法](#-exploit-usage) | 渗透测试工作流 |
| 7 | [检测](#-detection) | YARA、Sigma、脚本 |
| 8 | [缓解措施](#-mitigation) | 补丁与加固 |
| 9 | [渗透测试报告](#-pentest-reporting) | 报告模板 |
| 10 | [法律与道德](#-legal--ethics) | 免责声明 |
| 11 | [参考资料](#-references) | CVE、公告、博客 |
## 🔍 什么是 Copy Fail?
**Copy Fail** 是一个于 **2026 年 4 月 29 日** 被披露的**本地提权 (LPE)** 漏洞,几乎影响了自 **2017 年**以来运行内核的所有主要 Linux 发行版。
```
Unprivileged User ──► AF_ALG + splice() ──► 4-byte Page Cache Write ──► ROOT
```
### 关键事实概览
| 属性 | 详情 |
|----------|--------|
| **CVE ID** | CVE-2026-31431 |
| **昵称** | Copy Fail |
| **CVSS v3.1** | 7.8 (高) |
| **攻击向量** | 本地 |
| **所需权限** | 低 (任何非特权用户) |
| **用户交互** | 无 |
| **发现者** | Xint Code (Theori) |
| **披露日期** | 2026 年 4 月 29 日 |
| **漏洞利用大小** | 732 字节 (Python PoC) |
| **补丁状态** | ✅ 可用 — 还原提交 `a664bf3d603d` |
### 为什么这很危险
- 🕵️ **隐蔽** — 修改仅存在于页缓存中;磁盘上的文件**从未被更改**。标准的磁盘取证将无法检测到它。
- ⚡ **可靠** — 确定性的逻辑缺陷,而非竞态条件。漏洞利用在不同环境中表现一致。
- 🌐 **通用** — 影响 Ubuntu、RHEL、Amazon Linux、SUSE、Debian — 自 2017 年以来的每一个主要发行版。
- ☸️ **云/K8s 影响** — 可促进 Kubernetes 工作负载和 CI/CD 运行器中的容器逃逸。
- 🤖 **AI 发现** — 由 Xint Code 的 AI 系统在大约 1 小时的扫描时间和单一操作员提示下发现。
## 🔬 技术深入解析
### 根本原因
该漏洞源于 2017 年(`commit 72548b093ee3`)在 Linux 内核用户空间 crypto API (`AF_ALG`) 的 `algif_aead` 模块中引入的一个**有缺陷的原地优化**。
```
AF_ALG (userspace crypto API)
└── algif_aead module
└── authencesn template ◄── VULNERABLE
└── in-place optimization (2017)
└── req->src == req->dst ◄── pages from splice() chained into writable dst scatterlist
```
### 攻击流程
```
Step 1: Open AF_ALG AEAD socket
socket(AF_ALG, SOCK_SEQPACKET, 0)
Step 2: Send splice() pages referencing target file
(page cache pages of a privileged binary, e.g. /usr/bin/sudo)
Step 3: Trigger authencesn scratch write
authencesn uses dst buffer as scratch pad →
writes 4 controlled bytes PAST the legitimate output region
Step 4: Page cache entry for the target file is now corrupted
(disk file untouched — only in-memory copy modified)
Step 5: Execute the modified binary → ROOT
```
### 为什么是页缓存?
Linux 内核的页缓存支持文件的内存副本。当读取文件时,其页面会被缓存。`splice()` 系统调用可以直接引用这些缓存的页面。通过将页缓存页面馈送到 AF_ALG AEAD 散列链表中,authencesn 临时写入会**落在这些缓存的页面内**,从而有效地修补任何可读文件的内存中副本——包括像 `sudo`、`pkexec` 或 `passwd` 这样的特权二进制文件。
### 修复方案
上游修复还原了有缺陷的 2017 年优化:
```
# 已在 commit: a664bf3d603d 中修复
git show a664bf3d603d
```
## 🖥️ 受影响的系统
### Linux 内核版本
| 内核分支 | 是否受影响? | 修复版本 |
|--------------|-----------|---------------|
| 4.9.x (LTS) | ✅ 是 | 4.9.340+ |
| 5.4.x (LTS) | ✅ 是 | 5.4.295+ |
| 5.10.x (LTS) | ✅ 是 | 5.10.239+ |
| 5.15.x (LTS) | ✅ 是 | 5.15.185+ |
| 6.1.x (LTS) | ✅ 是 | 6.1.132+ |
| 6.6.x (LTS) | ✅ 是 | 6.6.83+ |
| 6.12.x (LTS) | ✅ 是 | 6.12.19+ |
| < 4.9 (2017 年前) | ❌ 否 | 不适用 — 不存在此优化 |
### 发行版矩阵
| 发行版 | 受影响版本 | 已修补? | 公告 |
|---|---|---|---|
| Ubuntu | < 26.04 (所有版本) | ✅ 已修补 | [USN](https://ubuntu.com/blog/copy-fail-vulnerability-fixes-available) |
| Ubuntu 26.04 (Resolute) | ❌ 不受影响 | — | — |
| RHEL / CentOS | 7, 8, 9 | ✅ 已修补 | RHSA-2026 |
| Amazon Linux | 2, 2023 | ✅ 已修补 | ALAS |
| SUSE / openSUSE | 均受影响 | ✅ 已修补 | SUSE-SU |
| Debian | Bullseye, Bookworm | ✅ 已修补 | DSA |
| CloudLinux | 8, 9 | ✅ 已修补 | [公告](https://blog.cloudlinux.com/cve-2026-31431-copy-fail-kernel-update) |
## 📁 仓库结构
```
CVE-2026-31431-CopyFail/
│
├── 📄 README.md ← You are here
├── 📄 LICENSE ← Research/Educational license
├── 📄 DISCLAIMER.md ← Legal & ethical use policy
├── 📄 CHANGELOG.md ← Version history
│
├── 📂 docs/
│ ├── vulnerability-analysis.md ← Deep-dive: root cause & mechanics
│ ├── exploitation-walkthrough.md ← Step-by-step methodology
│ ├── affected-kernels.md ← Full kernel/distro version matrix
│ ├── detection.md ← Defender, Tenable, Wazuh coverage
│ └── references.md ← All CVEs, blogs, advisories
│
├── 📂 exploit/
│ ├── README.md ← Usage, prerequisites, tested distros
│ ├── copyfail.py ← Reference PoC (educational)
│ ├── trigger.c ← AF_ALG + splice() C trigger
│ └── variants/
│ ├── ubuntu.py ← Ubuntu-specific variant
│ ├── rhel.py ← RHEL/CentOS variant
│ └── amazon_linux.py ← Amazon Linux variant
│
├── 📂 detection/
│ ├── yara/
│ │ └── copyfail.yar ← YARA rule for exploit artefacts
│ ├── sigma/
│ │ └── copyfail_lpe.yml ← Sigma rule for SIEM/SOC
│ └── scripts/
│ ├── check_vulnerable.sh ← Quick kernel vulnerability check
│ └── detect_algif_aead.sh ← Check if module is loaded/active
│
├── 📂 mitigation/
│ ├── README.md ← Mitigation overview
│ ├── disable_algif_aead.sh ← Disable affected kernel module
│ ├── patch-notes.md ← Upstream patch details
│ └── kubernetes-hardening.md ← K8s / container hardening
│
├── 📂 lab/
│ ├── Vagrantfile ← Reproducible vulnerable VM
│ ├── setup.sh ← Lab bootstrap script
│ └── docker/
│ └── Dockerfile ← Vulnerable Ubuntu container
│
├── 📂 reports/
│ ├── pentest-report-template.md ← Client-ready report template
│ └── sample-finding.md ← Sample finding write-up
│
└── 📂 assets/
├── demo.gif ← (Optional) terminal demo
└── diagrams/
└── page-cache-write.png ← Attack flow diagram
```
## 🧪 实验环境搭建
### 选项 A — Vagrant 虚拟机 (推荐)
```
# 克隆仓库
git clone https://github.com/0xFuffM3/CVE-2026-31431-CopyFail.git
cd CVE-2026-31431-CopyFail
# 启动存在漏洞的实验虚拟机
cd lab/
vagrant up
# 通过 SSH 登录实验环境
vagrant ssh
# 验证内核版本(应为易受攻击版本)
uname -r
```
### 选项 B — Docker 容器
```
cd lab/docker/
# 构建存在漏洞的容器镜像
docker build -t copyfail-lab .
# 以进行内核交互所需的权限运行
docker run --rm -it --privileged copyfail-lab /bin/bash
```
### 检查您的系统是否存在漏洞
```
# 运行快速检查脚本
chmod +x detection/scripts/check_vulnerable.sh
./detection/scripts/check_vulnerable.sh
```
在**易受攻击的**系统上的预期输出:
```
[!] Kernel version: 5.15.0-91-generic
[!] algif_aead module: LOADED
[✗] System appears VULNERABLE to CVE-2026-31431 (Copy Fail)
[*] Recommended action: Apply kernel update or disable algif_aead
```
在**已修补的**系统上的预期输出:
```
[✓] Kernel version: 6.1.132
[✓] System appears PATCHED against CVE-2026-31431 (Copy Fail)
```
## 💥 漏洞利用用法
### 前提条件
```
# Python 3.6+
python3 --version
# 存在所需的内核模块
lsmod | grep algif_aead
# 验证目标二进制文件是否可读
ls -la /usr/bin/sudo
```
### 运行 PoC
```
cd exploit/
# 检查当前权限级别
id
# uid=1000(user) gid=1000(user) groups=1000(user)
# 运行 Copy Fail PoC
python3 copyfail.py
# 验证权限提升
id
# uid=0(root) gid=0(root) groups=0(root)
```
### 渗透测试工作流
```
1. Enumerate kernel version
└─► uname -r / cat /proc/version
2. Check if algif_aead is loaded
└─► lsmod | grep algif_aead
3. Confirm low-privilege foothold
└─► id / whoami
4. Execute Copy Fail PoC
└─► python3 exploit/copyfail.py
5. Verify root access
└─► id && cat /etc/shadow
6. Document evidence
└─► Screenshot + log kernel version, distro, exploit hash
7. Apply mitigation (post-test)
└─► sudo bash mitigation/disable_algif_aead.sh
8. Include in pentest report
└─► Use reports/pentest-report-template.md
```
## 🔎 检测
### YARA 规则
```
// detection/yara/copyfail.yar
rule CopyFail_CVE_2026_31431 {
meta:
description = "Detects Copy Fail (CVE-2026-31431) exploit artefacts"
author = "0xFuffM3"
date = "2026-04-30"
reference = "https://copy.fail"
strings:
$py1 = "algif_aead" ascii
$py2 = "AF_ALG" ascii
$py3 = "splice" ascii
$py4 = "page_cache" ascii
$py5 = "authencesn" ascii
condition:
3 of them
}
```
运行 YARA 扫描:
```
yara detection/yara/copyfail.yar /tmp/ -r
```
### Sigma 规则 (SIEM)
```
# detection/sigma/copyfail_lpe.yml
title: Copy Fail LPE Exploit Execution (CVE-2026-31431)
status: stable
logsource:
category: process_creation
product: linux
detection:
selection:
CommandLine|contains:
- 'AF_ALG'
- 'algif_aead'
- 'authencesn'
condition: selection
falsepositives:
- Legitimate crypto API testing
level: high
```
### 快速检测脚本
```
chmod +x detection/scripts/detect_algif_aead.sh
./detection/scripts/detect_algif_aead.sh
```
### 安全工具覆盖范围
| 工具 | 检测支持 |
|------|-----------------|
| Microsoft Defender (MDVM) | ✅ 是 |
| Tenable Nessus | ✅ 是 |
| Qualys | ✅ 是 |
| Wazuh | ✅ 通过自定义 Sigma 规则 |
| Palo Alto Cortex XDR | ✅ 是 |
| CrowdStrike Falcon | ✅ 是 |
## 🛡️ 缓解措施
### 选项 1 — 应用内核补丁 (推荐)
```
# Ubuntu / Debian
sudo apt-get update && sudo apt-get upgrade linux-image-generic
# RHEL / CentOS
sudo yum update kernel
# Amazon Linux
sudo yum update kernel
# 更新后,重新启动
sudo reboot
```
### 选项 2 — 禁用 `algif_aead` 模块 (临时)
```
# 运行缓解脚本
chmod +x mitigation/disable_algif_aead.sh
sudo bash mitigation/disable_algif_aead.sh
```
该脚本的作用:
```
echo "install algif_aead /bin/false" > /etc/modprobe.d/disable-algif.conf
rmmod algif_aead 2>/dev/null || echo "[*] Module not currently loaded"
echo "[✓] algif_aead disabled. Reboot to confirm persistence."
```
### 选项 3 — Kubernetes 加固
参见 [`mitigation/kubernetes-hardening.md`](mitigation/kubernetes-hardening.md) 了解:
- 在 pod 安全策略中限制 `AF_ALG` 套接字创建
- 使用 Seccomp 配置文件阻止 `socket(AF_ALG, ...)` 系统调用
- 针对 Kubernetes 节点和 CI/CD 运行器的优先补丁
## 📝 渗透测试报告
随时可用的客户报告模板位于 [`reports/pentest-report-template.md`](reports/pentest-report-template.md)。
### 样本发现摘要
```
Finding: Local Privilege Escalation via Copy Fail (CVE-2026-31431)
Severity: HIGH (CVSS 7.8)
Host: 10.10.10.55 (ubuntu-prod-01)
Kernel: 5.15.0-91-generic
Evidence:
- Unprivileged shell (uid=1000) escalated to root (uid=0)
- Kernel module algif_aead confirmed loaded
- No disk artefacts — page cache only
Recommendation:
1. Apply vendor kernel patch immediately
2. Interim: disable algif_aead module
3. Review Kubernetes nodes and CI/CD runners
```
## ⚖️ 法律与道德
本仓库仅出于**合法的安全研究、授权的渗透测试和防御性安全**目的而发布。
- ✅ **允许:** 在您拥有或获得明确书面授权测试的系统上进行测试
- ✅ **允许:** 在隔离的实验室环境中进行安全研究
- ✅ **允许:** 防御性使用 — 检测、打补丁、加固
- ❌ **禁止:** 在未获得书面授权的系统上进行测试
- ❌ **禁止:** 对生产系统部署漏洞利用
- ❌ **禁止:** 任何违反当地、国家或国际法律的使用
未经授权使用本材料可能违反《**计算机欺诈和滥用法 (CFAA)**》、**欧盟指令 2013/40/EU**、**印度 IT 法案 2000** 以及您所在司法管辖区的同等法律。
作者对滥用**不承担任何责任**。完整法律声明请参见 [`DISCLAIMER.md`](DISCLAIMER.md)。
## 📚 参考资料
| 来源 | 链接 |
|--------|------|
| 原始披露 (Xint/Theori) | [copy.fail](https://copy.fail) |
| Xint Code 技术分析文章 | [xint.io/blog/copy-fail](https://xint.io/blog/copy-fail-linux-distributions) |
| NVD 条目 | [nvd.nist.gov](https://nvd.nist.gov/vuln/detail/CVE-2026-31431) |
| Microsoft 安全博客 | [microsoft.com/security/blog](https://www.microsoft.com/en-us/security/blog/2026/05/01/cve-2026-31431-copy-fail-vulnerability-enables-linux-root-privilege-escalation/) |
| Ubuntu 公告 | [ubuntu.com/blog](https://ubuntu.com/blog/copy-fail-vulnerability-fixes-available) |
| CERT-EU 公告 | [cert.europa.eu](https://cert.europa.eu/publications/security-advisories/2026-005/) |
| Tenable FAQ | [tenable.com/blog](https://www.tenable.com/blog/copy-fail-cve-2026-31431-frequently-asked-questions-about-linux-kernel-privilege-escalation) |
| Palo Alto Unit 42 | [unit42.paloaltonetworks.com](https://unit42.paloaltonetworks.com/cve-2026-31431-copy-fail/) |
| CloudLinux 公告 | [blog.cloudlinux.com](https://blog.cloudlinux.com/cve-2026-31431-copy-fail-kernel-update) |
| Bugcrowd 分析 | [bugcrowd.com/blog](https://www.bugcrowd.com/blog/what-we-know-about-copy-fail-cve-2026-31431/) |
| Linux 内核补丁 | [kernel.org — commit a664bf3d603d](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/) |
## 🤝 贡献
欢迎安全研究人员贡献:
1. Fork 本仓库
2. 创建一个功能分支:`git checkout -b feat/your-contribution`
3. 提交您的更改:`git commit -m "Add: detection rule for X"`
4. 推送并开启 Pull Request
请遵循负责任的披露准则。不要包含针对已修补系统的武器化、可用于生产环境的漏洞利用代码。
[](https://nvd.nist.gov/vuln/detail/CVE-2026-31431) [](https://nvd.nist.gov/vuln/detail/CVE-2026-31431) [-yellow?style=for-the-badge&logo=linux&logoColor=black)](https://kernel.org) [](LICENSE) [](mitigation/)
**为安全社区而制 — 请负责任地使用。**
[](https://github.com/0xFuffM3)
标签:0day, algif_aead, CSV导出, CVE-2026-31431, CVSS 7.8, Exploit, Linux内核, LPE, PoC, Web报告查看器, 内核漏洞, 加密框架, 协议分析, 子域名枚举, 应用安全, 暴力破解, 本地提权, 权限提升, 漏洞修复, 漏洞分析, 系统安全, 网络安全, 网络安全培训, 请求拦截, 路径探测, 逆向工具, 隐私保护, 页缓存破坏