MCPcopy Index your code
hub / github.com/bsauce/kernel-exploit-factory

github.com/bsauce/kernel-exploit-factory @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,921 symbols 3,521 edges 98 files 397 documented · 21%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

kernel-exploit-factory

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.


Example

# 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 # 

Catalog

  1. CVE-2015-8550
  2. CVE-2016-9793
  3. 4-20-BPF-integer
  4. CVE-2017-5123
  5. CVE-2017-6074
  6. CVE-2017-7308
  7. CVE-2017-8890
  8. CVE-2017-11176
  9. CVE-2017-16995
  10. CVE-2017-1000112
  11. CVE-2018-5333
  12. CVE-2019-9213 & CVE-2019-8956
  13. CVE-2019-15666
  14. CVE-2020-8835
  15. CVE-2020-27194
  16. CVE-2021-3156
  17. CVE-2021-31440
  18. CVE-2021-3490
  19. CVE-2021-22555
  20. CVE-2021-41073
  21. CVE-2021-4154
  22. CVE-2021-42008
  23. CVE-2021-43267
  24. CVE-2022-0185
  25. CVE-2022-0847
  26. CVE-2022-0995
  27. CVE-2022-1015
  28. CVE-2022-2588
  29. CVE-2022-2602
  30. CVE-2022-2639
  31. CVE-2022-25636
  32. CVE-2022-27666
  33. CVE-2022-32250
  34. CVE-2022-34918
  35. CVE-2023-2598
  36. CVE-2024-1086
  37. CVE-2025-21702
  38. CVE-2026-23271

Detail

1.CVE-2015-8550

writeup

Test version: Linux-4.19.65

Protection: 开启kaslr/SMEP,未开启SMAP。

Vulnerability: gcc 编译优化导致的Double-Fetch漏洞,可直接劫持控制流。

2. CVE-2016-9793

writeup

Test version: Linux-4.8.13

Protection: 未开 KASLR/SMAP/SMEP。伪造的skb_shared_info结构在用户空间,显然不能绕过SMAP。

Vulnerability: net/core/sock.c中的 sock_setsockopt() 函数错误处理负值,导致 sk_sndbufsk_rcvbuf取值为负。调用write时将skb->headskb->end设置错误,最后调用close释放时会访问用户空间报错。用户空间地址0xfffffed0处伪造skb_shared_info结构,通过skb_shared_info->destructor_arg->callback 劫持控制流。

3. 4-20-BPF-integer

writeup

Test version: Linux-4.20.0-rc3

Protection: 开启SMEP,未开启kaslr/SMAP。

Vulnerability: Linux ebpf 模块中queue_stack_map_alloc()整数溢出漏洞,导致堆溢出。修改虚表指针劫持控制流到xchg eax, esp

4.CVE-2017-5123

writeup

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 来提权。

5.CVE-2017-6074

writeup reference

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))来提权。

6.CVE-2017-7308

writeup reference

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防护,再提权。

7.CVE-2017-8890

writeup reference

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。

8.CVE-2017-11176

writeup

Test version: Linux-4.11.9

Protection: 开启SMEP,关闭kASLR、SMAP。

Vulnerability: Linux内核中的POSIX消息队列的实现,mq_notify()函数没有把sock指针置为null,导致UAF。实际上是由于竞争导致的Double-Free漏洞,但竞态的时间可以无限延长。

9.CVE-2017-16995

writeup

Test version: Linux-4.4.110

Protection: 开启SMEP/SMAP/kaslr。

Vulnerability: Linux ebpf 模块整数扩展问题,主要问题是二者寄存器值类型不同,导致check函数和真正的函数的执行方法不一致。本漏洞不包含堆栈攻击或控制流劫持,仅用系统调用数据进行提权,是Data-Oriented Attacks在linux内核上的一个典型应用。

10. CVE-2017-1000112

writeup reference

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劫持控制流。

11. CVE-2018-5333

writeup

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地址伪造结构和函数指针,劫持控制流。

12. CVE-2019-9213 & CVE-2019-8956

CVE-2019-9213-writeup CVE-2019-8956-writeup

Test version: Linux-4.20.0 32位

Protection: 开启SMEP,关闭SMAP/kaslr。

Vulnerability:

  • CVE-2019-9213:mm/mmap.c中的expand_downwards()对mmap最小地址的检查出错,对错误的task进行了capability检查,导致绕过了mmap_min_addr的限制,逻辑漏洞。利用LD_DEBUG=help /bin/su 1>&%d命令执行write操作,本来应检测exp的cred,结果错误检测了write进程的cred,就将低地址标记为特权可访问。只有32位系统能成功利用漏洞,原因不详。
  • CVE-2019-8956:net/sctp/socket.c中的 sctp_sendmsg() 函数在处理SCTP_SENDALL flag时出现空指针引用漏洞。结合CVE-2019-9213,绕过mmap_min_addr的限制,可以mmap到低地址0xd4并伪造结构,劫持控制流。

13. CVE-2019-15666

writeup reference

Test version: Ubuntu 18.04(4.15.0-20-generic #21)

Protection: 开启SMEP/SMAP/kaslr。

Vulnerability: net/xfrm/xfrm_user.c中的 verify_newpolicy_info() 错误处理了dir验证,导致__xfrm_policy_unlink()中出现越界访问。漏洞原本是个越界减1,可以利用别的路径来构造UAF,可以往空闲块上的8字节写null。漏洞对象xfrm_policy位于kmalloc-1024,cred结构位于kmalloc-192。首先利用setxattr+userfaultfdpolicy0周围都喷射kmalloc-1024堆块,释放policy0后同时释放喷射块,促使该slab释放后被c子进程的cred复用,然后触发UAF 空闲块8字节NULL写来修改cred中的gid/suid,再将当前用户添加到sudoers,即可提权。

14. CVE-2020-8835

writeup reference

Test version: Linux-5.5.0

Protection: 开启SMEP/SMAP/kaslr。

Vulnerability: kernel/bpf/verifier.c没有正确将64位值转换为32位(直接取低32位),发生整数截断,使得BPF代码验证阶段和实际执行阶段不一致,导致越界读写。

15. CVE-2020-27194

writeup reference

Test version: Linux-5.8.14

Protection: 开启SMEP/SMAP/kaslr。

Vulnerability: eBPF验证程序中进行or操作时,scalar32_min_max_or()函数将64位的值赋值到32位的变量上,导致整数截断,进而错误计算了寄存器的范围,从而绕过bpf的检查,导致越界读写。

16. CVE-2021-3156

writeup exploit

Test version: Ubuntu 19.04、Sudo 1.8.27

Protection: 开启SMEP/SMAP/kaslr。

Vulnerability: sudo在处理命令行参数时,处理单个反斜杠结尾的命令时,发生逻辑错误,导致堆溢出

17. CVE-2021-31440

writeup exploit

Test version: Linux-5.11

Protection: 开启SMEP/SMAP/kaslr。

Vulnerability: eBPF模块—kernel/bpf/verifier.c__reg_combine_64_into_32() 函数,寄存器计算错误。利用verifier阶段与实际执行阶段的不一致性,进行越界读写。泄露内核基址、伪造函数表、实现任意读写后篡改本线程的cred。

18. CVE-2021-3490

writeup exploit

Test version: Linux-5.11 Linux-5.11.16

Protection: 开启SMEP/SMAP/kaslr。

Vulnerability: eBPF模块—kernel/bpf/verifier.c的按位操作(AND、OR 和 XOR)的 eBPF ALU32 边界跟踪没有正确更新 32 位边界,造成 Linux 内核中的越界读取和写入,从而导致任意代码执行。三个漏洞函数分别是 scalar32_min_max_and()scalar32_min_max_or()scalar32_min_max_xor()。利用verifier阶段与实际执行阶段的不一致性,进行越界读写。泄露内核基址、伪造函数表、实现任意读写后篡改本线程的cred。

19. CVE-2021-22555

writeup exploit

Test version: Linux-5.11.14

Protection: 开启KASLR/SMEP/SMAP。

Vulnerability: net/netfilter/x_tables.cNetfilter 模块的ip_tables子模块, 当调用setsockopt()和选项IPT_SO_SET_REPLACE(或 IP6T_SO_SET_REPLACE)时,内核结构需要从32位转换为64位,由于错误计算转换大小,导致在调用 xt_compat_match_from_user() 函数时堆溢出写 0 ,可转化为UAF。攻击者可用于提权,或者从docker、k8s容器(kubernetes)中逃逸。需要CAP_NET_ADMIN权限,或者支持user+network命名空间。

20. CVE-2021-41073

writeup reference

Test version: Linux-5.14.6

Protection: 开启KASLR/SMEP/SMAP。未开启 CONFIG_SLAB_FREELIST_RANDOM / CONFIG_SLAB_FREELIST_HARDENED / CONFIG_BPF_JIT_ALWAYS_ON / CONFIG_MEMCG(默认是开启的)。

Vulnerability: fs/io_uring.c中的loop_rw_iter()函数存在 type confusion漏洞io_kiocb->rw.addr 既充当内核地址又充当用户地址,但是在loop_rw_iter()函数中递增时没有作区分,导致在读文件时错误将内核地址递增,最后错误将位于可控偏移处的相邻buffer释放掉(kmalloc-32)。利用条件很严格,由于漏洞对象位于 kmalloc-32,所以关闭了 freelist 保护机制;由于 seq_operations 对象采用 GFP_KERNEL_ACCOUNT flag 分配,所以还关闭了 CONFIG_MEMCG* 机制;本漏洞采用篡改eBPF中的 sk_filter->prog 指针并伪造 BPF程序的方式来进行提权,所以还关闭了 CONFIG_BPF_JIT_ALWAYS_ON 配置。

21. CVE-2021-4154

writeup reference

Test version: Linux-5.13.3

Protection: 开启KASLR/SMEP/SMAP。

Vulnerability: kernel/cgroup/cgroup-v1.ccgroup1_parse_param() 函数(通过fsconfig 系统调用触发)存在类型混淆,导致UAF漏洞。可以调用syscall fsconfig 设置任意的 fd,最终关闭该文件后 fd 对应 file 对象会被释放。这样我们就能释放任意一个文件描述符对应的 file 结构。本文采用两种方法实现利用,一是DirtyCred,二是构造ROP。对比两种方法,DirtyCred方法的优点是跨内核版本通用,不需要适配,缺点是需要覆写特权文件来提权,所以在docker等容器中无法提权;ROP的优点是可以任意读写内核内存并执行任意代码,缺点是对不同内核版本的适配很麻烦。

22. CVE-2021-42008

writeup reference

Test version: Linux-5.13.12

Protection: 开启KASLR / SMEP / SMAP / PTI。

Vulnerability: drivers/net/hamradio/6pack.cdecode_data() 函数存在堆溢出,用户需具备 CAP_NET_ADMIN 权限。sixpack_decode() 可多次调用 decode_data() ,对输入进行解码并保存到 sixpack->cooked_bufsixpack->rx_count_cooked成员充当访问 sixpack->cooked_buf 的下标,确定写入解码字节的目标偏移。问题是如果多次调用decode_data()rx_count_cooked就会一直递增,直到超过 cooked_buf 的长度(400字节),导致越界写。参考Linux内核中利用msg_msg结构实现任意地址读写构造越界读和任意地址写,篡改modprobe_path提权,缺点是得用到userfaultfd,且绕不开 CAP_NET_ADMIN 的槛。

23. CVE-2021-43267

writeup reference

Test version: Linux-5.14.15

Protection: 开启KASLR/SMEP/SMAP。

Vulnerability: 漏洞位于 net/tipc/crypto.c 文件,TIPC(Transparent Inter-Process Communication)集群内通信协议中对 MSG_CRYPTO 类型的消息长度验证出错,导致堆溢出tipc_crypto_key_rcv() 函数中,TIPC消息([tipc_msg](https://elixir.boot

Core symbols most depended-on inside this repo

netlink_attr
called by 88
CVE-2022-27666/exploit/exploit.c
netlink_done
called by 42
CVE-2022-27666/exploit/exploit.c
get_time_ns
called by 38
CVE-2026-23271/exploit/exploit.cpp
netlink_nest
called by 35
CVE-2022-27666/exploit/exploit.c
ptr_to_u64
called by 35
CVE-2020-8835/exp/exp_multi_core.c
die
called by 33
CVE-2021-4154/exploit/exploit-ROP.c
debug
called by 26
CVE-2017-6074/exp.c
errExit
called by 26
CVE-2022-0995/exploit.c

Shape

Class 964
Function 847
Enum 110

Languages

C61%
C++39%

Modules by API surface

CVE-2025-21702/exploit/exploit.c106 symbols
CVE-2022-27666/exploit/exploit.c97 symbols
CVE-2022-27666/exploit/libfuse/fuse_kernel.h67 symbols
CVE-2022-0185/exploit/libfuse/fuse_kernel.h67 symbols
CVE-2021-41073/exploit/libfuse/fuse_kernel.h67 symbols
CVE-2026-23271/exploit/exploit.cpp65 symbols
CVE-2021-3490/exp/5.11/bpf.h58 symbols
CVE-2021-31440/exp/bpf.h58 symbols
CVE-2022-2639/exploit.c48 symbols
CVE-2022-34918/exploit/exploit.c47 symbols
CVE-2020-8835/exp/bpf.h47 symbols
CVE-2020-27194/exp/bpf.h47 symbols

For agents

$ claude mcp add kernel-exploit-factory \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact