iOS Security Model & Sandboxing
iOS Internals · Mobile Internals track
5 min read
In this module
Defence in Depth
iOS stacks its defences in independent layers. Punch through one and another waits behind it. That's the whole reason a working iOS exploit needs a chain — every layer demands its own bypass, and a single bug rarely covers more than one.
The Secure Enclave
At the silicon level, every modern iOS device carries a Secure Enclave — a security coprocessor physically distinct from the main application processor. The boundary is physical: a separate chip with its own CPU, its own OS (sepOS, built on the L4 microkernel), and its own encrypted memory.
The Enclave handles the touchy stuff:
- Cryptographic keys: The device's key hierarchy is generated inside the Enclave and stays there. Even total compromise of the main CPU and the XNU kernel leaves those keys unreachable.
- Biometric processing: Face ID and Touch ID matching runs entirely inside the Enclave. The application processor never sees raw biometric data — it only ever gets a yes/no.
- Hardware AES engine: All Enclave memory is AES-encrypted. Probe the bus and you see ciphertext.
The Secure Enclave is a dedicated hardware security processor running its own OS (sepOS, based on L4). It generates and holds keys that never cross the chip boundary, performs biometric matching, and AES-encrypts every byte of its memory. A fully popped main processor still cannot pull those keys out.
The App Sandbox
Every third-party iOS app runs inside a sandbox that fences off what it can touch. The kernel does the enforcement through the TrustedBSD MAC framework, with profiles handled by Seatbelt — a policy engine that catches syscalls and checks them against the app's profile.
A sandboxed app:
- Gets a unique home directory (UUID-named container) and reads/writes only inside it.
- Can't see other apps' files or the system partition.
- Can't make arbitrary syscalls. The profile is an allowlist.
- Can't touch hardware resources (camera, mic, location) without the user explicitly saying yes.
# An app's sandbox container on iOS/var/mobile/Containers/Data/Application/<UUID>/ Documents/ # User-visible documents Library/ # Preferences, caches tmp/ # Temporary files# The app CANNOT access any path outside this directoryThe app doesn't get a say in its own profile. Apple writes them, the kernel enforces them. A sandboxed process that asks for something off-limits gets a polite kernel-level "no".
Entitlements
The sandbox describes the floor. Entitlements lift the ceiling. They're signed key-value pairs baked into the app's code signature, declaring extra capabilities the app gets on top of the default sandbox. Once signed, they're frozen — no app can hand itself new entitlements at runtime.
# Example entitlements (from codesign --display --entitlements)<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict> <key>com.apple.developer.networking.vpn.api</key> <array><string>allow-vpn</string></array> <key>com.apple.security.app-sandbox</key> <true/> <key>keychain-access-groups</key> <array><string>TEAM_ID.com.example.app</string></array></dict></plist>Kernel and system services consult the entitlement list before handing out privileged capabilities. Because entitlements ride inside the code signature, they're verified cryptographically. Slip an extra entitlement in and the signature breaks.
Entitlements are signed key-value pairs in an app's code signature. They declare capabilities — VPN access, keychain groups, push notifications. Frozen at signing time and checked by the kernel. Sandbox restrictions plus entitlement grants give iOS a fine-grained least-privilege model.
How the Layers Interact
The security model works as a chain of enforcement:
- Hardware root of trust ensures only Apple-signed code boots.
- Kernel enforcement (AMFI) verifies code signatures at page-in time and enforces MAC policies.
- The App Sandbox confines each app to its own container and restricts system call access.
- Entitlements grant specific capabilities beyond the sandbox baseline.
- User permissions give the user final say over sensitive resources.
Each layer stands on its own. The sandbox doesn't lean on entitlements; AMFI doesn't lean on the sandbox. Bypassing one wins you nothing automatic on the others, which is the structural reason iOS exploit chains pile up multiple distinct bugs.
Android builds the same chain from different parts. The comparison below lines up the lower four links for both platforms. Expand a layer, or flip to side-by-side, and look at where they part ways: Android lets the owner unlock the bootloader and leans on SELinux plus Linux UIDs, where iOS has no unlock path and confines apps with Seatbelt profiles.
iOS vs Android Security Model
Sandbox Escapes
A sandbox escape is one of the most valuable links in an iOS chain. Pop a WebKit bug and you're running code, sure, but you're stuck inside Safari's box. Reaching the kernel, other apps, or system resources means breaking out first.
Most escapes target system services that sandboxed apps are already allowed to talk to. The sandbox lets the IPC through; the bug lives inside the service on the other end. That makes the legitimate IPC surface — daemons reachable from sandboxed apps — the most-watched corner of iOS security research.