macOS Security Model
macOS & BSD Internals · Operating Systems track
9 min read
In this module
Defence in Depth on Apple Platforms
macOS has arguably the densest security stack on the desktop. Hardware-rooted protections from the Secure Enclave. Kernel-enforced lockdowns through SIP. An app verification chain through Gatekeeper and notarisation, and fine-grained privacy gates through TCC. Every layer holds even if the one above it falls. Mapping this stack is your starting point for macOS security work — and for making an honest comparison against Windows and Linux.
System Integrity Protection (SIP)
SIP — first shipped in El Capitan, also marketed as "rootless" — is a kernel-enforced cage that even root sits inside:
SIP Protections:┌─────────────────────────────────────────────┐│ Protected paths (even root cannot modify): ││ /System/ ││ /usr/ (except /usr/local/) ││ /bin/ ││ /sbin/ ││ /var/ (selected subdirectories) ││ ││ Protected operations: ││ - Cannot attach debugger to Apple procs ││ - Cannot load unsigned kexts ││ - Cannot modify NVRAM boot variables ││ - Cannot write to protected directories ││ - Cannot modify protected processes │└─────────────────────────────────────────────┘There's no daemon you can SIGKILL to take SIP off; the policy is baked into the kernel. The only legitimate way to disable it is through Recovery Mode, which means rebooting and physical access to the machine.
# Check SIP statuscsrutil status# Output: System Integrity Protection status: enabled
# In Recovery Mode only:csrutil disable # Disable SIP (not recommended)csrutil enable # Re-enable SIPSIP is more restrictive than any single Windows security feature. Windows has Protected Process Light (PPL) for critical processes and file system protections through ACLs, but the root/SYSTEM account can generally override these. SIP ensures that even root on macOS cannot modify system files or debug system processes, providing protection against rootkits and persistent malware.
Gatekeeper and Notarisation
Gatekeeper polices what's allowed to run in the first place:
Application Verification Chain:1. User downloads app from internet2. App gets quarantine extended attribute (com.apple.quarantine)3. On first launch, Gatekeeper checks: a. Is the app signed with a valid Developer ID? b. Has the app been notarized by Apple? c. Has the certificate been revoked?4. If checks pass → app runs5. If checks fail → app blocked with warning dialogueTry it on a Mac: what marks a download as "from the internet", and how would you see what Gatekeeper decides?
Run xattr -l on anything you've just downloaded. You'll find a com.apple.quarantine attribute: a short string of semicolon-separated fields holding flags, a hex timestamp, the app that downloaded it (Safari or Chrome, say) and an ID. Command-line tools such as curl don't set it at all. Copy the same file in with cp from a USB stick and the attribute isn't there, so Gatekeeper never runs its first-launch check.
spctl --assess -vv /Applications/SomeApp.app asks Gatekeeper for its verdict without launching anything; a notarised app reports accepted with a source of Notarized Developer ID. codesign -dvvv /Applications/SomeApp.app shows the signing identity, team ID and whether the hardened runtime flag is set.
Notarisation — mandatory since Catalina if you want Gatekeeper to be happy — means the developer pushed the build through Apple's automated scanner, which looks for:
- Known malware
- A valid Developer ID signature on every executable, with a secure timestamp
- The hardened runtime switched on
- Debug-only entitlements (such as
get-task-allow) left out
Private-API checks belong to App Store review, which is a separate process.
Gatekeeper is only the first of several checks a downloaded app meets. Here's roughly the order they fire on a first launch, with the sandbox and TCC (both covered below) included so you can see where they slot in:
Notice the left-hand shortcut. A file without the quarantine attribute skips Gatekeeper's first-launch checks entirely, but AMFI's signature check at exec time still applies.
The Sandbox
macOS apps get sandboxed via profile-based rules. The default deny-everything stance means you have to whitelist what your app actually needs:
Sandbox Profile (simplified):(version 1)(deny default) ; Deny everything by default(allow file-read* (subpath "/usr/lib")) ; Allow reading system libraries(allow file-read-data (subpath "/Users/alice/Documents")) ; Read user docs(allow network-outbound (remote tcp)) ; Allow outbound TCP(deny file-write* (subpath "/System")) ; Explicitly deny system writes(allow mach-lookup (global-name "com.apple.FontServer")) ; Allow font serviceEvery App Store app has to be sandboxed; there's no opt-out. The kernel's MAC (Mandatory Access Control) framework polices the boundary, so root has no way to lift the sandbox off a sandboxed process at runtime.
Entitlements
Entitlements are simple key/value pairs sealed into the app's code signature. Each one switches on a particular capability:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.network.client</key> <true/> <key>com.apple.security.files.user-selected.read-write</key> <true/> <key>com.apple.security.device.camera</key> <true/></dict></plist>The result is a capability-style model. An app gets exactly the powers its entitlements list — nothing more — and those entitlements have to be approved by Apple (for distribution builds) or self-signed by the developer (for local work).
Predict: an app has the four entitlements above. It calls open() on a file in ~/Documents that the user never picked in an Open dialogue. What happens?
The call fails with EPERM ("Operation not permitted"). files.user-selected.read-write only covers files the user chose through the system file picker, so a hard-coded path is outside the container and the sandbox denies it. The denial is logged too: log stream --predicate 'sender == "Sandbox"' shows a deny(1) file-read-data line naming the process and the path. On a Mac, codesign -d --entitlements - /path/to/App.app prints an app's entitlements so you can check what it was granted.
TCC: Transparency, Consent, and Control
TCC is the gatekeeper for the privacy-sensitive stuff:
TCC-Protected Resources:├── Camera├── Microphone├── Location Services├── Contacts├── Calendar├── Reminders├── Photos├── Full Disk Access├── Files and Folders├── Accessibility├── Input Monitoring├── Screen Recording├── Automation (Apple Events)└── Developer ToolsFirst time an app tries to touch a TCC-gated resource, you see the familiar "App X would like to access your camera" prompt. Your choice gets recorded in a SQLite database:
~/Library/Application Support/com.apple.TCC/TCC.db/Library/Application Support/com.apple.TCC/TCC.db (system-wide)The decisions themselves are made by tccd, a user-space daemon, and the database files are shielded by SIP and by TCC itself, so an ordinary root process can't rewrite them. Enforcement doesn't depend on the app using Apple's frameworks: access to protected resources and folders is checked below them, so a raw open() on a protected path gets the same answer as a framework call.
Secure Enclave
Every Apple Silicon Mac (and any Intel Mac with a T2) ships a Secure Enclave: a separate processor core integrated into the SoC (or the T2 chip), with its own boot ROM and encrypted memory, sitting beside the main CPU like a slightly paranoid sibling.
┌────────────────────────────────────┐│ Main Processor (Application CPU) ││ Runs macOS, applications ││ CANNOT access Secure Enclave RAM │├────────────────────────────────────┤│ Secure Enclave Processor (SEP) ││ - Stores biometric templates ││ - Manages encryption keys ││ - Handles Touch ID / Face ID ││ - Hardware random number generator││ - Secure boot chain verification ││ Runs its own RTOS (sepOS) ││ Has its own encrypted memory │└────────────────────────────────────┘Pop macOS wide open — root, SIP off, kernel exploited — and the Enclave's keys and biometric templates are still out of reach. The main CPU talks to the SEP through a tightly validated mailbox interface; that's the only legal channel.
The Secure Enclave represents a hardware security boundary that a macOS kernel exploit alone cannot cross: compromising the main processor doesn't hand over the Enclave's keys. It isn't invulnerable, since its own boot ROM and firmware have had bugs, but an attacker has to break the SEP itself rather than the OS around it. This is fundamentally stronger than software-only protections like Windows DPAPI or Linux keyring, which can be compromised by kernel-level attackers. Similar concepts exist in Windows (TPM, VBS) but with different implementation details.
Comparing Security Models
| Feature | macOS | Windows | Linux |
|---|---|---|---|
| Root restriction | SIP (kernel-enforced) | UAC (can be bypassed by admin) | SELinux/AppArmor (MAC) |
| App verification | Gatekeeper + notarisation | SmartScreen | Package manager signatures |
| App sandboxing | Sandbox profiles (MAC) | AppContainer | seccomp + namespaces |
| Privacy controls | TCC (tccd decides, checks enforced below the frameworks) | App permissions (UWP) | xdg-desktop-portal for Flatpak/Snap apps; little for native apps |
| Secure hardware | Secure Enclave | TPM 2.0 | TPM (varies) |
| System volume | Sealed System Volume (SSV) | Protected system files | dm-verity (ChromeOS) |
| Code signing | Required for distribution | SmartScreen reputation | Optional |
macOS's stack clamps down harder than the typical Windows or Linux desktop. You pay for it in flexibility: every developer has to work within Apple's entitlement and sandbox framework, and users can't easily mod the system the way you'd tweak a Linux box. Whether that trade reads as protective or paternalistic depends entirely on what you're trying to defend.