Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
copyfail-check — 用于在 Linux 系统上检测 CVE-2026-31431(Copy Fail)暴露情况及缓解措施的 Shell 脚本:内核检查、模块状态、启动参数、AF_ALG 可达性以及发行版补丁状态。 | Kitploit
工具/GitHubGitHub/codesource/copyfail-check
漏洞扫描器漏洞分析配置审计DevSecOps事件响应
GitHubcodesource/copyfail-check

copyfail-check

用于在 Linux 系统上检测 CVE-2026-31431(Copy Fail)暴露情况及缓解措施的 Shell 脚本:内核检查、模块状态、启动参数、AF_ALG 可达性以及发行版补丁状态。

查看仓库
23个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

copyfail-check

用于检测 Linux 内核漏洞、检查缓解状态并指导修复的 Shell 脚本——设计用于本地运行或通过 SSH、Ansible 或 pssh 在服务器集群中运行。


CVE-2026-31431 — Copy Fail

Copy Fail 是 Linux 内核 algif_aead 加密模块中的一个高危本地权限提升(LPE)漏洞。该漏洞源于 2017 年引入的一个逻辑缺陷,允许任何无特权的本地用户向任意可读文件的页缓存中写入 4 个受控字节——足以覆盖 setuid 二进制文件并获得 root 权限。一个可用的 732 字节 Python 概念验证(PoC)已公开可用。

CVECVE-2026-31431
CVSS7.8(高危)
披露日期2026 年 4 月 29 日
受影响版本Linux 内核 4.13 – 6.x(2017–2026)
发行版Ubuntu、RHEL、SUSE、Debian、Amazon Linux 及大多数其他发行版
可远程利用否——需要本地访问权限
可用补丁部分——请查看您发行版的安全公告

脚本检查内容

检查项需要 root 权限?
内核版本——是否处于受影响范围(≥ 4.13)否
algif_aead 模块——是否已加载、磁盘上是否存在或被列入黑名单否
启动参数——initcall_blacklist=algif_aead_init 是否存在否
AF_ALG 套接字可达性——利用路径是否开放否
SELinux 状态否
AppArmor 状态是——无 root 权限时仅输出部分结果
发行版补丁状态——CVE 是否列在内核变更日志中否

运行脚本不需要 root 权限——除 AppArmor 状态外,所有检查均可以普通用户身份运行。建议使用 sudo 运行以获得完整结果,并且在使用 curl 管道执行时,使用 sudo 是更安全的选择。

兼容性

该脚本设计用于在所有主流 Linux 发行版上运行:

发行版系列包管理器检查模块路径
Debian、Ubuntudpkg + 内核变更日志/lib/modules/
RHEL、CentOS、Amazon Linuxrpm(kernel、kernel-rt)/lib/modules/
SUSE、openSUSErpm(kernel-default)/lib/modules/
Arch Linuxpacman + 安全公告链接/usr/lib/modules/
Fedorarpm + /usr/lib/modules/ 回退/usr/lib/modules/

需要 bash——该脚本使用 bash 特有的语法,无法在 sh、ash 或 dash 下运行。在 Alpine Linux(默认使用 busybox ash)上,请先安装 bash:

root@kitploit:~
apk add bash

快速运行(单台服务器)

无 root 权限——大多数检查可正常工作:

root@kitploit:~
curl -fsSL https://raw.githubusercontent.com/codesource/copyfail-check/main/check_copyfail.sh | bash

使用 root 权限——完整结果,包括 AppArmor 状态:

root@kitploit:~
curl -fsSL https://raw.githubusercontent.com/codesource/copyfail-check/main/check_copyfail.sh | sudo bash

提示: 在生产环境中请固定到特定的提交 SHA,以免脚本在您不知情的情况下被更改:

root@kitploit:~
curl -fsSL https://raw.githubusercontent.com/codesource/copyfail-check/COMMIT_SHA/check_copyfail.sh | sudo bash

先下载并检查(推荐)

root@kitploit:~
curl -fsSL https://raw.githubusercontent.com/codesource/copyfail-check/main/check_copyfail.sh -o check_copyfail.sh
less check_copyfail.sh
bash check_copyfail.sh        # 无 root 权限
sudo bash check_copyfail.sh   # 完整结果

在服务器集群中运行

SSH 循环

root@kitploit:~
for HOST in server1 server2 server3; do
  echo "=== $HOST ==="
  ssh "$HOST" "curl -fsSL https://raw.githubusercontent.com/codesource/copyfail-check/main/check_copyfail.sh | sudo bash"
done

Ansible

root@kitploit:~
- name: Check Copy Fail vulnerability
  hosts: all
  tasks:
    - name: Run check script
      script: check_copyfail.sh
      become: yes

并行 SSH

root@kitploit:~
pssh -h hosts.txt -i \
  "curl -fsSL https://raw.githubusercontent.com/codesource/copyfail-check/main/check_copyfail.sh | sudo bash"

示例输出

root@kitploit:~
============================================================
  Copy Fail CVE-2026-31431 – Vulnerability Check
============================================================

>>> Kernel Version
  [INFO]  Running kernel: 5.15.0-107-generic
  [WARN]  Kernel 5.15.0-107-generic is in the affected range (4.13 – 6.x).

>>> algif_aead Module Status
  [WARN]  algif_aead module is currently LOADED — system is exploitable.
  [WARN]  Module file found at: /lib/modules/5.15.0-107-generic/kernel/crypto/algif_aead.ko
  [WARN]  algif_aead is NOT blacklisted — it can be loaded on demand.

>>> Kernel Boot Parameter Mitigation
  [WARN]  initcall_blacklist=algif_aead_init is NOT set in boot parameters.

>>> AF_ALG Socket Reachability
  [WARN]  AF_ALG sockets are reachable by this user — exploit path is open.

>>> Mandatory Access Control (SELinux / AppArmor)
  [WARN]  Neither SELinux nor AppArmor tools detected — no MAC layer present.

>>> Distribution Patch Status
  [WARN]  Could not confirm CVE-2026-31431 is listed as fixed in running kernel's changelog.

============================================================
  SUMMARY
============================================================
  !! LIKELY VULNERABLE — No confirmed mitigation detected.

  Recommended actions (in order of preference):
  1. Apply your distro's kernel update as soon as available.
  2. Add to /etc/modprobe.d/copyfail.conf:
       blacklist algif_aead
       install algif_aead /bin/true
     Then run: sudo depmod -a && sudo update-initramfs -u
  3. Add to kernel boot parameters (grub):
       initcall_blacklist=algif_aead_init
  4. Immediately unload the module if loaded:
       sudo rmmod algif_aead
============================================================

缓解措施

请按优先顺序应用以下措施:

1. 修补内核 (最佳修复方案)

root@kitploit:~
# Debian / Ubuntu
sudo apt update && sudo apt upgrade linux-image-$(uname -r)

# RHEL / CentOS / Amazon Linux
sudo yum update kernel

# SUSE
sudo zypper update kernel-default

2. 将模块列入黑名单 (立即生效,持久有效)

root@kitploit:~
sudo tee /etc/modprobe.d/copyfail.conf << 'EOF'
blacklist algif_aead
install algif_aead /bin/true
EOF

sudo depmod -a

# Debian/Ubuntu
sudo update-initramfs -u

# RHEL/Fedora
sudo dracut -f

3. 立即卸载模块 (立即生效,重启后不持久)

root@kitploit:~
sudo rmmod algif_aead

4. 内核启动参数 (黑名单的替代方案)

将 initcall_blacklist=algif_aead_init 添加到 GRUB 配置中并重启。


参考链接

  • copy.fail — 官方漏洞页面
  • Xint/Theori 分析文章
  • NVD — CVE-2026-31431
  • CERT-EU 安全公告 2026-005
  • Microsoft 安全博客
  • The Hacker News

许可证

MIT — 可自由使用,不提供任何担保。始终在以 root 身份运行脚本之前对其进行审查。

下载工具