kw-soft/copyfail

GitHub: kw-soft/copyfail

针对 CVE-2026-31431(Copy Fail)Linux 内核本地提权漏洞的安全检测脚本,通过只读方式检查内核版本、algif_aead 模块状态和各发行版补丁状态,判断系统是否受影响并给出缓解建议。

Stars: 1 | Forks: 0

# CVE-2026-31431 — "Copy Fail" 安全检测脚本 ## 背景 **Copy Fail** (CVE-2026-31431) 是 Linux 内核 `algif_aead` 模块(AF\_ALG 用户空间 crypto API 的一部分)中的一个逻辑缺陷。该漏洞由 [Theori / Xint Code](https://xint.io/blog/copy-fail-linux-distributions) 于 **2026 年 4 月 29 日** 披露。 一个 732 字节的 Python 脚本就可以让无特权的本地用户在几乎所有 2017 年以来构建的主流 Linux 发行版上获得完整的 root 权限——无需竞态条件、内核偏移或编译的有效载荷。 | 属性 | 详情 | |---|---| | CVE | CVE-2026-31431 | | CVSS | 7.8 HIGH | | 类型 | 本地权限提升 (LPE) | | 受影响的内核 | 4.14 – 6.18.21, 6.19.0 – 6.19.11 | | 根本原因 | `algif_aead` 原地优化(提交 `72548b093ee3`,2017 年) | | 上游修复 | 通过提交 `a664bf3d603d` 回退 | | 漏洞利用可靠性 | 确定性的 — 无需竞态条件 | ## 脚本检测内容 1. **内核版本** — 当前运行的内核是否处于易受攻击的上游版本范围内 2. **algif\_aead 模块状态** — 已加载、内建还是不存在 3. **活动缓解措施** — `modprobe.d` 黑名单、`initcall_blacklist` 内核命令行参数 4. **特定发行版的补丁状态** — 针对 Debian/Ubuntu/Parrot:根据 USN-8226-1 验证 `kmod` 软件包版本 ## 支持的发行版 | 发行版 | 检查方法 | |---|---| | Ubuntu / Linux Mint | `kmod` 软件包版本 (USN-8226-1) | | Debian | `kmod` 软件包版本 + 安全追踪器 | | Parrot OS | `kmod` 软件包版本 (Debian rolling) | | RHEL / CentOS / AlmaLinux / Rocky | `dnf updateinfo` + `initcall_blacklist` 命令行 | | Fedora | `dnf updateinfo` | | Amazon Linux | `dnf check-update --security` | | SUSE / openSUSE | `zypper lp` | | Arch Linux | `pacman -Syu linux` | ## 用法 ``` # Download curl -O https://raw.githubusercontent.com/kw-soft/copyfail/main/copyfail.sh # 设为可执行文件 chmod +x copyfail.sh # 运行(建议使用 root 以获取完整模块可见性) sudo ./copyfail.sh ``` ## 示例输出 ### 易受攻击的系统 ``` ============================================ CVE-2026-31431 'Copy Fail' — Safe Detection ============================================ [*] Kernel: 6.8.0-71-generic [!] Kernel 6.8.0-71-generic is in the vulnerable upstream range (4.14 – 6.19.11) [~] Distro backport check follows — version number alone is not conclusive [*] algif_aead module status: [!] algif_aead is LOADED — attack surface is active [*] Distribution patch status: Distro : Ubuntu 24.04 kmod installed : 31+20240202-2ubuntu6 kmod required : >= 31+20240202-2ubuntu7.2 [!] kmod 31+20240202-2ubuntu6 < 31+20240202-2ubuntu7.2 — mitigation NOT applied ============================================ RESULT ============================================ [!] VULNERABLE — kernel affected and algif_aead is active ``` ### 已缓解的系统 ``` ============================================ CVE-2026-31431 'Copy Fail' — Safe Detection ============================================ [*] Kernel: 6.8.0-71-generic [!] Kernel 6.8.0-71-generic is in the vulnerable upstream range (4.14 – 6.19.11) [~] Distro backport check follows — version number alone is not conclusive [*] algif_aead module status: [✓] algif_aead is NOT loaded [✓] modprobe blacklist active: /etc/modprobe.d/disable-algif_aead.conf [*] Distribution patch status: Distro : Ubuntu 24.04 kmod installed : 31+20240202-2ubuntu7.2 kmod required : >= 31+20240202-2ubuntu7.2 [✓] kmod >= 31+20240202-2ubuntu7.2 — USN-8226-1 mitigation present ============================================ RESULT ============================================ [✓] MITIGATED — algif_aead is blocked [~] Apply a patched kernel when available to fully resolve the issue ``` ## 应用缓解措施 ### Debian / Ubuntu / Parrot / Linux Mint ``` sudo apt update && sudo apt upgrade && sudo reboot ``` 这将安装已打补丁的 `kmod` 软件包 (USN-8226-1),该软件包会下发一个 `modprobe.d` 规则来阻止 `algif_aead`。 如果无法立即重启: ``` echo 'install algif_aead /bin/false' | sudo tee /etc/modprobe.d/disable-algif.conf sudo update-initramfs -u sudo rmmod algif_aead 2>/dev/null || echo "Module in use — reboot required" ``` ### RHEL / CentOS / AlmaLinux / Rocky ``` sudo grubby --update-kernel=ALL --args='initcall_blacklist=algif_aead_init' sudo reboot ``` ### Arch Linux ``` sudo pacman -Syu linux && sudo reboot ``` ## 不受影响的内容 该缓解措施不会影响以下任何内容: - `dm-crypt` / LUKS 全盘加密 - SSH - IPsec / XFRM - OpenSSL(默认构建) - GnuTLS / NSS - kTLS 只有显式配置为使用 `afalg` 引擎或直接绑定 AF\_ALG AEAD socket 的应用程序可能会受到影响——这在标准部署中很少见。 ## 检查自动更新 (Ubuntu) Hetzner **不会**自动应用操作系统更新。Ubuntu 预装了 `unattended-upgrades`,但必须手动启用和配置。 ``` # 检查自动安全更新是否处于活动状态 cat /etc/apt/apt.conf.d/20auto-upgrades # 查看升级历史 grep "^Start-Date\|^Commandline" /var/log/apt/history.log | tail -30 # 检查 kmod 缓解措施是否已自动应用 grep "kmod\|algif" /var/log/apt/history.log # 检查上次 unattended-upgrades 运行情况 tail -30 /var/log/unattended-upgrades/unattended-upgrades.log ``` ## 参考 | 资源 | 链接 | |---|---| | 原始文章 | https://xint.io/blog/copy-fail-linux-distributions | | NVD | https://nvd.nist.gov/vuln/detail/CVE-2026-31431 | | Ubuntu 公告 | https://ubuntu.com/blog/copy-fail-vulnerability-fixes-available | | USN-8226-1 | https://ubuntu.com/security/notices/USN-8226-1 | | CERT-EU 公告 | https://cert.europa.eu/publications/security-advisories/2026-005/ | | Debian 追踪器 | https://security-tracker.debian.org/tracker/CVE-2026-31431 | | Microsoft 博客 | https://www.microsoft.com/en-us/security/blog/2026/05/01/cve-2026-31431-copy-fail-vulnerability-enables-linux-root-privilege-escalation/ | | 维基百科 | https://en.wikipedia.org/wiki/Copy_Fail | ## 免责声明 此脚本旨在供您在自己拥有或被授权测试的系统上使用。 它仅执行只读检查,不会以任何方式利用该漏洞。
标签:0day挖掘, AF_ALG, algif_aead, CentOS, Copy Fail, Cutter, CVE-2026-31431, CVSS 7.8, Debian, GPT, Linux内核漏洞, LPE, RHEL, Shell脚本, Web报告查看器, 内核安全, 加密, 协议分析, 子域名枚举, 安全基线检查, 安全检测脚本, 安全渗透, 安全防护, 应用安全, 本地提权, 权限提升, 漏洞扫描器, 漏洞管理, 用户态加密API, 系统安全, 网络安全, 隐私保护