Skip to content

Commit 06a6881

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks
2 parents 25b59b3 + 468610b commit 06a6881

File tree

35 files changed

+2049
-50
lines changed

35 files changed

+2049
-50
lines changed

src/SUMMARY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
- [RoguePotato, PrintSpoofer, SharpEfsPotato, GodPotato](windows-hardening/windows-local-privilege-escalation/roguepotato-and-printspoofer.md)
267267
- [SeDebug + SeImpersonate copy token](windows-hardening/windows-local-privilege-escalation/sedebug-+-seimpersonate-copy-token.md)
268268
- [SeImpersonate from High To System](windows-hardening/windows-local-privilege-escalation/seimpersonate-from-high-to-system.md)
269+
- [Semanagevolume Perform Volume Maintenance Tasks](windows-hardening/windows-local-privilege-escalation/semanagevolume-perform-volume-maintenance-tasks.md)
269270
- [Windows C Payloads](windows-hardening/windows-local-privilege-escalation/windows-c-payloads.md)
270271
- [Active Directory Methodology](windows-hardening/active-directory-methodology/README.md)
271272
- [Abusing Active Directory ACLs/ACEs](windows-hardening/active-directory-methodology/acl-persistence-abuse/README.md)
@@ -497,6 +498,7 @@
497498
- [Harvesting tickets from Windows](network-services-pentesting/pentesting-kerberos-88/harvesting-tickets-from-windows.md)
498499
- [Harvesting tickets from Linux](network-services-pentesting/pentesting-kerberos-88/harvesting-tickets-from-linux.md)
499500
- [Wsgi](network-services-pentesting/pentesting-web/wsgi.md)
501+
- [Zabbix](network-services-pentesting/pentesting-web/zabbix.md)
500502
- [110,995 - Pentesting POP](network-services-pentesting/pentesting-pop.md)
501503
- [111/TCP/UDP - Pentesting Portmapper](network-services-pentesting/pentesting-rpcbind.md)
502504
- [113 - Pentesting Ident](network-services-pentesting/113-pentesting-ident.md)
@@ -765,6 +767,7 @@
765767
- [Physical Attacks](hardware-physical-access/physical-attacks.md)
766768
- [Escaping from KIOSKs](hardware-physical-access/escaping-from-gui-applications.md)
767769
- [Firmware Analysis](hardware-physical-access/firmware-analysis/README.md)
770+
- [Android Mediatek Secure Boot Bl2 Ext Bypass El3](hardware-physical-access/firmware-analysis/android-mediatek-secure-boot-bl2_ext-bypass-el3.md)
768771
- [Bootloader testing](hardware-physical-access/firmware-analysis/bootloader-testing.md)
769772
- [Firmware Integrity](hardware-physical-access/firmware-analysis/firmware-integrity.md)
770773

@@ -857,6 +860,7 @@
857860
- [iOS Exploiting](binary-exploitation/ios-exploiting/README.md)
858861
- [ios CVE-2020-27950-mach_msg_trailer_t](binary-exploitation/ios-exploiting/CVE-2020-27950-mach_msg_trailer_t.md)
859862
- [ios CVE-2021-30807-IOMobileFrameBuffer](binary-exploitation/ios-exploiting/CVE-2021-30807-IOMobileFrameBuffer.md)
863+
- [Imessage Media Parser Zero Click Coreaudio Pac Bypass](binary-exploitation/ios-exploiting/imessage-media-parser-zero-click-coreaudio-pac-bypass.md)
860864
- [ios Corellium](binary-exploitation/ios-exploiting/ios-corellium.md)
861865
- [ios Heap Exploitation](binary-exploitation/ios-exploiting/ios-example-heap-exploit.md)
862866
- [ios Physical UAF - IOSurface](binary-exploitation/ios-exploiting/ios-physical-uaf-iosurface.md)

src/binary-exploitation/ios-exploiting/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,6 @@ From the screenshot:
850850
| `default.kalloc.32` | 32 bytes | Small structs, object headers. |
851851
| `default.kalloc.64` | 64 bytes | IPC messages, tiny kernel buffers. |
852852
| `default.kalloc.128` | 128 bytes | Medium objects like parts of `OSObject`. |
853-
| `default.kalloc.256` | 256 bytes | Larger IPC messages, arrays, device structures. |
854853
||||
855854
| `default.kalloc.1280`| 1280 bytes | Large structures, IOSurface/graphics metadata. |
856855

@@ -1191,4 +1190,10 @@ If you want to check for vulnerabilities in a specific version of iOS, you can c
11911190
For example, the versions `15.1 RC`, `15.1` and `15.1.1` use the version `Darwin Kernel Version 21.1.0: Wed Oct 13 19:14:48 PDT 2021; root:xnu-8019.43.1~1/RELEASE_ARM64_T8006`.
11921191

11931192

1193+
### iMessage/Media Parser Zero-Click Chains
1194+
1195+
{{#ref}}
1196+
imessage-media-parser-zero-click-coreaudio-pac-bypass.md
1197+
{{#endref}}
1198+
11941199
{{#include ../../banners/hacktricks-training.md}}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# iMessage Media Parser Zero-Click → CoreAudio RCE → PAC/RPAC → Kernel → CryptoTokenKit Abuse
2+
3+
{{#include ../../banners/hacktricks-training.md}}
4+
5+
This page summarizes a modern iOS zero-click attack surface and an observed end-to-end exploitation chain abusing iMessage automatic media parsing to compromise CoreAudio, bypass BlastDoor, defeat Pointer Authentication (PAC) via an RPAC path, escalate to kernel, and finally abuse CryptoTokenKit for unauthorized key uses.
6+
7+
> Warning: This is an educational summary to help defenders, researchers, and red teams understand the techniques. Do not use offensively.
8+
9+
## High-level chain
10+
11+
- Delivery vector: a malicious audio attachment (e.g., .amr / MP4 AAC) sent via iMessage/SMS.
12+
- Auto-ingestion: iOS auto-parses media for previews and conversions without user interaction.
13+
- Parser bug: malformed structures hit CoreAudio’s AudioConverterService and corrupt heap memory.
14+
- Code exec in media context: RCE inside the media parsing process; reported to bypass BlastDoor isolation in specific paths (e.g., “known sender” framing path).
15+
- PAC/RPAC bypass: once arbitrary R/W is achieved, a PAC bypass in the RPAC path enables stable control flow under arm64e PAC.
16+
- Kernel escalation: the chain converts userland exec into kernel exec (e.g., via wireless/AppleBCMWLAN code paths and AMPDU handling as seen in logs below).
17+
- Post-exploitation: with kernel, abuse CryptoTokenKit to perform signing with Secure Enclave–backed keys, read sensitive data paths (Keychain contexts), intercept messages/2FA, silently authorize actions, and enable stealth surveillance (mic/camera/GPS) without prompts.
18+
19+
## iMessage/BlastDoor attack surface notes
20+
21+
BlastDoor is a hardened service designed to parse untrusted message content. However, observed logs indicate paths where protections may be bypassed when messages are framed from a “known sender” and when additional filters (e.g., Blackhole) are relaxed:
22+
23+
```text
24+
IDSDaemon BlastDoor: Disabled for framing messages
25+
SpamFilter Blackhole disabled; user has disabled filtering unknown senders.
26+
```
27+
28+
Takeaways:
29+
- Auto-parsing still represents a remote, zero-click attack surface.
30+
- Policy/context decisions (known sender, filtering state) can materially change the effective isolation.
31+
32+
## CoreAudio: AudioConverterService heap corruption (userland RCE)
33+
34+
Affected component:
35+
- CoreAudio → AudioConverterService → AAC/AMR/MP4 parsing and conversion flows
36+
37+
Observed parser touchpoint (logs):
38+
39+
```text
40+
AudioConverterService ACMP4AACBaseDecoder.cpp: inMagicCookie=0x0, inMagicCookieByteSize=39
41+
```
42+
43+
Technique summary:
44+
- Malformed container/codec metadata (e.g., invalid/short/NULL magic cookie) causes a memory corruption during decode setup.
45+
- Triggers in the iMessage media conversion path without taps by the user.
46+
- Yields code execution in the media parsing process. The write-up claims this escapes BlastDoor in the observed delivery path, enabling the next stage.
47+
48+
Practical tips:
49+
- Fuzz AAC/AMR magic cookie and MP4 codec atoms when targeting AudioConverterService conversions.
50+
- Focus on heap overflows/underflows, OOB reads/writes, and size/length confusion around decoder initialization.
51+
52+
## PAC bypass via RPAC path (CVE-2025-31201)
53+
54+
arm64e Pointer Authentication (PAC) impedes hijacking of return addresses and function pointers. The chain reports defeating PAC using an RPAC path once arbitrary read/write is available.
55+
56+
Key idea:
57+
- With arbitrary R/W, attackers can craft valid, re-signed pointers or pivot execution to PAC-tolerant paths. The so-called “RPAC path” enables control-flow under PAC constraints, turning a userland RCE into a reliable kernel exploit setup.
58+
59+
Notes for researchers:
60+
- Collect info leaks to defeat KASLR and stabilize ROP/JOP chains even under PAC.
61+
- Target callsites that generate or authenticate PAC in controllable ways (e.g., signatures generated on attacker-controlled values, predictable context keys, or gadget sequences that re-sign pointers).
62+
- Expect Apple hardening variance by SoC/OS; reliability hinges on leaks, entropy, and robust primitives.
63+
64+
## Kernel escalation: wireless/AMPDU path example
65+
66+
In the observed chain, once in userland with memory corruption and a PAC bypass primitive, kernel control was achieved via code paths in the Wi‑Fi stack (AppleBCMWLAN) under malformed AMPDU handling. Example logs:
67+
68+
```text
69+
IO80211ControllerMonitor::setAMPDUstat unhandled kAMPDUStat_ type 14
70+
IO80211ControllerMonitor::setAMPDUstat unhandled kAMPDUStat_ type 13
71+
```
72+
73+
General technique:
74+
- Use userland primitives to build kernel R/W or controlled call paths.
75+
- Abuse reachable kernel surfaces (IOKit, networking/AMPDU, media shared memory, Mach interfaces) to achieve kernel PC control or arbitrary memory.
76+
- Stabilize by building read/write primitives and defeating PPL/SPTM constraints where applicable.
77+
78+
## Post-exploitation: CryptoTokenKit and identity/signing abuse
79+
80+
Once kernel is compromised, processes like identityservicesd can be impersonated and privileged cryptographic operations invoked via CryptoTokenKit without user prompts. Example logs:
81+
82+
```text
83+
CryptoTokenKit operation:2 algo:algid:sign:ECDSA:digest-X962:SHA256
84+
CryptoTokenKit <sepk:p256(d) kid=9a86778f7163e305> parsed for identityservicesd
85+
```
86+
87+
Impact:
88+
- Use Secure Enclave–backed keys for unauthorized signing (tokens, messages, payments), breaking trust models even if keys are not exported.
89+
- Intercept 2FA codes/messages silently; authorize payments/transfers; enable stealth mic/camera/GPS.
90+
91+
Defensive angle:
92+
- Treat post-kernel integrity breaks as catastrophic: enforce runtime attestation for CTK consumers; minimize ambient authority; verify entitlements at the point of use.
93+
94+
## Reproduction and telemetry hints (lab only)
95+
96+
- Delivery: send a crafted AMR/MP4-AAC audio to the target device via iMessage/SMS.
97+
- Observe telemetry for the foregoing log lines around parsing and wireless stack reactions.
98+
- Ensure devices are fully patched; only test in isolated lab setups.
99+
100+
## Mitigations and hardening ideas
101+
102+
- Patch level: iOS 18.4.1 reportedly fixes this chain; keep devices up to date.
103+
- Parser hardening: strict validation for codec cookies/atoms and lengths; defensive decoding paths with bounds checks.
104+
- iMessage isolation: avoid relaxing BlastDoor/Blackhole in “known sender” contexts for media parsing.
105+
- PAC hardening: reduce PAC-gadget availability; ensure signatures are bound to unpredictable contexts; remove PAC-tolerant bypassable patterns.
106+
- CryptoTokenKit: require post-kernel attestation and strong entitlements at call-time for key-bound operations.
107+
- Kernel surfaces: harden wireless AMPDU/status handling; minimize attacker-controlled inputs from userland after compromise.
108+
109+
## Affected versions (as reported)
110+
111+
- iOS 18.x prior to iOS 18.4.1 (April 16, 2025).
112+
- Primary: CoreAudio → AudioConverterService (media auto-parsing path via iMessage/SMS).
113+
- Chained: PAC/RPAC path and kernel escalation via AppleBCMWLAN AMPDU handling.
114+
115+
## References
116+
117+
- [iOS Crypto Heist repo (README)](https://github.com/JGoyd/iOS-Attack-Chain-CVE-2025-31200-CVE-2025-31201)
118+
- [Remote Crypto Attack Chain details](https://github.com/JGoyd/iOS-Attack-Chain-CVE-2025-31200-CVE-2025-31201/blob/main/Remote%20Crypto%20Attack%20Chain%20.md)
119+
120+
{{#include ../../banners/hacktricks-training.md}}

src/binary-exploitation/libc-heap/heap-memory-functions/free.md

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@
77
(No checks are explained in this summary and some case have been omitted for brevity)
88

99
1. If the address is null don't do anything
10-
2. If the chunk was mmaped, mummap it and finish
10+
2. If the chunk was mmaped, munmap it and finish
1111
3. Call `_int_free`:
1212
1. If possible, add the chunk to the tcache
1313
2. If possible, add the chunk to the fast bin
1414
3. Call `_int_free_merge_chunk` to consolidate the chunk is needed and add it to the unsorted list
1515

16-
## \_\_libc_free <a href="#libc_free" id="libc_free"></a>
16+
> Note: Starting with glibc 2.42, the tcache step can also take chunks up to a much larger size threshold (see “Recent glibc changes” below). This changes when a free lands in tcache vs. unsorted/small/large bins.
17+
18+
## __libc_free <a href="#libc_free" id="libc_free"></a>
1719

1820
`Free` calls `__libc_free`.
1921

2022
- If the address passed is Null (0) don't do anything.
2123
- Check pointer tag
22-
- If the chunk is `mmaped`, `mummap` it and that all
24+
- If the chunk is `mmaped`, `munmap` it and that all
2325
- If not, add the color and call `_int_free` over it
2426

2527
<details>
@@ -78,9 +80,9 @@ libc_hidden_def (__libc_free)
7880
7981
</details>
8082
81-
## \_int_free <a href="#int_free" id="int_free"></a>
83+
## _int_free <a href="#int_free" id="int_free"></a>
8284
83-
### \_int_free start <a href="#int_free" id="int_free"></a>
85+
### _int_free start <a href="#int_free" id="int_free"></a>
8486
8587
It starts with some checks making sure:
8688
@@ -121,7 +123,7 @@ _int_free (mstate av, mchunkptr p, int have_lock)
121123

122124
</details>
123125

124-
### \_int_free tcache <a href="#int_free" id="int_free"></a>
126+
### _int_free tcache <a href="#int_free" id="int_free"></a>
125127

126128
It'll first try to allocate this chunk in the related tcache. However, some checks are performed previously. It'll loop through all the chunks of the tcache in the same index as the freed chunk and:
127129

@@ -181,7 +183,7 @@ If all goes well, the chunk is added to the tcache and the functions returns.
181183

182184
</details>
183185

184-
### \_int_free fast bin <a href="#int_free" id="int_free"></a>
186+
### _int_free fast bin <a href="#int_free" id="int_free"></a>
185187

186188
Start by checking that the size is suitable for fast bin and check if it's possible to set it close to the top chunk.
187189

@@ -278,7 +280,7 @@ Then, add the freed chunk at the top of the fast bin while performing some check
278280
279281
</details>
280282
281-
### \_int_free finale <a href="#int_free" id="int_free"></a>
283+
### _int_free finale <a href="#int_free" id="int_free"></a>
282284
283285
If the chunk wasn't allocated yet on any bin, call `_int_free_merge_chunk`
284286
@@ -317,7 +319,7 @@ If the chunk wasn't allocated yet on any bin, call `_int_free_merge_chunk`
317319

318320
</details>
319321

320-
## \_int_free_merge_chunk
322+
## _int_free_merge_chunk
321323

322324
This function will try to merge chunk P of SIZE bytes with its neighbours. Put the resulting chunk on the unsorted bin list.
323325

@@ -383,7 +385,66 @@ _int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size)
383385
384386
</details>
385387
386-
{{#include ../../../banners/hacktricks-training.md}}
388+
---
389+
390+
## Attacker notes and recent changes (2023–2025)
391+
392+
- Safe-Linking in tcache/fastbins: `free()` stores the `fd` pointer of singly-linked lists using the macro `PROTECT_PTR(pos, ptr) = ((size_t)pos >> 12) ^ (size_t)ptr`. This means crafting a fake next pointer for tcache poisoning requires the attacker to know a heap address (e.g., leak `chunk_addr`, then use `chunk_addr >> 12` as the XOR key). See more details and PoCs in the tcache page below.
393+
- Tcache double-free detection: Before pushing a chunk into tcache, `free()` checks the per-entry `e->key` against the per-thread `tcache_key` and walks the bin up to `mp_.tcache_count` looking for duplicates, aborting with `free(): double free detected in tcache 2` when found.
394+
- Recent glibc change (2.42): The tcache grew to accept much larger chunks, controlled by the new `glibc.malloc.tcache_max_bytes` tunable. `free()` will now try to cache freed chunks up to that byte limit (mmapped chunks are not cached). This reduces how often frees fall into unsorted/small/large bins on modern systems.
395+
396+
### Quick crafting of a safe-linked fd (for tcache poisoning)
397+
398+
```py
399+
# Given a leaked heap pointer to an entry located at &entry->next == POS
400+
# compute the protected fd that points to TARGET
401+
protected_fd = TARGET ^ (POS >> 12)
402+
```
403+
404+
- For a full tcache poisoning walkthrough (and its limits under safe-linking), see:
405+
406+
{{#ref}}
407+
../tcache-bin-attack.md
408+
{{#endref}}
409+
410+
### Forcing frees to hit unsorted/small bins during research
411+
412+
Sometimes you want to avoid tcache entirely in a local lab to observe classic `_int_free` behaviour (unsorted bin consolidation, etc.). You can do this with GLIBC_TUNABLES:
387413

414+
```bash
415+
# Disable tcache completely
416+
GLIBC_TUNABLES=glibc.malloc.tcache_count=0 ./vuln
388417

418+
# Pre-2.42: shrink the maximum cached request size to 0
419+
GLIBC_TUNABLES=glibc.malloc.tcache_max=0 ./vuln
389420

421+
# 2.42+: cap the new large-cache threshold (bytes)
422+
GLIBC_TUNABLES=glibc.malloc.tcache_max_bytes=0 ./vuln
423+
```
424+
425+
Related reading within HackTricks:
426+
427+
- First-fit/unsorted behaviour and overlap tricks:
428+
429+
{{#ref}}
430+
../use-after-free/first-fit.md
431+
{{#endref}}
432+
433+
- Double-free primitives and modern checks:
434+
435+
{{#ref}}
436+
../double-free.md
437+
{{#endref}}
438+
439+
> Heads-up on hooks: Classic `__malloc_hook`/`__free_hook` overwrite techniques are not viable on modern glibc (≥ 2.34). If you still see them in older write-ups, adapt to alternative targets (IO_FILE, exit handlers, vtables, etc.). For background, check the page on hooks in HackTricks.
440+
441+
{{#ref}}
442+
../../arbitrary-write-2-exec/aw2exec-__malloc_hook.md
443+
{{#endref}}
444+
445+
## References
446+
447+
- GNU C Library – NEWS for 2.42 (allocator: larger tcache via tcache_max_bytes, mmapped chunks are not cached) <https://www.gnu.org/software/libc/NEWS.html#2.42>
448+
- Safe-Linking explanation and internals (Red Hat Developer, 2020) <https://developers.redhat.com/articles/2020/05/13/new-security-hardening-gnu-c-library>
449+
450+
{{#include ../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)