如何骗过PackageKit拿到Root(CVE-2026-41651)

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

文章总结: PackageKit存在高危TOCTOU权限提升漏洞CVE-2026-41651,攻击者通过异步D-Bus请求构造竞态条件,在polkit授权后替换安装参数,从而以root权限执行任意代码。影响1.0.2至1.3.4版本,官方修复方案为在事务处理中增加状态守卫机制。360漏洞研究院已成功复现该漏洞并提供详细技术分析。 综合评分: 88 文章分类: 漏洞分析,技术标准,解决方案,漏洞预警,实战经验


cover_image

如何骗过 PackageKit 拿到 Root(CVE-2026-41651)

原创

360漏洞研究院 360漏洞研究院

360漏洞研究院

2026年4月27日 11:04 四川

在小说阅读器读本章

去阅读

“扫描下方二维码,进入公众号粉丝交流群。更多一手网安资讯、漏洞预警、技术干货和技术交流等您参与!”

PackageKit 曝出高危本地权限提升漏洞(CVE-2026-41651,CVSS 8.8),本地普通用户通过构造特制的异步 D-Bus 请求利用 TOCTOU 竞态缺陷,可绕过 polkit 授权验证,以 root 权限安装恶意软件包并执行任意指令。

目前 360漏洞挖掘智能体已成功复现该漏洞。本文包含完整影响范围、修复方案、技术原理与复现细节,建议用户立即升级。

| | | | | | — | — | — | — | | 漏洞概述 | | | | | 漏洞名称 | PackageKit TOCTOU 本地权限提升漏洞 | | | | 漏洞编号 | CVE-2026-41651 | | | | 公开时间 | 2026-04-22 | POC状态 | 已公开 | | 漏洞类型 | 权限提升 | EXP状态 | 已公开 | | 利用可能性 | 高 | 技术细节状态 | 已公开 | | CVSS 3.1 | 8.8 | 在野利用状态 | 未发现 |

01

漏洞影响范围

受影响的软件版本:

1.0.2 <= PackageKit <= 1.3.4

02

修复建议

正式防护方案

官方发布了正式的修复Patch,详情如下:

@@ -5250,14&nbsp;+5250,32&nbsp;@@ pk_transaction_method_call (GDBusConnection *connection_, const gchar *sender,&nbsp; &nbsp; pk_transaction_set_hints (transaction, parameters, invocation);return;&nbsp; }- &nbsp;if&nbsp;(g_strcmp0 (method_name,&nbsp;"AcceptEula") ==&nbsp;0) {- &nbsp; &nbsp;pk_transaction_accept_eula (transaction, parameters, invocation);- &nbsp; &nbsp;return;- &nbsp;}if&nbsp;(g_strcmp0 (method_name,&nbsp;"Cancel") ==&nbsp;0) {&nbsp; &nbsp; pk_transaction_cancel (transaction, parameters, invocation);return;&nbsp; }++ &nbsp;/* All action methods below must only be invoked once on a new transaction.+ &nbsp; * Reject&nbsp;any&nbsp;attempt to re-invoke them after the transaction has been initialized,+ &nbsp; * preventing situations where a second D-Bus call could overwrite transaction flags+ &nbsp; * (or&nbsp;other cached state) after authorization has already been granted&nbsp;for&nbsp;the previous+ &nbsp; * request based on the old parameters. */+ &nbsp;if&nbsp;(transaction->state != PK_TRANSACTION_STATE_NEW) {+ &nbsp; &nbsp;g_dbus_method_invocation_return_error (invocation,+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PK_TRANSACTION_ERROR,+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PK_TRANSACTION_ERROR_INVALID_STATE,+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;"cannot call %s on transaction %s: "+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;"already in state %s",+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; method_name,+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; transaction->tid,+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pk_transaction_state_to_string (transaction->state));+ &nbsp; &nbsp;return;+ &nbsp;}++ &nbsp;if&nbsp;(g_strcmp0 (method_name,&nbsp;"AcceptEula") ==&nbsp;0) {+ &nbsp; &nbsp;pk_transaction_accept_eula (transaction, parameters, invocation);+ &nbsp; &nbsp;return;+ &nbsp;}if&nbsp;(g_strcmp0 (method_name,&nbsp;"DownloadPackages") ==&nbsp;0) {&nbsp; &nbsp; pk_transaction_download_packages (transaction, parameters, invocation);return;

在 pk_transaction_method_call() 中,所有动作方法(InstallFiles、InstallPackages、RemovePackages 等)统一前置状态守卫。事务离开 NEW 状态后,任何动作方法的重复调用均立即以 INVALID_STATE 错误拒绝。第二次 InstallFiles() 调用在 Bug 1 发生前即被拒绝,整条攻击链断裂。同时将 AcceptEula 方法移入状态守卫范围(原版在守卫之前),收紧了整体防护边界。

03

漏洞描述

4月22日,有研究人员公开了漏洞CVE-2026-41651详情。这是一个由三个独立缺陷组合而成的利用,形成典型的 TOCTOU(检查时间/使用时间)竞态窗口。在 polkit 完成授权决策之后,后端实际执行安装操作之前,攻击者可以将授权时使用的”模拟安装”参数替换为”真实安装+恶意载荷”参数,从而以 root 权限安装任意软件包(包括执行 postinst 脚本),实现本地权限提升。

根因分析

漏洞位于src/pk-transaction.c文件中。

Bug 1 — InstallFiles() 无条件覆写缓存参数(文件第 4036 行)

/* src/pk-transaction.c, pk_transaction_install_files() */
// 无任何状态检查,直接覆写transaction->cached_transaction_flags = transaction_flags; &nbsp;&nbsp;// ← Bug 1transaction->cached_full_paths = g_strdupv (full_paths); &nbsp; &nbsp;&nbsp;// ← Bug 1
pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_FILES);
/* 尝试获取 polkit 授权 */ret = pk_transaction_obtain_authorization (transaction,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PK_ROLE_ENUM_INSTALL_FILES,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&error);

InstallFiles() D-Bus 方法处理函数在写入 cached_transaction_flags(事务标志)和 cached_full_paths(安装路径)时,没有检查事务当前所处的状态。这意味着即使事务已处于 READY 或 RUNNING 状态,第二次 InstallFiles() 调用仍会无条件覆写这两个字段。

Bug 2 — 状态机静默丢弃,非法逆向转换(文件第 873–882 行)

/* src/pk-transaction.c, pk_transaction_set_state() */
voidpk_transaction_set_state(PkTransaction *transaction, PkTransactionState state){/* 检查不能回退 */if&nbsp;(transaction->state !=&nbsp;PK_TRANSACTION_STATE_UNKNOWN&nbsp;&&&nbsp; &nbsp; &nbsp; &nbsp; transaction->state > state) {&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;g_warning&nbsp;("cannot set %s, as already %s",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pk_transaction_state_to_string&nbsp;(state),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pk_transaction_state_to_string&nbsp;(transaction->state));return; &nbsp;// ← 只打日志,静默返回,不报错&nbsp; &nbsp; }&nbsp; &nbsp; ...}

第二次 InstallFiles(NONE, payload) 调用结束时,代码试图将状态设置为 WAITING_FOR_AUTH(等待 polkit)。但由于事务已处于 READY 状态(由第一次调用设置),READY > WAITING_FOR_AUTH,set_state() 静默丢弃 此次转换并直接返回——不报错,不回滚。此时 cached_transaction_flags 已被覆写为 NONE(无 SIMULATE 标志),但状态仍为 READY。

Bug 3 — 调度时读取标志而非授权时读取(文件第 2273–2277 行)

/* src/pk-transaction.c, pk_transaction_run() — 由 GLib idle 回调触发 */
case&nbsp;PK_ROLE_ENUM_INSTALL_FILES:&nbsp; &nbsp;&nbsp;pk_backend_install_files&nbsp;(transaction->backend,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; transaction->job,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; transaction->cached_transaction_flags, &nbsp;// ← Bug 3: 此时已被覆写&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; transaction->cached_full_paths); &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;// ← 此时已指向 payloadbreak;

pk_transaction_run() 在 GLib 的 g_idle_add() 回调中被调用,在调度执行时才读取 cached_transaction_flags,而不是在 polkit 授权时读取它们。

SIMULATE 标志绕过 polkit 检查(文件第 2893–2900 行)

/* src/pk-transaction.c, pk_transaction_obtain_authorization() */
if&nbsp;(pk_bitfield_contain (transaction->cached_transaction_flags,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD) ||&nbsp; &nbsp; &nbsp; &nbsp; pk_bitfield_contain (transaction->cached_transaction_flags,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PK_TRANSACTION_FLAG_ENUM_SIMULATE) || &nbsp;&nbsp;// ← bit 2, value = 0x4&nbsp; &nbsp; &nbsp; &nbsp; transaction->skip_auth_check ==&nbsp;TRUE) {&nbsp; &nbsp; g_debug ("No authentication required");&nbsp; &nbsp; pk_transaction_set_state (transaction, PK_TRANSACTION_STATE_READY);return&nbsp;TRUE; &nbsp;// polkit 完全跳过}

PK_TRANSACTION_FLAG_ENUM_SIMULATE(bit 2,值 0x4)被设计为”模拟安装预演”,无需实际权限。当 flags 中包含此位时,polkit 检查被完全跳过,状态直接设为 READY,并由 GLib 调度执行(g_idle_add)。这是触发整条攻击链的起点。

漏洞触发时序

两次 InstallFiles() 调用作为异步 D-Bus 调用发送,在客户端主循环开始处理之前发出。这保证两个消息都会先进入服务器 socket,再触发 GLib idle 回调——无需竞争条件。

polkitd 最终会对第二个调用返回 NOT\_AUTHORIZED,但此时 APT 已经开始执行安装。该错误是预期行为且无害。

就这样,通过两次执行InstallFiles() 调用完成攻击,在第一次执行绕过 polkit,使事务进入 READY 状态并注册 idle 调度,在第二次执行,在 idle 触发前覆写 cached_flags 和 cached_full_paths,使得事务真正被执行。

04

漏洞复现

360 漏洞研究院已成功复现 PackageKit TOCTOU 本地权限提升漏洞(CVE-2026-41651)。本次复现使用 Docker 环境隔离,构建含漏洞版本 PackageKit 1.3.4(commit 2149735)的镜像。

环境说明:

  • 宿主系统 PackageKit 1.2.5-2ubuntu3.1(已含安全反向移植补丁,直接运行漏洞利用无效)
  • Docker 镜像内运行纯净 Ubuntu 24.04 + PackageKit 1.3.4 源码编译版

CVE-2026-41651 PackageKit TOCTOU 本地权限提升漏洞复现

05

时间线

2026年04月27日,360漏洞研究院发布本安全风险通告。

06

参考链接

https://www.cve.org/CVERecord?id=CVE-2026-41651

07

更多漏洞情报

建议您订阅360数字安全-漏洞情报服务,获取更多漏洞情报详情以及处置建议,让您的企业远离漏洞威胁。

邮箱:[email protected]

网址:https://vi.loudongyun.360.net

“洞”悉网络威胁,守护数字安全

关于我们

360 漏洞研究院,隶属于360数字安全集团。其成员常年入选谷歌、微软、华为等厂商的安全精英排行榜, 并获得谷歌、微软、苹果史上最高漏洞奖励。研究院是中国首个荣膺Pwnie Awards“史诗级成就奖”,并获得多个Pwnie Awards提名的组织。累计发现并协助修复谷歌、苹果、微软、华为、高通等全球顶级厂商CVE漏洞3000多个,收获诸多官方公开致谢。研究院也屡次受邀在BlackHat,Usenix Security,Defcon等极具影响力的工业安全峰会和顶级学术会议上分享研究成果,并多次斩获信创挑战赛、天府杯等顶级黑客大赛总冠军和单项冠军。研究院将凭借其在漏洞挖掘和安全攻防方面的强大技术实力,帮助各大企业厂商不断完善系统安全,为数字安全保驾护航,筑造数字时代的安全堡垒。


免责声明:

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

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

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

本文转载自:360漏洞研究院 360漏洞研究院 360漏洞研究院《如何骗过 PackageKit 拿到 Root(CVE-2026-41651)》

评论:0   参与:  0