PPL — Page Protection Layer
PPL là execution context chạy tại EL1 nhưng với privilege cao hơn kernel thông thường. PPL bảo vệ page tables và code signing verification. A12 đến A14 (replaced by SPTM trên A15+).
Cơ Chế
Concept
Normal kernel code (EL1):
✗ Không thể modify page tables trực tiếp
✗ Không thể thay đổi code signing state
✗ Không thể map executable pages
PPL code (EL1, special mode):
✓ Full access to page tables
✓ Code signing verification
✓ Manage pmap structures
Transition: kernel → PPL qua gated call interface
ppl_enter() → switch to PPL context
PPL operation
ppl_leave() → return to normal kernel
Implementation
PPL dùng APRR (Apple Page Protection Register) để thay đổi permissions
tùy thuộc vào execution context:
Normal kernel: page table pages = read-only
PPL context: page table pages = read-write
APRR remaps permission bits per-EL:
- Kernel code reading page table → APRR says "read-only"
- PPL code reading page table → APRR says "read-write"
Protected Operations
Qua PPL:
- pmap_enter() → create page table entries
- pmap_remove() → remove page table entries
- pmap_protect() → change page permissions
- Code signing page verification
- Trust cache management
NOT qua PPL:
- Normal kernel memory allocation (kalloc, zalloc)
- Process scheduling
- File I/O
- Networking
Tại Sao PPL Quan Trọng Cho Exploitation
Không có PPL:
kernel r/w → modify page table → map executable page → run arbitrary code
Có PPL:
kernel r/w → CÓ THỂ ĐỌC page tables nhưng KHÔNG THỂ GHI
→ Cần PPL bypass để modify page tables
→ Cần PPL bypass để inject executable code
PPL Bypass Techniques
1. Operation Triangulation (2023)
- Exploit sử dụng UNDOCUMENTED hardware MMIO registers
- Registers cho phép modify page table entries WITHOUT going through PPL
- Apple không biết registers này tồn tại (hoặc quên protect)
- Fix: Apple removed/protected these registers
Impact: Full PPL bypass → map any physical address → code execution
2. PPL Logic Bugs
- Bug trong PPL code itself
- PPL is C code → có thể có bugs
- Nhưng PPL codebase nhỏ → ít attack surface
Ví dụ:
- pmap_enter với crafted arguments → bypass checks
- Race condition trong PPL transition
3. Physical Memory Attack (Pre-SPTM)
Với physrw (physical read/write):
- PPL protects page tables via APRR (virtual permission remapping)
- Nhưng physrw bypasses virtual permissions entirely
- → Directly modify page table physical memory
- → PPL protection ineffective against physical access
Đây là lý do Apple replace PPL bằng SPTM:
SPTM chạy tại EL2 → controls physical page types
→ Physrw qua dangling user page CANNOT touch kernel/page-table pages
Dopamine PPL Bypass
Dopamine jailbreak (iOS 15-16):
1. kfd exploit → kernel read/write
2. PPL bypass dựa trên Operation Triangulation technique:
- Dùng hardware MMIO registers modify page tables
3. Trust cache injection (giờ có thể vì page table control)
4. Rootless jailbreak installation
Tài Nguyên
- Project Zero — The Core of Apple is PPL
- Quarkslab — Modern Jailbreaks Post-Exploitation
- Kaspersky — Operation Triangulation technical analysis