Keep updating......
Linux kernel CVE exploit analysis report and relative debug environment. You don't need to compile Linux kernel and configure your environment anymore.
This repository is to extract all Linux kernel exploit and relative debug environment. You can use Qemu to boot the kernel and test the exploit.
# Eg, test CVE-2017-11176, finally you levate privileges and get the shell
john@john-virtual-machine:~/Desktop/kernel-exploit-factory/CVE-2017-11176$ ./start.sh
chmod: /dev/csaw: No such file or directory
ifconfig: SIOCSIFADDR: No such device
route: SIOCADDRT: No such device
/ $ uname -a
Linux (none) 4.11.9 #1 SMP Sat Feb 20 21:52:39 CST 2021 x86_64 GNU/Linux
/ $ id
uid=1000(chal) gid=1000(chal) groups=1000(chal)
/ $ cd exp
/exp $ ./exp-slab-4119
[*] sk_rmem_alloc > sk_rcvbuf ==> ok
[*] mq_notify start
[*] wake up thread 1
... ...
/exp # id
uid=0(root) gid=0(root)
/exp #
Test version: Linux-4.19.65
Protection: 开启kaslr/SMEP,未开启SMAP。
Vulnerability: gcc 编译优化导致的Double-Fetch漏洞,可直接劫持控制流。
Test version: Linux-4.8.13
Protection: 未开 KASLR/SMAP/SMEP。伪造的skb_shared_info结构在用户空间,显然不能绕过SMAP。
Vulnerability: net/core/sock.c中的 sock_setsockopt() 函数错误处理负值,导致 sk_sndbuf 和 sk_rcvbuf取值为负。调用write时将skb->head和skb->end设置错误,最后调用close释放时会访问用户空间报错。用户空间地址0xfffffed0处伪造skb_shared_info结构,通过skb_shared_info->destructor_arg->callback 劫持控制流。
Test version: Linux-4.20.0-rc3
Protection: 开启SMEP,未开启kaslr/SMAP。
Vulnerability: Linux ebpf 模块中queue_stack_map_alloc()中整数溢出漏洞,导致堆溢出。修改虚表指针劫持控制流到xchg eax, esp。
Test version: Linux 4.14-rc4
Protection: 开启 SMEP / SMAP,关闭KASLR。
Vulnerability: /kernel/exit.c中的waitid的实现,在调用unsafe_put_user()将内核数据拷贝到用户空间地址时,没有调用access_ok()检测用户空间地址的合法性,导致实际可以往内核空间地址拷贝数据。 waitid未检测用户地址合法性 导致 null 任意地址写。可执行0地址shellcode 或 覆盖某猜测范围的cred 来提权。
Test version: Linux-4.9.12
Protection: 开启SMEP/SMAP,关闭kASLR。
Vulnerability: Linux内核IP V6协议簇的DCCP(数据报拥塞控制协议),net/dccp/input.c中的 dccp_rcv_state_process() 函数,在LISTEN状态下错误处理 DCCP_PKT_REQUEST 包数据结构,用户采用IPV6_RECVPKTINFO选项调用setsockopt()时会触发**sk_buff结构的 Double-Free**。利用方式类似CVE-2016-8655。第一次触发漏洞,堆喷伪造po->rx_ring->prb_bdqc->retire_blk_timer结构,执行native_write_cr4(0x406e0)来关闭SMEP/SMAP;第二次触发漏洞,堆喷伪造skb-> ... ->destructor_arg结构,执行commit_creds(prepare_kernel_cred(0))来提权。
Test version: Linux-4.10.6
Protection: 开启 SMEP / SMAP,关闭KASLR。
Vulnerability: net/packet/af_packet.c中的packet_set_ring()函数没有正确检查块size,长度判断条件错误,导致堆溢出,需要CAP_NET_RAW 权限。两次劫持函数指针,先关闭SMEP/SMAP防护,再提权。
Test version: Linux-4.10.15
Protection: 开启SMEP,关闭kASLR、SMAP。
Vulnerability: net/ipv4/inet_connection_sock.c文件中的inet_csk_clone_lock()函数存在Double-Free漏洞。利用Double-Free来篡改RCU的回调函数指针,关闭SMEP并跳转到shellcode来修改cred。
Test version: Linux-4.11.9
Protection: 开启SMEP,关闭kASLR、SMAP。
Vulnerability: Linux内核中的POSIX消息队列的实现,mq_notify()函数没有把sock指针置为null,导致UAF。实际上是由于竞争导致的Double-Free漏洞,但竞态的时间可以无限延长。
Test version: Linux-4.4.110
Protection: 开启SMEP/SMAP/kaslr。
Vulnerability: Linux ebpf 模块整数扩展问题,主要问题是二者寄存器值类型不同,导致check函数和真正的函数的执行方法不一致。本漏洞不包含堆栈攻击或控制流劫持,仅用系统调用数据进行提权,是Data-Oriented Attacks在linux内核上的一个典型应用。
Test version: Linux-4.12.6
Protection: 开启SMEP,关闭SMAP/kaslr。
Vulnerability: net/ipv4/ip_output.c 中的__ip_append_data() 没有保证UDP报文处理的一致性,导致两次send报文时,可从UFO路径切换为non-UFO路径,导致堆溢出。利用时可通过覆盖skb_shared_info->destructor_arg->callback劫持控制流。
Test version: Linux-4.14.13
Protection: 开启SMEP,关闭SMAP/kaslr。
Vulnerability: net/rds/rdma.c中的 rds_cmsg_atomic() 函数中忘记将rm->atomic.op_active置0,导致 rds_atomic_free_op() -> set_page_dirty() 引用page->page_link时发生 null-dereference 漏洞。在0地址伪造结构和函数指针,劫持控制流。
CVE-2019-9213-writeup CVE-2019-8956-writeup
Test version: Linux-4.20.0 32位
Protection: 开启SMEP,关闭SMAP/kaslr。
Vulnerability:
mm/mmap.c中的expand_downwards()对mmap最小地址的检查出错,对错误的task进行了capability检查,导致绕过了mmap_min_addr的限制,逻辑漏洞。利用LD_DEBUG=help /bin/su 1>&%d命令执行write操作,本来应检测exp的cred,结果错误检测了write进程的cred,就将低地址标记为特权可访问。只有32位系统能成功利用漏洞,原因不详。net/sctp/socket.c中的 sctp_sendmsg() 函数在处理SCTP_SENDALL flag时出现空指针引用漏洞。结合CVE-2019-9213,绕过mmap_min_addr的限制,可以mmap到低地址0xd4并伪造结构,劫持控制流。Test version: Ubuntu 18.04(4.15.0-20-generic #21)
Protection: 开启SMEP/SMAP/kaslr。