$npx -y skills add Prohao42/aimy-skill --skill macos-security-bypassmacOS security bypass playbook. Use when targeting macOS endpoints and need to bypass TCC, Gatekeeper, SIP, sandbox, code signing, or entitlement-based protections during authorized red team or pentest engagements.
| 1 | # SKILL: macOS Security Bypass — Expert Attack Playbook |
| 2 | |
| 3 | > **AI LOAD INSTRUCTION**: Expert macOS security bypass techniques. Covers TCC bypass, Gatekeeper evasion, SIP restrictions, sandbox escape, and entitlement abuse. Base models miss version-specific bypass nuances and protection interaction effects. |
| 4 | |
| 5 | ## 0. RELATED ROUTING |
| 6 | |
| 7 | Before going deep, consider loading: |
| 8 | |
| 9 | - [macos-process-injection](../macos-process-injection/SKILL.md) when you need dylib injection, XPC exploitation, or Electron abuse after achieving initial access |
| 10 | - [linux-privilege-escalation](../linux-privilege-escalation/SKILL.md) for Unix-layer privesc techniques that also apply to macOS (SUID, cron, writable paths) |
| 11 | - [linux-security-bypass](../linux-security-bypass/SKILL.md) for shared Unix security bypass concepts |
| 12 | |
| 13 | ### Advanced Reference |
| 14 | |
| 15 | Also load [TCC_BYPASS_MATRIX.md](./TCC_BYPASS_MATRIX.md) when you need: |
| 16 | - Per-macOS-version TCC bypass mapping |
| 17 | - Protection-type-specific techniques (Camera, Microphone, FDA, Automation) |
| 18 | - MDM/configuration profile abuse patterns |
| 19 | |
| 20 | --- |
| 21 | |
| 22 | ## 1. TCC (TRANSPARENCY, CONSENT, CONTROL) OVERVIEW |
| 23 | |
| 24 | TCC is macOS's permission framework controlling access to sensitive resources (camera, microphone, contacts, full disk access, etc.). |
| 25 | |
| 26 | ### 1.1 TCC Database Locations |
| 27 | |
| 28 | | Database | Path | Controls | Protection | |
| 29 | |---|---|---|---| |
| 30 | | User-level | `~/Library/Application Support/com.apple.TCC/TCC.db` | Per-user consent decisions | SIP-protected since Catalina | |
| 31 | | System-level | `/Library/Application Support/com.apple.TCC/TCC.db` | System-wide consent decisions | SIP-protected | |
| 32 | | MDM-managed | Via configuration profiles | Push PPPC (Privacy Preferences Policy Control) | Device management | |
| 33 | |
| 34 | ```sql |
| 35 | -- Query TCC database (requires FDA or SIP off) |
| 36 | sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \ |
| 37 | "SELECT service, client, allowed FROM access;" |
| 38 | ``` |
| 39 | |
| 40 | ### 1.2 TCC Bypass Categories |
| 41 | |
| 42 | | Category | Mechanism | Typical Prerequisite | |
| 43 | |---|---|---| |
| 44 | | FDA app exploitation | Piggyback on apps already granted Full Disk Access | Write access to FDA app's bundle or plugin dir | |
| 45 | | Direct DB modification | Edit TCC.db to grant consent | SIP disabled or FDA | |
| 46 | | Inherited permissions | Child process inherits parent's TCC grants | Code execution in context of FDA-granted app | |
| 47 | | Automation abuse | Apple Events / osascript to control TCC-granted app | Automation permission (lower bar than direct TCC) | |
| 48 | | Mounting tricks | Mount a crafted disk image containing modified TCC.db | Local access, pre-Ventura | |
| 49 | | SQL injection in TCC | Malformed bundle IDs triggering SQL injection in TCC subsystem | CVE-2023-32364 and similar | |
| 50 | |
| 51 | ### 1.3 Known TCC Bypass Patterns |
| 52 | |
| 53 | **Terminal / iTerm FDA inheritance**: Terminal.app granted FDA → any command run inherits FDA → read any file. |
| 54 | |
| 55 | ```bash |
| 56 | # If Terminal has FDA, this reads protected files directly |
| 57 | cat ~/Library/Mail/V*/MailData/Envelope\ Index |
| 58 | cat ~/Library/Messages/chat.db |
| 59 | ``` |
| 60 | |
| 61 | **Finder automation**: Automate Finder (lower permission bar) to access files in protected locations. |
| 62 | |
| 63 | ```applescript |
| 64 | tell application "Finder" |
| 65 | set f to POSIX file "/Users/target/Library/Mail/V9/MailData/Envelope Index" |
| 66 | duplicate f to desktop |
| 67 | end tell |
| 68 | ``` |
| 69 | |
| 70 | **System Preferences / System Settings injection**: Inject into a process that already has TCC permissions by writing to its Application Scripts folder. |
| 71 | |
| 72 | **MDM profile abuse**: PPPC profiles can pre-approve TCC permissions. Rogue MDM enrollment or compromised MDM server → push PPPC payload. |
| 73 | |
| 74 | --- |
| 75 | |
| 76 | ## 2. GATEKEEPER BYPASS |
| 77 | |
| 78 | Gatekeeper blocks unsigned or unnotarized apps from executing. Core enforcement depends on the `com.apple.quarantine` extended attribute. |
| 79 | |
| 80 | ### 2.1 Quarantine Attribute Removal |
| 81 | |
| 82 | ```bash |
| 83 | # Check quarantine attribute |
| 84 | xattr -l /path/to/app |
| 85 | # Output: com.apple.quarantine: 0083;... |
| 86 | |
| 87 | # Remove quarantine (requires write access) |
| 88 | xattr -d com.apple.quarantine /path/to/app |
| 89 | # Recursive for app bundles |
| 90 | xattr -rd com.apple.quarantine /path/to/MyApp.app |
| 91 | ``` |
| 92 | |
| 93 | ### 2.2 Bypass Techniques |
| 94 | |
| 95 | | Technique | How It Works | macOS Version | |
| 96 | |---|---|---| |
| 97 | | `xattr -d` removal | Remove quarantine before execution | All (requires local access) | |
| 98 | | App translocation bypass | Apps in certain locations skip translocation | Pre-Catalina | |
| 99 | | Archive tools that strip quarantine | Some unarchiver apps don't propagate quarantine | Varies by tool | |
| 100 | | Unsigned code in signed bundle | Notarized app bundles with unsigned nested helpers | Pre-Ventura (CVE-2022-42821) | |
| 101 | | Safari auto-extract + open | Downloaded ZIP auto-extracted, app opened before quarantine fully applied | Safari-specific, patched | |
| 102 | | ACL abuse | `com.apple.quarantine` can be blocked by ACLs set before download | Requires pre-positioning | |
| 103 | | Disk image (DMG) tricks |