SPTM (Secure Page Table Monitor) và TXM (Trusted Execution Monitor) là mitigations thế hệ mới, chạy tại EL2 (hypervisor level). Chúng thay thế PPL và AMFI/CoreTrust tương ứng. Đây là rào cản lớn nhất hiện tại cho iOS exploitation.


SPTM — Secure Page Table Monitor

Architecture

Trước SPTM (PPL):                 Sau SPTM:
┌────────────────────┐            ┌────────────────────┐
│ EL0: Userspace     │            │ EL0: Userspace     │
├────────────────────┤            ├────────────────────┤
│ EL1: Kernel        │            │ EL1: Kernel        │
│  ├── Normal kernel │            │  └── Cannot touch  │
│  └── PPL (special  │            │      page tables   │
│       mode via APRR│            ├────────────────────┤
│       = page table │            │ EL2: SPTM          │
│       access)      │            │  └── Manages ALL   │
├────────────────────┤            │      page tables +  │
│ EL2: (unused)      │            │      page types     │
├────────────────────┤            ├────────────────────┤
│ EL3: Secure Monitor│            │ EL3: Secure Monitor│
└────────────────────┘            └────────────────────┘

Key Differences from PPL

Feature PPL SPTM
Execution level EL1 (special mode) EL2 (hypervisor)
Isolation mechanism APRR permission remapping True EL separation
Physical memory access Vulnerable to physrw Protected: page type tracking
Attack via kernel r/w Possible (access PPL data) Not possible (different address space)
Code location Kernel __TEXT Separate EL2 binary

Page Type Tracking

SPTM assigns type to every physical page:

Page types:
  SPTM_PAGE_FREE        — Not allocated
  SPTM_PAGE_USER        — Mapped to userspace process
  SPTM_PAGE_KERNEL      — Mapped to kernel
  SPTM_PAGE_TABLE       — Used as page table
  SPTM_PAGE_SPTM        — SPTM's own memory
  SPTM_PAGE_TXM         — TXM's memory
  SPTM_PAGE_IOMMU       — I/O memory

Transition rules:
  USER → FREE    : allowed (process exits, page released)
  FREE → KERNEL  : allowed (kernel allocates page)
  USER → KERNEL  : BLOCKED! ← This kills physical UAF escalation
  USER → TABLE   : BLOCKED!
  KERNEL → USER  : Requires explicit transition through SPTM

Impact on PUAF Exploitation

Pre-SPTM:
  PUAF bug → physical page freed but still mapped in user process
  → Kernel reallocates page for kernel object or page table
  → User process reads/writes kernel data via dangling mapping
  ✓ WORKS

Post-SPTM:
  PUAF bug → physical page freed but still mapped in user process
  → Page type = USER (because still mapped to user)
  → SPTM REFUSES to reallocate as KERNEL or TABLE type
  → Page can only be reused by OTHER user processes
  ✗ Cannot escalate to kernel access
  
  Partial: user→user PUAF still possible
  → Read/write other processes' memory
  → But NOT kernel memory

SPTM API (from kernel’s perspective)

Kernel CANNOT:
  - Write to page table pages directly
  - Change page types
  - Map arbitrary physical addresses

Kernel CAN:
  - Request SPTM to create/remove mappings via API:
    sptm_map_page(pmap, va, pa, prot, ...)
    sptm_unmap_page(pmap, va)
  
  SPTM validates:
    - Source page type matches request
    - Permissions are allowed
    - No security-violating transitions

TXM — Trusted Execution Monitor

Architecture

TXM replaces AMFI/CoreTrust’s role in code signing verification:

Pre-TXM:
  Binary execution → AMFI (kernel kext) → amfid (userspace)
  → CoreTrust (kernel kext) → certificate validation
  → Kernel trusts result → allow/deny

Post-TXM:
  Binary execution → Kernel asks TXM (EL2) to verify
  → TXM independently verifies code signature
  → TXM returns decision to kernel
  → Kernel CANNOT override TXM decision

Impact on Jailbreaking

Pre-TXM:
  Kernel r/w → patch AMFI checks → bypass code signing
  Kernel r/w → inject trust cache → run unsigned code
  ✓ Kernel exploit sufficient

Post-TXM:
  Kernel r/w → CANNOT patch TXM (runs at EL2)
  Kernel r/w → Trust cache injection BLOCKED (TXM manages trust caches)
  ✗ Kernel exploit NOT sufficient
  Need: TXM vulnerability + SPTM vulnerability + kernel vulnerability

Tấn Công SPTM/TXM (Theoretical)

1. SPTM Vulnerability

SPTM is software (chạy tại EL2) → có thể có bugs
  - Logic bugs trong page type transition validation
  - Memory corruption trong SPTM's own data structures
  - Race conditions trong concurrent page operations
  
Nhưng: SPTM codebase rất nhỏ, highly audited

2. Hardware Attacks

- Undocumented hardware features (à la Operation Triangulation)
- DMA attacks (nếu IOMMU không properly configured)
- Side channels (timing, power analysis)

3. Architectural Weaknesses

- SPTM/kernel interface bugs
- Information leaks từ EL2 → EL1
- Boot chain attacks (compromise trước khi SPTM initialized)

Current State (2026)

iOS 17-18 trên A15+ devices:
  - Không có public SPTM/TXM bypass
  - Không có public jailbreak
  - Difficulty level: extreme
  
iOS 17-18 trên A14 và cũ hơn:
  - Vẫn dùng PPL (không phải SPTM)
  - PPL bypasses vẫn applicable
  - Jailbreak có khả năng nếu có kernel exploit

Tài Nguyên