无竞态条件。无偏移量。无需盲目信任的预编译二进制文件。
一个针对 CVE-2026-31431(复制失败漏洞)的 Bash 实现。该脚本在运行时会内联编译一个最小的 C 辅助程序。Bash 层负责架构检测、载荷解压和目标选择;C 层负责实际的与内核的交互(AF_ALG 套接字、splice、sendmsg),这些是 Bash 本身无法触及的。
完整的技术细节请参见 copy.fail。
该漏洞位于 algif_aead 中,即内核的 AF_ALG AEAD 套接字接口。2017 年的一项原地优化使得页面缓存页面可能出现在 authencesn 解密操作的可写目标散列表中。通过 splice() 提供正确的输入,你就能获得一个确定性的 4 字节写入,写入到任何可读文件的页面缓存中,包括你不拥有的 setuid 二进制文件。
每次用 shellcode 覆盖 /usr/bin/su 4 个字节,运行它,获得 root shell。无需竞争窗口,无需内核特定符号,无需重试。
chmod +x copyfail.sh
# Check if the system is vulnerable before doing anything
./copyfail.sh -c
# Run the exploit (must be non-root)
./copyfail.sh
# Specify a different setuid target
./copyfail.sh -t /usr/bin/passwd
# List all setuid-root candidates on the system
./copyfail.sh -s
该漏洞仅覆盖内存中的页面缓存,磁盘上的文件不受影响。重启即可恢复一切。如果想立即清理:
# Inside your root shell
/usr/bin/su --version # still works from disk if page cache is evicted
# Or just reboot
如果你使用 -t 指定了 su 以外的内容,也同样适用。仅影响页面缓存,磁盘是干净的。
gcc 用于编译内联 C 辅助程序python3 用于解压 shellcode 载荷(单行命令,无需额外包)algif_aead、authencesn、hmac、cbc如果算法不可用:
sudo modprobe algif_aead authencesn hmac cbc
某些发行版在 /etc/modprobe.d/ 中放置了一个阻止模块作为临时解决方案。如果存在则删除:
sudo rm /etc/modprobe.d/disable-algif{_,-}aead.conf 2>/dev/null
floor: torvalds/linux 72548b093ee3 August 2017, v4.14
(AF_ALG iov_iter rework that introduced
the file-page write primitive via splice
into the AEAD scatterlist)
ceiling: torvalds/linux a664bf3d603d April 2026, mainline
(reverts the 2017 in-place optimization;
source and destination scatterlists are
now separate, page-cache pages can no
longer end up as writable crypto output)
在这两个提交之间的版本:所有未向后移植修复的主要发行版。Ubuntu、RHEL、SUSE、Amazon Linux、Debian 在披露时均被确认存在漏洞。发行版的后向移植大约从 2026-04-29 开始。要检查特定内核,请在变更日志中查找 a664bf3d603d(或其发行版后向移植)。
| 架构 | 状态 |
|---|---|
| x86_64 | ✓ |
| aarch64 | ✓ |
| i386 / i686 | ✓ |
| armv7l | ✓ |
永久性: 更新你的内核。
临时解决方案(阻止 AF_ALG 套接字;不影响直接使用内核加密 API 的 IPsec/XFRM):
echo "install algif_aead /bin/false" | sudo tee /etc/modprobe.d/disable-algif-aead.conf
sudo rmmod algif_aead 2>/dev/null
容器: 添加一个 seccomp 配置文件来阻止 AF_ALG 套接字创建,并在你的 Pod 安全上下文中设置 allowPrivilegeEscalation: false。这会启用 no_new_privs,从而阻止内核在 execve() 时遵循 setuid 位。
Bash 版本在依赖方面不占优势,但它是一个单一脚本,你可以在运行前从头到尾阅读。C 辅助程序在运行时从一个 heredoc 生成并编译,没有需要单独审计的二进制 blob。
仅供授权安全测试和研究使用。请勿在没有所有权或明确书面许可的系统上运行。
| Python | Go | Bash |
|---|
| 依赖 | python3 | 无(静态二进制) | gcc + python3 |
| 预编译二进制文件 | 否 | 是 | 否 |
| 单文件 | 是 | 否 | 是 |
| 编译步骤 | 否 | 否 | 是(内联,自动) |