Hacktricks-skills macos-sip-analysis
Analyze macOS System Integrity Protection (SIP) status, identify potential bypass vectors, and assess system security posture. Use this skill whenever the user mentions macOS security, SIP, System Integrity Protection, privilege escalation on macOS, checking system protections, analyzing SIP bypasses, or needs to understand macOS security mechanisms. Trigger for any macOS security assessment, penetration testing, or system hardening tasks.
git clone https://github.com/abelrguezr/hacktricks-skills
skills/macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-sip/SKILL.MDmacOS SIP Analysis Skill
This skill helps analyze macOS System Integrity Protection (SIP) configurations, identify potential security gaps, and understand bypass vectors for security assessments.
When to Use This Skill
Use this skill when:
- Assessing macOS system security posture
- Checking SIP status and configuration
- Identifying potential SIP bypass vectors
- Understanding macOS privilege escalation paths
- Analyzing Sealed System Snapshots
- Performing macOS penetration testing
- Reviewing system hardening requirements
Core Concepts
What is SIP?
System Integrity Protection (SIP) is a macOS security mechanism that prevents even root users from modifying protected system files and directories. Key protected paths include:
/System/bin/sbin/usr
SIP rules are defined in
/System/Library/Sandbox/rootless.conf. Paths prefixed with * are exceptions where modifications are allowed.
SIP Status Commands
# Check if SIP is enabled csrutil status # Check authenticated root status (for sealed snapshots) csrutil authenticated-root status # Check mount status (read-only sealed volumes) mount | grep -E "(sealed|read-only)"
Identifying SIP Protection
Use
ls -lOd to check for protection flags:
# Check directory protection status ls -lOd /usr/libexec/cups ls -lOd /usr/libexec
Flag meanings:
: Directory is SIP-protected (no create/modify/delete)restricted
: Directory cannot be deleted, but files inside can be modifiedsunlnk
extended attribute: File is SIP-protectedcom.apple.rootless
SIP Bypass Vectors
1. Installer Package Bypasses
Apple-signed installer packages can bypass SIP protections. Notable vulnerabilities:
- CVE-2019-8561: Package swap after signature verification
- CVE-2020-9854: Arbitrary binary execution from mounted images
- CVE-2021-30892 (Shrootless):
execution via/etc/zshenvsystem_installd - CVE-2022-22583: Virtual image mounting in
for post-install scripts/tmp - CVE-2023-42860: Symlink-based file unrestricting
2. Entitlement-Based Bypasses
Key SIP-bypassing entitlements:
: Child processes inherit SIP bypasscom.apple.rootless.install.heritable
: Direct SIP bypasscom.apple.rootless.install
: Control launchdcom.apple.rootless.xpc.bootstrap
: Unfettered filesystem accesscom.apple.rootless.internal.installer-equivalent
3. File System Manipulation
- Inexistent files: Files listed in
but not present can be createdrootless.conf - Mount over protected folders: Mount filesystems over SIP-protected paths
- fsck_cs vulnerability: Symbolic link corruption of
Info.plist
4. Environment Variable Exploitation
: Executed by/etc/zshenv
in non-interactive modezsh
: User-level persistence and privilege escalation~/.zshenv
: Bash environment variable exploitationBASH_ENV
: Perl script injectionPERL5OPT
Sealed System Snapshots
Introduced in macOS Big Sur (11.0), Sealed System Snapshots provide additional protection:
Key Features
- Immutable System: System volume cannot be modified
- Safe Updates: New snapshots created for each update
- Data Separation: Data stored on separate volume
Checking Snapshots
# List APFS volumes and snapshots diskutil apfs list # Check for sealed status mount | grep "sealed" # Verify authenticated root csrutil authenticated-root status
Important Paths
- System volume:
(sealed, read-only)/ - Data volume:
(user-accessible)/System/Volumes/Data - Update mount:
/System/Volumes/Update/mnt1
Security Assessment Checklist
When assessing macOS SIP security:
-
Check SIP Status
- Run
csrutil status - Verify
csrutil authenticated-root status
- Run
-
Analyze Protected Paths
- Check
for exceptions/System/Library/Sandbox/rootless.conf - Identify
andrestricted
flags on key directoriessunlnk
- Check
-
Identify Bypass Opportunities
- Check for Apple-signed packages that could be exploited
- Look for
or/etc/zshenv
files~/.zshenv - Verify no symbolic links to protected files
-
Review Entitlements
- Check for processes with
entitlementscom.apple.rootless.* - Identify XPC services with SIP-bypassing capabilities
- Check for processes with
-
Assess Snapshot Integrity
- Verify snapshots are sealed
- Check mount status for read-only protection
Common Commands Reference
# SIP Status csrutil status csrutil authenticated-root status # Directory Protection ls -lOd /usr/libexec ls -lOd /System/Library/Sandbox/rootless.conf # Snapshot Analysis diskutil apfs list mount | grep -E "(sealed|read-only)" # Check for zshenv files ls -la /etc/zshenv ls -la ~/.zshenv # Check extended attributes xattr -l /path/to/file | grep rootless
Important Notes
- SIP cannot be disabled without recovery mode: Requires
at boot, thenCommand+Rcsrutil disable - Sealed snapshots prevent boot if modified: OS won't boot if sealed snapshot is tampered with
- Partial SIP disabling:
keeps SIP but removes debugging protectionscsrutil enable --without debug - Sandbox hooks:
prevents modification ofhook_vnode_check_setextattr
attributecom.apple.rootless
When NOT to Use This Skill
- For general macOS troubleshooting unrelated to security
- For user data recovery tasks
- For application installation guidance
- For non-security-related system configuration
Related Security Concepts
- TCC (Transparency, Consent, and Control): macOS privacy database that can be manipulated via SIP bypass
- Kernel Extensions: SIP prevents loading unsigned kexts
- NVRAM Variables: SIP restricts modification of boot-related variables
- Task Ports: SIP prevents getting task-ports for Apple-signed processes