Skip to content
Back to skills

Ios Exploiting

ASecurity

iOS exploitation: jailbreak, dylib injection, keychain theft

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 29, 2026
securityjavascriptgojavabashspringtestingdebugginggitapisecurity

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 29, 2026

npx -y skills add blackfoxxx/kestrel --skill ios-exploiting --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ios Exploiting?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ios Exploiting
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/blackfoxxx-ios-exploiting/badge)](https://www.skillsdirectory.com/skills/blackfoxxx-ios-exploiting)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ios-exploiting
description: "iOS exploitation: jailbreak, dylib injection, keychain theft"
metadata: 
tags: "ios,kernel,exploit,pac,sandbox-escape,webkit,jailbreak,tfp0,privilege-escalation,security-research"
category: mobile
mcps: pentest mcp, context1337, autopen
---

# iOS Kernel Exploit Methodology

> **Scope**: This skill covers iOS security research and exploit development for authorized testing and educational purposes. Focus: PAC bypass, sandbox escape, WebKit exploitation chain, and kernel privilege escalation.

## iOS Security Architecture Overview

```
User Space
├─ App Sandbox (each app isolated)
├─ System daemons (launchd, backboardd, SpringBoard)
└─ libSystem (userspace syscall interface)
           ↓ syscall interface
Kernel Space (XNU)
├─ BSD subsystem (file system, process management)
├─ Mach (IPC, tasks, threads)
├─ IOKit (driver framework)
└─ Sandbox (MAC framework)
```

### Key Security Mechanisms

| Mechanism | Description | Bypass Difficulty |
|-----------|-------------|-------------------|
| PAC (ARM8.3+) | Pointer Authentication Code — prevents ROP/JOP | High — hardware-level |
| Sandbox | App isolation (MAC framework) | Requires kernel priv |
| ASLR | Address Space Layout Randomization | Needs kernel exploit or info leak |
| KASLR | Kernel ASLR | Needs kernel info leak |
| KPP/AMCC | Kernel Page Protection — prevents kernel code modification | High on A10+ |
| PPL (Page Protection Layer) | Prevents unauthorized page table modification (A12+) | Very high |
| KTRR | Kernel Text Read-only Region | Hardware-level |
| Pointer Masking | Mask unused high bits of kernel pointers | Varies |

---

## Phase 1: Exploitation Entry Points

### 1.1 WebKit Exploitation (Browser/WebView)

The most common remote code execution path:

```
Attacker-controlled webpage → WebKit parse/JIT vuln → Renderer process RCE
                           → Sandbox escape (IPC with privileged process)
                           → Kernel exploit → tfp0 (task-for-pid 0)
                           → Full control
```

WebKit attack surface:
- JavaScript JIT compiler (most exploited)
- CSS parser
- HTML parser
- WebGL / GPU process
- IndexedDB / Web Storage

```javascript
// PAC-aware exploitation: JIT spraying for PAA bypass
// pac_bti combined with JIT — target must mark code as executable
// WKWebView isolates renderer, requires sandbox escape to elevate
```

### 1.2 Local Privilege Escalation (App to Kernel)

Requires running code on the device (jailbreak/pentest scenario):

| Attack Surface | Example CVEs |
|----------------|-------------|
| IOKit user client | CVE-2021-30983, CVE-2022-32917 |
| Mach messages | CVE-2020-27932, CVE-2021-30737 |
| XNU syscalls | Multiple over the years |
| Memory pressure | CVE-2023-23536 |

### 1.3 IPC and Mach Port Exploitation

Mach ports are the inter-process communication mechanism — a task with `task_for_pid(0)` can read/write any kernel memory:

```c
// Core privileged primitives
task_for_pid(0)           // tfp0 — the kernel task port
mach_vm_read()            // read kernel memory
mach_vm_write()           // write kernel memory
mach_vm_allocate()        // allocate kernel memory
host_get_special_port()   // get host special ports (privileged)
```

---

## Phase 2: PAC (Pointer Authentication Codes) Analysis

### PAC Architecture

ARM8.3 introduced 5-bit PAC — pointers have signature bits embedded in unused high bits:

```
64-bit pointer: [PAC bits (top)][Physical address bits (bottom)]
                     ↑
              Generated by: PACIA/PACIB/PACDA/PACDB instructions
              Validated by: AUTIA/AUTIB/AUTDA/AUTDB instructions
              Stripped by: XPACLRI / XPACI / XPACD
```

PAC key types:
- **IA/IB**: Instruction Address keys (for code pointers / function pointers)
- **DA/DB**: Data Address keys (for data pointers)
- **GA**: Generic Authentication (for MACs)

### PAC Bypass Strategies

```
PAC bypass path?
├─ Reuse existing signed pointers (ROP gadgets still work if they don't modify PAC)
├─ Type confusion — create fake object where PAC isn't validated
├─ JIT code — JIT-generated code might not have PAC applied
├─ Kernel data-only attacks — modify data, not code (doesn't trigger PAC)
│   └─ Modify credentials struct / sandbox policy in kernel
└─ Forge PAC (requires knowing key — practical only in some contexts)
    └─ Key extraction via side-channel (theoretical)
```

### Common Bypass Techniques

**Data-Only Exploitation** (most practical for kernel exploits):
Instead of hijacking control flow (blocked by PAC), modify kernel data structures directly:
- Modify `cred` structure → escalate privileges
- Modify sandbox policy → escape sandbox
- Modify `task_policy` → remove restrictions

```
Kernel write primitive → target kernel data structures
├─ task.itk_self (task port)
├─ proc.p_ucred (credentials)
├─ mac_label (sandbox label)
└─ vm_map (virtual memory mappings)
```

---

## Phase 3: Sandbox Escape

### iOS App Sandbox Restriction Scope

```
Restricted:
├─ Filesystem access outside app container
├─ Mach ports of other processes (without entitlements)
├─ IOKit userclients (most)
├─ Network connections (some — controlled by entitlements)
└─ Location, camera, microphone (without permissions)
```

### Sandbox Escape Paths

```
Escape path?
├─ Mach IPC to privileged service
│   ├─ XPC services with elevated privileges
│   ├─ MIG (Mach Interface Generator) APIs
│   └─ Bootstrap server lookup
├─ IOKit userclients accessible from sandbox
│   └─ IOSurface, IOHIDFamily, AGX (GPU driver)
├─ Kernel exploit directly (from compromised renderer)
└─ Logic bugs in platform binaries
    └─ Bugs in daemons that accept sandbox IPC
```

### Real-world Escape Chain

Typical WebKit-to-root chain:
1. **WebKit RCE** → code execution in renderer sandbox (iOS 16+: WebContent process)
2. **Sandbox Escape** → exploit IPC bug with platform daemon
3. **Kernel Exploit** → obtain tfp0
4. **Post-tfp0** → patch sandbox / escalate to root / install persistence

---

## Phase 4: Kernel Exploitation Primitives

### Standard Exploitation Primitives

For any kernel exploit, need to establish:

```
1. Kernel read primitive  → read arbitrary kernel memory
2. Kernel write primitive → write arbitrary kernel memory
3. Code execution (optional — often replaced by data-only exploitation)
```

### Heap Grooming / Heap Feng Shui

XNU uses zone allocator — objects of the same size share zones:

```c
// Control heap layout to get UAF/heap spray at predictable address
// 1. Fill holes in target zone
// 2. Trigger allocation of target object
// 3. Free some objects to create controllable gap
// 4. Allocate fake object to fill gap
```

### Common Exploitation Targets

| Target | Purpose |
|--------|---------|
| `ipc_port` | Mach port object — control exposes everything |
| `ipc_object` | Port set |
| `task` | Process task struct |
| `proc` | BSD process |
| `vm_map_entry` | VM mapping — control → arbitrary r/w |
| `OSData` | IOKit data container — often confused with other types |

---

## Phase 5: WebKit Exploitation Techniques

### JIT Compiler Attacks

Modern JIT compilers are complex and have historically had many bugs:

```javascript
// Type confusion via optimization:
// Make JIT assume a variable is always type A,
// then switch it to type B → type mismatch allows OOB access
function jit_vuln(arr, idx) {
  // This gets JIT-compiled with type assumptions
  return arr[idx].field;
}
// Call many times to trigger JIT compilation
for (let i = 0; i < 10000; i++) jit_vuln([{field: 1}], 0);
// Now trigger type confusion
```

### ArrayBuffer / TypedArray Exploitation

After getting type confusion or OOB write, typical primitive is to control an ArrayBuffer's backing store pointer:

```javascript
// 1. Get OOB write
// 2. Overwrite ArrayBuffer's byteLength with large value → OOB read
// 3. Overwrite ArrayBuffer's backing store ptr → arbitrary r/w
```

### WASM / JIT Region Exploitation (pre-iOS 14)

WASM and JIT regions were previously RWX — now they use two separate mappings.

---

## Phase 6: Post-Exploitation (Post-tfp0)

### Patching Sandbox

```c
// Method 1: Modify sandbox label (sandbox policy stored in kernel)
// Find task's mac_label
// Overwrite sandbox profile pointer

// Method 2: Set sandbox exception entitlement
// kernel_task → proc → p_lctx → sandbox allows rule override
```

### Escalating to Root

```c
// Method 1: Modify credentials
// proc.p_ucred → ucred.cr_posix.cr_uid = 0
// proc.p_ucred → ucred.cr_posix.cr_groups[0] = 0

// Method 2: Fake entitlements
// Inject entitlements into codesigning structures
```

### Achieving Persistence (Jailbreak)

Modern jailbreaks must work around:
- **KPP**: Can't modify kernel code
- **AMCC**: Memory controller enforces code signing
- **PPL**: Prevents page table modification

Modern approach: **rootless jailbreak**
- Don't touch /System/Library (protected by SSV)
- Install into `/var/jb/` (custom volume mount point)
- Use fake filesystems / bind mounts

---

## Phase 7: Vulnerability Research Tools

### Fuzzing

```bash
# Syzkaller for iOS kernel fuzzing (requires modification for iOS)
# libfuzzer for userspace
# Jackalope (Windows/macOS/Linux, some iOS support)

# Manual IPC fuzzing
# joern for code analysis
# IDA / Ghidra for reverse engineering
```

### IOKit Attack Surface Enumeration

```bash
# List user clients accessible from sandbox
# iocheck (requires jailbroken device)
iocheck

# Enumerate IOKit registry
ioclasscount all | sort -n

# iometa — parse IOKit vtables
iometa -A kernel_cache IOService
```

### Kernel Debugging Setup

```bash
# Two devices needed:
# 1. Device under test (DUT) — with JTAG / kdp
# 2. Debugger device

# LLDB kernel debugging
lldb --kdp-remote device-ip
(lldb) command script import lldbmacros/core/xnu.py
(lldb) showallprocs
```

---

## iOS Version Exploit Landscape

| iOS Version | Notable Exploits / Jailbreak Tools | PAC |
|-------------|-----------------------------------|-----|
| iOS 14 | Taurine (Odyssey), unc0ver | IA-only (A12+) |
| iOS 15 | Palera1n (A11-), Cheyote (beta) | IA + DA (A12+) |
| iOS 16 | Palera1n (A11-), Dopamine (A12+, 16.0–16.6.1) | Full PAC |
| iOS 17 | No stable public jailbreak (as of 2025) | Full PAC |

---

## References

- [Apple Platform Security Guide](https://support.apple.com/guide/security/welcome/web)
- [Project Zero iOS Research](https://googleprojectzero.blogspot.com)
- [Brandon Azad's PAC Writeups](https://googleprojectzero.blogspot.com/search/label/iOS)
- [CVE Details iOS Vulnerabilities](https://www.cvedetails.com/product/15556/Apple-Iphone-Os.html)
- [Siguza's iOS Research](https://siguza.github.io)

Files in this skill

  • SKILL.md10.6 KB
  • references/ios-exploit-mitigations.md7.3 KB
  • references/ios-kernel-heap.md6.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in security →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.