Macos security

From brucesongs/kali-claw · View interactive version

Macos security is an AI agent skill from the GitHub repository brucesongs/kali-claw. macOS red team and security assessment — SIP/TCC bypass, Endpoint Security framework, Apple Silicon/T2/M-series attacks, Mach-O analysis, Keychain extraction, MDM bypass, LaunchAgents/Daemons persistence, and macOS-native malware analysis.

How to use this skill

Skill file

Skill: macOS Security Assessment

Supplementary Files:

- payloads.md — Command catalogue for macOS red team and malware analysis: 18 sections covering recon, SIP/TCC bypass, ESF event logging, LaunchAgents/Daemons persistence, Keychain extraction, Cookies.binarycookies, Apple Silicon (arm64e, PAC, sealed snapshots), MDM profile analysis, Mach-O analysis (otool, jtool2, machOView), code signing/notarization, process/memory analysis, network analysis, persistence enumeration, defense bypass (AMFI, sandbox), Objective-See tools (KnockKnock, LuLu, BlockBlock, OverSight), and a cheat sheet. 60+ code blocks with real macOS CLI syntax.

- test-cases.md — Structured test cases (TC-MO-001..018): system profiling, SIP status check, TCC.db audit, LaunchAgents/Daemons enumeration, Keychain extraction via security, Cookies.binarycookies parsing, MDM profile analysis, Mach-O analysis, code signing verification, KnockKnock persistence scan, ESF event logging, Apple Silicon PAC check, plus Apple Silicon boot chain, ESF client construction, TCC.db deep reverse engineering, MDM profile abuse, unified log hunting, AMSI/AMFI bypass, and Keychain offline cracking. Includes a Verification Checklist.

- guides/macos-security-playbook.md — End-to-end operational playbook: macOS security architecture (SIP/TCC/AMFI/sandbox/ESF/Secure Boot), Apple Silicon specifics (arm64e, PAC, Rosetta 2, sealed system snapshots), building a macOS test lab, red team methodology, real-world macOS threats (XCSpy, Shlayer, Bundlore, Silver Sparrow, NodeStealer), defense patterns, and references.

- guides/macos-security-deep-dive.md — Deep-dive on Apple Silicon (M1/M2/M3/M4) security architecture: boot chain (SSV/Rosetta/kernel), PPL (Page Protection Layer), pointer authentication codes, kext vs System Extensions, the Endpoint Security Framework API surface, TCC.db reverse engineering methodology, recent CVEs (CVE-2023-32434/32435/41990), and the macOS red team tradecraft playbook.

Summary

macOS security assessment skill covering Apple's desktop/laptop platform from a red team and malware analyst perspective. This skill addresses the modern macOS attack surface: System Integrity Protection (SIP/rootless), Transparency Consent and Control (TCC), Endpoint Security framework (ESF), Apple Silicon (M1/M2/M3/M4 with arm64e and Pointer Authentication Codes), T2 chip on Intel Macs, code signing + notarization enforcement, LaunchAgents/LaunchDaemons persistence, Keychain credential stores, MDM profile abuse, and Mach-O binary analysis.

Tools: Objective-See suite (KnockKnock, LuLu, BlockBlock, OverSight, TaskExplorer, What's Your Sign?), sindresorhus/Equity, mSCP (macOS Security Compliance Project), machOView, Hopper Disassembler, Ghidra (Mach-O plugin), jtool2, ldid, plus native CLI (system_profiler, csrutil, tccutil, security, codesign, otool, nm, vmmap, lldb, profiles, airport).

Domain: macos

MITRE ATT&CK: T1547-Boot or Logon Autostart (LaunchAgents/Daemons, login items), T1555-Credentials from Password Stores (Keychain, Cookies.binarycookies), T1059-Command and Scripting Interpreter (zsh, osascript), T1068-Exploitation for Privilege Escalation (SIP bypass, SUID abuse), T1106-Native API (Mach APIs, launchd), T1620-Reflective Code Loading (DYLD injection), TA0005-Defense Evasion (AMFI bypass, notarization abuse, TCC bypass).

Description

macOS is no longer a niche enterprise endpoint. As of 2026 it commands roughly a quarter of the U.S. enterprise laptop market, is the default developer machine at most Fortune 500 technology companies, and is increasingly the executive laptop of choice. It is also a strange target: it runs a Darwin/BSD core (so it has UNIX permissions, file flags, chroot, seatbelt sandbox profiles), but it is wrapped in a sophisticated proprietary security architecture (System Integrity Protection, Apple Mobile File Integrity / AMFI, TCC privacy consent, Secure Boot, sealed system snapshots on Apple Silicon, and the Endpoint Security framework). Most offensive techniques ported from Linux work, but the interesting bugs and persistence mechanisms are macOS-specific — and the defenders have a 10-year head start via Patrick Wardle's research, the Objective-See tooling, Apple's Platform Security Guide, and the macOS Security Compliance Project (mSCP).

This skill is the macOS counterpart to av-edr-evasion (which focuses on Windows Defender / commercial EDR) and binary-reverse (which is platform-agnostic but mostly ELF/PE-flavored). Where those skills cover Windows and Linux, this skill covers the macOS-specific attack surface: csrutil/nvram for SIP, tccutil + TCC.db for privacy, security CLI for Keychain, codesign/spctl for signing and notarization, otool -L and jtool2 for Mach-O introspection, profiles for MDM, and the EndpointSecurity framework for the same event stream that commercial EDR (Falcon, SentinelOne, Jamf Protect, Microsoft Defender for Endpoint) subscribes to.

Eight things distinguish macOS attacks from generic UNIX attacks:

  1. SIP (System Integrity Protection) is the new root — On 2015+ macOS, even root cannot write to /System, /usr, /bin, /sbin, certain protected subdirs of /Library, or the TCC database by default. Processes that try must be Apple-signed with the right entitlements, or SIP itself must be disabled (recovery-mode csrutil disable). Modern macOS attacks either work within SIP (persistence in user-writable locations, TCC.db manipulation under granted entitlements) or seek SIP bypasses (CVE-2019-8805, CVE-2020-3837, CVE-2023-32434 — the latter a memory corruption in the boot ROM image parser, unpatchable by software on Apple Silicon).
  1. TCC (Transparency, Consent, and Control) is the new permission gate — Every macOS app that wants to read user data (location, camera, microphone, contacts, calendars, reminders, photos, Mail, Safari history, Messages, full disk access, accessibility control, automation) must request consent at first use, recorded in /Library/Application Support/com.apple.TCC/TCC.db (system) and ~/Library/Application Support/com.apple.TCC/TCC.db (user). TCC bypass is the macOS analog of a Windows UAC bypass — historically via DYLD insertion into a TCC-entitled binary (Xcode.app, swift), via env-var abuse, or via direct SQLite manipulation when SIP is weakened.
  1. The Endpoint Security framework (ESF) is the EDR's eyes — and yours — Introduced in macOS 10.15 Catalina (2019) and hardened repeatedly since, ESF is the only supported API for monitoring process exec, file writes, endpoint disk I/O, mount/unmount, opendirectory lookups, and (on Monterey+) login/logout. Commercial EDR (CrowdStrike, SentinelOne, Defender for Endpoint, Jamf Protect) is required by Apple to subscribe to ESF — and a red team operator who can run eslogger or build their own ESF client gets the same telemetry, for free, on any Mac they have admin on.
  1. Apple Silicon changes the rules — PAC, sealed snapshots, Rosetta 2 — On M-series Macs, the kernel runs arm64e with Pointer Authentication Codes (PAC) on every function pointer and return address — most classic ROP/JOP chains fail. The system volume is a cryptographically sealed APFS snapshot (/System/Volumes/Data is mutable, ///System are read-only and hash-checked at every boot). Kernel extensions are effectively dead for third parties; the only supported path is System Extensions (user-land) and DriverKit. Rosetta 2 (x86_64 emulation) is an entire second ABI with its own historical bugs (CVE-2021-30717 — Rosetta translation bypass of code signing checks). Apple Silicon also brought Silver Sparrow (2021), the first malware family observed shipping an arm64 payload alongside x86_64.
  1. Code signing and notarization are mandatory, but gameable — On macOS 10.15+ the Gatekeeper default rejects any downloaded binary that isn't signed by a Developer ID and notarized by Apple. But ad-hoc signed binaries (signed locally with codesign -s -) execute fine if run from a path that bypasses Gatekeeper (anything not quarantined — e.g., extracted from an installer, run by a binary that already has the same permissions). And historically notarization was bypassed via signed-and-notarized "conduit" binaries (the classic Shlayer model: a notarized dropper that fetches and unpacks the actual payload at runtime).
  1. LaunchAgents and LaunchDaemons are the persistence layer — The single most abused macOS persistence mechanism is ~/Library/LaunchAgents/<bundle-id>.plist (user) and /Library/LaunchDaemons/<bundle-id>.plist (system). Each plist tells launchd (PID 1) to spawn a binary on a schedule, on login, on network change, or on a watched path. KnockKnock enumerates ~50 of these locations. macOS malware (Bundlore, Shlayer, XCSpy, CoinMiner) almost always adds a LaunchAgent. There are also login items (~/Library/Application Support/com.apple.backgroundtaskmanagementagent/), Spotlight importers, QuickLook plugins, Internet plug-ins, browser extensions, and the legacy /etc/periodic/ and crontab.
  1. Keychain and Cookies.binarycookies are the credential prize — macOS stores user secrets in ~/Library/Keychains/login.keychain-db (user) and /Library/Keychains/System.keychain (system): Safari passwords, Wi-Fi PSKs, application tokens, certificates. The security CLI can dump it after prompting for the user's login password (or with no prompt if the calling binary is signed and entitled), and KeychainDump/chainbreaker extract password hashes for offline cracking. Safari cookies live in ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies — a non-standard binary plist format that several tools parse.
  1. MDM is the enterprise control plane — and a target — macOS in enterprise is typically enrolled in Mobile Device Management (Jamf, Kandji, Microsoft Intune, Workspace ONE). MDM profiles can push restrictions, configure FileVault, deploy System Extensions, and remotely wipe. The profiles CLI lists installed profiles and can install new ones (with admin). MDM profile abuse includes: extracting an enrollment identity from a compromised host to enroll rogue devices, bypassing MDM via beta OS profiles, or exploiting profile signing weaknesses. Apple's Platform Security Guide treats the MDM as a privileged trust boundary.

Difference from mobile-security: mobile-security is iOS/Android — app review bypass, certificate pinning, APK/IPA reverse engineering, mobile data protection at the application layer. THIS skill is macOS desktop/laptop specifically — SIP/TCC/ESF, LaunchAgents/Daemons persistence, Mach-O (not ELF/PE), Keychain (not Android Keystore), MDM profile analysis as an enterprise control plane. The platforms share a kernel (Darwin) and code signing (codesign + ldid) but the attack surfaces are otherwise distinct. iOS additionally has its own sandbox and entitlement system that differs in detail.

Difference from av-edr-evasion: av-edr-evasion covers Windows Defender, commercial EDR (CrowdStrike, SentinelOne, Defender for Endpoint), and bypass techniques for those. THIS skill covers the macOS-specific defense stack: AMFI, Gatekeeper, XProtect, MRT (Malware Removal Tool), TCC, and the macOS-native EDR surface (System Extensions, ESF). Where av-edr-evasion might cover direct syscalls and process doppelgänging on Windows, this skill covers signed-and-notarized droppers, TCC bypass via entitlement inheritance, and persistence in LaunchAgents.

Difference from binary-reverse: binary-reverse covers static/dynamic analysis broadly — PE, ELF, and Mach-O. THIS skill narrows to Mach-O specifically: otool, nm, jtool2, machOView, Ghidra Mach-O plugin, disassembling arm64/arm64e with PAC-aware tooling, dumping entitlements, walking the load commands. The Mach-O format, the Objective-C runtime metadata, and the Swift symbol mangling are macOS-specific.

Difference from digital-forensics: digital-forensics covers IR artifacts broadly (logs, file system timeline, memory). THIS skill covers macOS-specific forensic artifacts: the unified log (log show), FSEvents, Spotlight metadata, TCC.db audit, Keychain access history, Spotlight importers, and the securenotes table in the user keychain. Where digital-forensics might describe Windows event log analysis, this skill covers log show --predicate 'subsystem == "com.apple.securityd"'.

Difference from container-security and cloud-security: those cover Linux containers and cloud IaaS. macOS has its own containerization model (per-app sandbox via sandboxd, hardened runtime via entitlements, App Sandbox container directories at ~/Library/Containers/<bundle-id>/). The macOS container model is per-process and enforced by the kernel, not by a container runtime.

Use Cases

Core Tools

Objective-See Suite (free, open-source, the de facto standard)

| Tool | Purpose | Command Example |

|------|---------|-----------------|

| KnockKnock | Enumerate ~50 macOS persistence locations (LaunchAgents, LaunchDaemons, login items, browser extensions, Spotlight importers, kernel extensions, System Extensions) | KnockKnock.app/Contents/MacOS/KnockKnock -h (or click "Scan") |

| LuLu | Free open-source macOS firewall — block outbound by bundle ID / binary path | sudo /Objects/LuLu.app/Contents/MacOS/LuLu (mode 2 = block-by-default) |

| BlockBlock | Persistence monitor — alerts when anything installs a LaunchAgent, login item, or kernel extension | BlockBlock.app (GUI monitor) |

| OverSight | Camera + microphone monitor — alerts when an app accesses the camera or mic | OverSight.app |

| TaskExplorer | Process explorer with code-signing info, VT lookups, file/path context | TaskExplorer.app |

| What's Your Sign? | Finder extension showing code-signing details (cert chain, notarization status) | Right-click → Services → What's Your Sign? |

Analysis + Compliance

| Tool | Purpose | Command Example |

|------|---------|-----------------|

| sindresorhus/Equity | Open-source Gatekeeper / notarization / TCC GUI inspector | Equity.app (drag-drop a binary to see signing/notarization details) |

| mSCP (macOS Security Compliance Project) | NIST + Apple baseline configuration profiles + audit scripts | python3 bin/mSCP.py -s baseline/macos_15_1.yaml |

| machOView | GUI Mach-O browser — load commands, segments, sections, Objective-C classes | machOView.app (open a Mach-O binary) |

| Hopper Disassembler | Native macOS disassembler/decompiler (commercial, with demo) | hopper <binary> |

| Ghidra (Mach-O plugin) | NSA's open-source reverse-engineering suite with Mach-O loader | analyzeHeadless . proj -import <binary> |

| jtool2 | The Swiss-army knife for Mach-O introspection (by Elias Limneos) — replaces many otool workflows | jtool2 -l <binary> (load commands); jtool2 -arch arm64e -L <fat> |

| ldid | Alternative to codesign for ad-hoc signing with entitlements (Cydia/Telesphoreo origin) | ldid -S<entitlements.plist> <binary> |

Methodology

macOS Red Team Five-Phase Workflow

Phase 1          Phase 2          Phase 3          Phase 4          Phase 5
Recon &       →  Privilege &   →  Persistence   →  Credential     →  Defense Bypass
Footold          TCC Posture      (LaunchAgents)    Extraction       & ESF Audit
   │                │                │                │                │
   ▼                ▼                ▼                ▼                ▼
 system_profiler   csrutil status   ~/Library/       security         AMFI bypass,
 sw_vers, uname    tccutil reset    LaunchAgents/     dump-keychain   sandbox profile
 hardware arch     TCC.db audit     LaunchDaemons/    Cookies.        escapes, notarization
 loginwindow       accessibility    login items       binarycookies   conduit abuse,
 MDM profiles      Full Disk Acc    Spotlight imp.    Safari          ESF self-audit
                                                                    via eslogger

Phase 1: Recon & Foothold — Determine the macOS version (sw_vers), hardware architecture (uname -m → arm64/arm64e for Apple Silicon, x86_64 for Intel), system model (system_profiler SPHardwareDataType), FileVault status (fdesetup status), and the user's full name + UID + admin group membership (id, groups). Enumerate installed MDM profiles (profiles list -output user) and the MDM vendor. Identify what security software is running (Look for falcon, sentinelone, jamfProtect, Microsoft Defender processes). Establish a foothold via the engagement scope (existing user creds, a delivered payload, a browser exploit).

Phase 2: Privilege & TCC Posture — Determine SIP status (csrutil status), TCC state (tccutil reset All clears — but only as user; system TCC.db requires root + SIP weakened), and the current process's own TCC grants (via the tccutil reads or by parsing ~/Library/Application Support/com.apple.TCC/TCC.db). Identify entitlement-rich binaries that grant indirect TCC access: Xcode (com.apple.dt.Xcode), Safari (com.apple.Safari), Mail (com.apple.Mail), Terminal with Full Disk Access already granted. Document which TCC-protected resources the user has already granted (the easiest path to credentials and history).

Phase 3: Persistence — Install a LaunchAgent at ~/Library/LaunchAgents/com.example.helper.plist (user scope, runs at user login) or ~/Library/LaunchDaemons/com.example.helper.plist (system scope, runs at boot, requires root + sudo). For wider persistence, consider: login items via LSSharedFileListInsertItemURL, Spotlight importers (~/Library/Spotlight/), QuickLook plugins (~/Library/QuickLook/), browser extensions (~/Library/Application Support/Google/Chrome/Default/Extensions/), the legacy /etc/periodic/daily/ dropboxes, and cron. On Apple Silicon, all of these work — kernel extensions do not.

Phase 4: Credential Extraction — Dump the login keychain via security dump-keychain -d ~/Library/Keychains/login.keychain-db (prompts for user password), enumerate generic passwords (security find-generic-password -l), extract saved Wi-Fi PSKs (security find-generic-password -ga "SSID" -w), parse Safari cookies from ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies (use binarycookies-reader or python script), and read Safari history from ~/Library/Safari/History.db (Full Disk Access required). Document each credential source and the TCC entitlement required to reach it.

Phase 5: Defense Bypass & ESF Audit — Identify what the defender sees: run eslogger (or build an ESF client) and observe your own actions; understand that ESF is the same data commercial EDR uses. If a specific defender (Falcon, Defender for Endpoint) is running, identify its ESF subscription and any network callouts it makes. Document anti-analysis: AMFI (amfid) checks every exec against the trust cache; sandbox profiles restrict syscalls; Gatekeeper enforces notarization on quarantined files. Document bypasses used: running from non-quarantined paths (no com.apple.quarantine extended attribute), DYLD insertion into TCC-entitled binaries (when SIP permits), entitlement inheritance via signed-and-notarized conduits.

Quick Selection Guide

| Scenario | Primary Approach | Alternative |

|----------|------------------|-------------|

| Just got user shell on a Mac | sw_vers, uname -m, id, csrutil status, profiles list | system_profiler SPHardwareDataType |

| Need to read user documents | Check ~/Library/Application Support/com.apple.TCC/TCC.db for granted Full Disk Access; if absent, look for a TCC-entitled binary to abuse | osascript automation of Finder/TextEdit with prior automation grant |

| Need credentials | security dump-keychain -d (prompts for user password); security find-generic-password -ga <SSID> -w | chainbreaker for offline hash extraction |

| Need Safari history | Read ~/Library/Safari/History.db (FDA required) | Parse Cookies.binarycookies for session tokens |

| Need persistence | LaunchAgent at ~/Library/LaunchAgents/com.example.helper.plist with RunAtLoad=true | Login items via osascript -e 'tell application "System Events" to make login item ...' |

| Need system-level persistence | /Library/LaunchDaemons/com.example.helper.plist (requires root + signed binary) | System Extension (high detection — not recommended for red team) |

| Analyzing a Mach-O | file, otool -h (arch), otool -L (libs), codesign -dvvv (signing), jtool2 -l (load commands) | machOView for GUI browsing, Hopper/Ghidra for disassembly |

| Detecting SIP-bypassed host | csrutil status, nvram boot-args, mount \| grep System | csrutil authenticated-root status (Apple Silicon) |

| Enumerating persistence | Run KnockKnock (GUI), or script: ls -l ~/Library/LaunchAgents/ /Library/LaunchAgents/ /Library/LaunchDaemons/ | launchctl list for currently-loaded services |

| Auditing MDM | profiles list -output user; profiles show -output open-command -identifier <UUID> | /var/db/ConfigurationProfiles/ (system) — needs root |

| Want to see what EDR sees | sudo eslogger exec,open,write --run foreground | Build an ESF client with EndpointSecurity.framework |

| Checking notarization | spctl --assess --type execute --verbose <binary>; codesign -dv --verbose=4 <binary> | Drag-drop into Equity GUI |

Defense Perspective

| Defense Measure | Description |

|-----------------|-------------|

| SIP enabled | csrutil status should report "fully enabled". Disable only for development. SIP-protected directories (/System, /usr, /bin, /sbin, preinstalled apps) cannot be modified even by root. |

| FireVault on + PRK escrow | fdesetup status → "FileVault is On." Recovery key escrowed to MDM or printed and stored. Without FileVault, all on-disk secrets are readable by anyone with physical access. |

| TCC audit | Quarterly review of /Library/Application Support/com.apple.TCC/TCC.db and ~/Library/Application Support/com.apple.TCC/TCC.db. Alert on any new Full Disk Access or Accessibility grant to a non-Apple binary. |

| Gatekeeper + notarization enforcement | spctl --status → "assessments enabled." macOS 11+ blocks all downloaded non-notarized apps by default. Users must override explicitly via System Settings → Privacy & Security. |

| XProtect + MRT active | systemextensionsctl list should show com.apple.XProtect.framework.ScanService and com.apple.MRT. Apple pushes background signature updates silently. |

| Endpoint Security framework subscription | At least one ESF-based EDR (Jamf Protect, CrowdStrike Falcon, Defender for Endpoint, SentinelOne) deployed via MDM. Apple does not ship a macOS-native EDR — third party is required. |

| MDM enrollment + restricted profiles | Device supervised via Apple Business/School Manager; MDM profile installed at DEP time; restricted system extensions (only allow-listed team IDs); Gatekeeper and SIP policy enforced via configurationProfile. |

| Software Update enforcement | softwareupdate --schedule-on; max N-day lag from Apple release; critical security updates auto-installed within 72h. |

| System Volume sealed snapshot | On Apple Silicon, /System/Volumes/SSV is a sealed snapshot — verify with mount \| grep sealed and csrutil authenticated-root status. Tampering here is a hardware-level indicator. |

| Hardened Runtime for in-house apps | All in-house macOS binaries built with Hardened Runtime (--options runtime to codesign), proper entitlements, and notarized via Xcode Organizer or notarytool. |

Practical Steps

Detailed payloads in payloads.md, complete test checklist in test-cases.md.

Exercise 1: Enumerate LaunchAgents and LaunchDaemons

# User-scope LaunchAgents (run at login as the user)
ls -l ~/Library/LaunchAgents/ 2>/dev/null
# System-scope LaunchAgents (run at login for any user)
ls -l /Library/LaunchAgents/ 2>/dev/null
# System-scope LaunchDaemons (run at boot as root — highest-impact persistence)
ls -l /Library/LaunchDaemons/ 2>/dev/null
# Apple's own LaunchAgents/Daemons (informational, do not touch)
ls -l /System/Library/LaunchAgents/ /System/Library/LaunchDaemons/ 2>/dev/null

# Inspect one plist
plutil -p ~/Library/LaunchAgents/com.example.helper.plist
# Key fields: Label, ProgramArguments, RunAtLoad, KeepAlive, StartInterval, WatchPaths

# List currently-loaded services
launchctl list | head -20
launchctl list | grep -i example

# Find services that auto-restart (KeepAlive=true)
for f in ~/Library/LaunchAgents/*.plist /Library/LaunchAgents/*.plist /Library/LaunchDaemons/*.plist; do
  [ -f "$f" ] || continue
  plutil -p "$f" 2>/dev/null | grep -q "KeepAlive = 1" && echo "KEEPALIVE: $f"
done

Exercise 2: Extract Keychain Items (with user prompt)

# Show the user's keychains
security list-keychains

# Show all generic-password entries (no secret values)
security dump-keychain ~/Library/Keychains/login.keychain-db | grep -E '"svce"|"acct"|"desc"'

# Dump one item WITH the password (prompts user for keychain unlock)
security find-generic-password -ga "Wi-Fi SSID Name" -d ~/Library/Keychains/login.keychain-db -w
# → password: <WPA-PSK>

# Dump everything (prompts repeatedly for the keychain password)
security dump-keychain -d ~/Library/Keychains/login.keychain-db

# Saved Wi-Fi networks (system keychain)
sudo security find-generic-password -ga "SSID" /Library/Keychains/System.keychain -w

# List certificates (e.g., MDM enrollment identity)
security find-certificate -a /Library/Keychains/System.keychain

Exercise 3: Check SIP and TCC Status

# SIP status (must be run as the logged-in user; shows config)
csrutil status
# Expected on a hardened host: "System Integrity Protection status: enabled."

# Apple Silicon: authenticated-root status (sealed system snapshot)
csrutil authenticated-root status

# TCC: list current grants via the tccutil (limited; full audit requires sqlite3)
tccutil reset All   # DANGEROUS: resets all user TCC grants — only for testing

# Read user TCC.db (sqlite3, requires Full Disk Access for the terminal)
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \
  "SELECT service, client, auth_value FROM access ORDER BY service;"
# auth_value: 0=denied, 2=allowed, 3=limited

# System TCC.db (requires root)
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db \
  "SELECT service, client, auth_value FROM access ORDER BY service;"

# Which services exist (Apple's documented list — see Apple Platform Security Guide)
# kTCCServiceSystemPolicyAllFiles (Full Disk Access)
# kTCCServiceAccessibility (Accessibility)
# kTCCServiceSystemPolicySysAdminFiles (Administrator files)
# kTCCServiceSystemPolicyDesktopFolder (Desktop)
# kTCCServiceSystemPolicyDocumentsFolder (Documents)
# kTCCServiceSystemPolicyDownloadsFolder (Downloads)
# kTCCServiceCamera, kTCCServiceMicrophone, kTCCServiceLocation, ...

Exercise 4: Mach-O Static Analysis with otool and jtool2

# Architecture (fat binary? single arch?)
file /Applications/Safari.app/Contents/MacOS/Safari
# → Mach-O 64-bit executable [arm64e] (Apple Silicon) or [x86_64]

# Header
otool -h /bin/ls
otool -hv /bin/ls                       # verbose

# Linked libraries
otool -L /bin/ls
# Lists LC_LOAD_DYLIB entries — the dylibs this binary depends on

# Load commands (one line each)
otool -l /bin/ls | head -50
# Or jtool2 (cleaner output):
jtool2 -l /bin/ls

# Symbol table
nm -p /bin/ls | head -20

# Objective-C class metadata (if the binary is Objective-C)
otool -ov /Applications/Safari.app/Contents/MacOS/Safari 2>/dev/null | head -100

# Code-signing details
codesign -dvvv /Applications/Safari.app
codesign -d --entitlements - /Applications/Safari.app
# Look for: Authority (Developer ID / Apple Mac OS Application Signing),
# TeamIdentifier, and entitlements like com.apple.security.cs.* (Hardened Runtime)

# Sections (better in machOView GUI)
jtool2 -section /bin/ls

# Disassemble (Hopper for GUI, jtool2 -d for CLI; arm64e disassembly needs PAC-aware tools)
jtool2 -d --arch arm64e /Applications/Safari.app/Contents/MacOS/Safari

Exercise 5: Enumerate MDM Profiles

# List installed configuration profiles (user-installable)
profiles list -output user

# List all profiles (system; requires admin)
sudo profiles list

# Show details of a specific profile (by identifier)
sudo profiles show -identifier com.example.restrictions

# Show the payload as a plist
sudo profiles show -output open-command -identifier com.example.restrictions > /tmp/profile.plist
plutil -p /tmp/profile.plist

# Where profiles are stored on disk (system)
sudo ls -l /var/db/ConfigurationProfiles/Setup/
sudo ls -l /var/db/ConfigurationProfiles/Settings/

# What's the MDM enrollment identity?
sudo security find-certificate -a -c "Profile" /Library/Keychains/System.keychain
sudo security find-certificate -a -c "MDM" /Library/Keychains/System.keychain

Detection Methods

macOS Endpoint Detection

SIEM Detection Rules

Defense Evasion Techniques

SIP Bypass

TCC Bypass

Keychain Access Stealth

Apple Silicon Specific

Common Pitfalls

Safety Notes

Hacker Laws

Apple Silicon Security Architecture

Apple Silicon (M1/M2/M3/M4) fundamentally reshapes the macOS attack surface. The kernel and Apple-signed system binaries run arm64e with Pointer Authentication Codes (PAC) on every function pointer and return address, defeating most classic ROP/JOP chains. The system volume is a cryptographically sealed APFS snapshot (SSV — Signed System Volume), verified at every boot by the boot ROM and the kernel. Third-party kernel extensions are effectively dead; the supported path is System Extensions (user-land) and DriverKit. Rosetta 2 (x86_64 emulation) is a separate ABI with its own historical bugs (CVE-2021-30717 — Rosetta translation bypassed code signing checks). The Page Protection Layer (PPL) on M1+ protects page tables and code-signing metadata from kernel-mode tampering — even a kernel read/write primitive cannot forge entitlements or trust-cache entries.

Boot Chain

  1. Boot ROM — immutable, masked ROM in the SoC; verifies the next stage via Apple's Root CA.
  2. Secure Enclave (SEP) — holds device-specific keys; runs sepOS, a separate L4 microkernel.
  3. iBoot — verifies the kernel cache and Device Tree; loads the kernel.
  4. Kernel + Kexts / System Extensions — kernel runs arm64e on Apple Silicon; executes launchd (PID 1).
  5. Signed System Volume (SSV) — / is a sealed APFS snapshot; mount shows apfs,sealed,read-only. Firmlinks (/usr/share/firmlinks) bridge read-write paths to /System/Volumes/Data.

Pointer Authentication Codes (PAC)

ARMv8.3 introduces PAC. Every function pointer and return address can be cryptographically signed with a 128-bit modifier and a secret key. Instructions: pacia/pacib (sign), autia/autib (authenticate), retaa/retab (authenticated return), braa/blraa (authenticated branch). Apple-signed binaries use arm64e; third-party code runs arm64 (PAC-disabled). Exploitation requires forging a PAC signature or finding a PAC bypass (signing oracle, exception-stream abuse, JIT spray against PAC-disabled regions).

Page Protection Layer (PPL)

PPL is an exception level below the kernel (EL2 on Apple Silicon, loosely). It guards: page table entries for executable mappings, the trust cache (kernel-resident CDHash list), code-signing blob interpretation, and the kernel's apple_sep Industriously primitives. Even with a kernel read/write primitive, you cannot self-sign an entitlement without breaking PPL. Documented PPL research: the "PPL爆破" / PPL bypass literature (2023-2024) explores hardware fault injection but no software-only PPL break is publicly known as of 2026.

Kexts vs System Extensions

Endpoint Security Framework Internals

ESF (EndpointSecurity.framework) is the only Apple-blessed API for system telemetry on macOS 10.15+. It is a Mach-based IPC between a System Extension (client) and the kernel (endpoint). A client subscribes to event types, receives messages containing the event details + audit tokens for the actor processes, and can issue responses (authorize/deny) for certain event classes.

Event Categories

Client Lifecycle

  1. es_new_client(&client, &handler) — create client. Requires com.apple.developer.endpoint-security.client entitlement (Apple-issued for EDR vendors; ad-hoc signing with this entitlement requires boot-args amfi_get_out_of_my_way=1 or SIP-disabled).
  2. es_subscribe_client(client, events, count) — register interest.
  3. Handler receives es_message_t *. The handler must call es_respond(result, msg, auth_result) for auth events; clear messages are fire-and-forget.
  4. es_mute_path / es_mute_path_prefix — exclude paths (e.g., /System/Library/).
  5. On macOS 13+: es_clear_cache() — required periodically to drain the kernel's message buffer.

Tooling

MDM Control Plane

Mobile Device Management is the enterprise control plane for macOS in 2026 — Jamf, Kandji, Microsoft Intune, Workspace ONE, Addigy, Mosyle. MDM pushes configuration profiles (Apple's .mobileconfig format) that enforce restrictions, push certificates, configure FileVault, deploy System Extensions, and remotely wipe. Supervision via Apple Business/School Manager (DEP — Device Enrollment Program, now Apple Automated Device Enrollment) makes profiles non-user-removable.

Profile Anatomy

A .mobileconfig is a signed plist with PayloadContent, PayloadIdentifier, PayloadType, PayloadUUID, PayloadDisplayName, and a signature (CMS/PKCS#7). Payload types include com.apple.applicationaccess (restrictions), com.apple.security.FDE (FileVault), com.apple.system-extension-policy (allow-listed SE Team IDs), com.apple.security.firewall (application firewall), com.apple.networkextension.configuration (VPN/filtered-network), com.apple.ldap.account (directory binding).

Enrollment Modes

MDM Abuse Vectors

  1. Enrollment identity theft — extract the MDM identity cert from /Library/Keychains/System.keychain, enroll rogue devices impersonating the supervised Mac.
  2. DEP re-enrollment race — wipe a supervised Mac, race to enroll in a different MDM before DEP check-in completes.
  3. Beta OS profile bypass — install a beta macOS profile that bypasses some restriction enforcement.
  4. Supervised-mode downgrade — older macOS versions had downgrade paths; modern macOS is largely closed.
  5. MDM server compromise — compromise the Jamf/Intune server → push malicious profiles fleet-wide (highest-impact scenario).

Real-World macOS Threats

macOS malware from 2017 to 2026 illustrates how attackers adapt to the platform's defenses. Key families:

Adware / Dropper Wave (2017-2020)

Apple Silicon Transition (2021-2022)

Modern Stealer Wave (2023-2026)

Nation-State / Targeted

macOS Forensic Artifacts

macOS produces unusually rich forensic telemetry. Unlike Windows (Event Log) or Linux (syslog/journald), macOS records to the unified log — a binary, time-indexed, structured log stream that requires log show to parse. Combined with the TCC.db, Keychain, FSEvents, and Spotlight metadata, an IR analyst can reconstruct nearly every action an attacker took.

Primary Artifact Sources

| Artifact | Path | Content |

|----------|------|---------|

| Unified log | /var/db/diagnostics/ (binary) | All system telemetry since macOS 10.12 Sierra; structured subsystem/category |

| TCC.db (user) | ~/Library/Application Support/com.apple.TCC/TCC.db | Privacy grants (Full Disk Access, Camera, Microphone, etc.) |

| TCC.db (system) | /Library/Application Support/com.apple.TCC/TCC.db | System-scope privacy grants |

| Keychain (user) | ~/Library/Keychains/login.keychain-db | User credentials (Safari, Wi-Fi, app tokens, certs) |

| Keychain (system) | /Library/Keychains/System.keychain | System secrets (MDM identity, Wi-Fi PSKs, system certs) |

| Cookies.binarycookies | ~/Library/Containers/com.apple.Safari/Data/Library/Cookies/ | Safari session cookies (binary plist) |

| History.db | ~/Library/Safari/History.db | Safari browsing history (SQLite) |

| FSEvents | /.fsevents/* | Filesystem events (creates, deletes, renames) |

| Spotlight metadata | /.Spotlight-V100/Store-V2/ | File content index (may contain path + metadata of deleted files) |

| quarantine | xattr -l <file> → com.apple.quarantine | Downloaded-file provenance (browser, timestamp) |

| launchd state | /var/db/launchd.db/, ~/Library/LaunchAgents/ | Persistence items |

| mdmcache | /var/db/ConfigurationProfiles/ | MDM profile payloads |

Unified Log Hunting

# Recent process exec events (subsystem = com.apple.securityd logs exec)
sudo log show --predicate 'subsystem == "com.apple.securityd"' --last 1h --style compact

# All TCC-related events (every privacy grant, denial, prompt)
sudo log show --predicate 'subsystem == "com.apple.TCC"' --last 24h

# Code-signing failures (AMFI denials)
sudo log show --predicate 'subsystem == "com.apple.amfi"' --last 24h --info --debug

# Search the entire unified log for a binary path (post-compromise)
sudo log show --last 7d --info --debug | grep -F "/tmp/payload"

Apple Platform Security Layers

Apple's published Platform Security Guide (the authoritative reference) defines the layered trust model. From hardware to user:

| Layer | Component | Purpose |

|-------|-----------|---------|

| Hardware | Boot ROM, SEP, TouchID/Touch Bar | Immutable root of trust; biometric secrets |

| Boot | iBoot, kernel cache, SSV | Verified boot chain; sealed system volume |

| Kernel | AMFI, sandbox (sandboxd), AppleMobileFileIntegrity | Binary validation at exec; syscall filtering; entitlement enforcement |

| System services | launchd, tccd, securityd, logd, mdmclientd | PID-1 supervisor; TCC daemon; keychain daemon; log daemon; MDM agent |

| Frameworks | EndpointSecurity.framework, Security.framework, LocalAuthentication.framework | Apple-blessed APIs for telemetry, keychain, biometric auth |

| Userspace | tccd, mdmclientd, EDR System Extensions, browsers, apps | The attack surface most red teamers care about |

The trust flows top-down: hardware verifies boot chain verifies kernel verifies system binaries verifies userspace. A break at any layer subverts layers above. SIP and SSV together make layer 2 (boot) and layer 3 (kernel) very hard to subvert on modern Apple Silicon; most practical attacks target layer 5-6 (userspace and apps).

Detection Engineering

For defenders building macOS detection (or for red teamers modeling what defenders see), the layered telemetry stack enables layered detection:

Layer 1: Process Telemetry (ESF `exec` events)

Layer 2: File Telemetry (ESF `write`, `rename`, `unlink`)

Layer 3: Network Telemetry

Layer 4: Behavior Indicators

Lab Build Guide

A reproducible macOS test lab is essential — never test live exploits on a daily-driver Mac. Recommended stack:

Tier 1: Virtual Machines (free, snapshots)

Tier 2: Bare-Metal Test Mac

Tier 3: MDM Test Environment

Lab Hygiene

Cross-References

Learning Resources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.