Hacktricks-skills macos-authorization-audit
Audit and analyze macOS authorization database and authd daemon for security assessments. Use this skill whenever you need to examine macOS privilege escalation vectors, check authorization rules in /var/db/auth.db, understand authd behavior, or test Security.framework APIs. Trigger this skill for any macOS security audit involving authorization rights, privilege checks, or when investigating how macOS controls sensitive operations through the authorization system.
git clone https://github.com/abelrguezr/hacktricks-skills
skills/macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-authorizations-db-and-authd/SKILL.MDmacOS Authorization Audit Skill
This skill helps you audit and analyze macOS authorization systems, including the authorization database (
/var/db/auth.db) and the authd daemon that enforces privilege checks.
What This Skill Does
- Query and analyze authorization rules in the macOS authorization database
- Understand authorization rule structure and semantics
- Test authorization rights using the
commandsecurity - Identify potential privilege escalation vectors
- Document authorization configurations for security assessments
Authorization Database Overview
The authorization database at
/var/db/auth.db stores permissions for sensitive operations performed in user space, typically by XPC services that need to verify if a calling client is authorized.
Database Structure
The
rules table contains authorization rules with these key columns:
| Column | Description |
|---|---|
| Unique identifier for the rule |
| Rule type (1 or 2) defining authorization logic |
| Rule category: , , , , or |
| User group for group-based authorization |
| K-of-N parameter for subrule satisfaction |
| Duration in seconds before authorization expires |
| Behavior modification flags |
| Maximum allowed authorization attempts |
| Serialized authorization requirements |
| Human-readable description |
Common Authorization Classes
- allow: Grants permission unconditionally
- deny: Denies permission unconditionally
- user: Requires user authentication (with optional group membership)
- rule: Array of subrules that must be satisfied
- evaluate-mechanisms: Uses built-in mechanisms or SecurityAgentPlugins
Core Commands
Query the Authorization Database
# List all rules with names and comments sudo sqlite3 /var/db/auth.db "SELECT name, comment FROM rules" # Get specific rule details security authorizationdb read <rule-name> # Example: Check TCC admin modification rights security authorizationdb read com.apple.tcc.util.admin
Test Authorization Execution
# Test AuthorizationExecuteWithPrivileges API security execute-with-privileges <command> # Example: Run ls as root (will prompt for admin password) security execute-with-privileges /bin/ls
Inspect Authd Logs
# View authd daemon logs sudo cat /var/log/authd.log # Follow logs in real-time sudo tail -f /var/log/authd.log
Common Authorization Rights
Admin Authentication Rights
| Right Name | Purpose | Key Properties |
|---|---|---|
| Authenticate as administrator | , , |
| Shared admin authentication | , |
| Admin privilege access | Requires admin authentication |
System Modification Rights
| Right Name | Purpose |
|---|---|
| Modify TCC (privacy) settings |
| Install software |
| Network configuration |
| Security settings modification |
Audit Workflow
Step 1: Enumerate Authorization Rules
# Get complete rule inventory sudo sqlite3 /var/db/auth.db "SELECT name, class, comment FROM rules ORDER BY name" # Export to file for analysis sudo sqlite3 -header -csv /var/db/auth.db "SELECT * FROM rules" > auth_rules.csv
Step 2: Analyze High-Value Rules
Focus on rules that:
- Grant admin privileges (
)authenticate-admin* - Allow system modifications (
)system.privilege.* - Have
(unconditional access)class: allow - Have long timeouts or high
valuestries
# Find rules with allow class sudo sqlite3 /var/db/auth.db "SELECT name, comment FROM rules WHERE class='allow'" # Find rules with high timeout values sudo sqlite3 /var/db/auth.db "SELECT name, timeout, comment FROM rules WHERE timeout > 300"
Step 3: Test Authorization Paths
# Test if a command can be executed with privileges security execute-with-privileges /bin/ls -la /var/db # Check specific authorization right security authorizationdb read system.privilege.admin
Step 4: Document Findings
Create a structured report:
## Authorization Audit Findings ### High-Risk Rules - [Rule Name]: [Comment] - [Risk Assessment] ### Unconditional Allow Rules - [Rule Name]: Grants access without authentication ### Long Timeout Rules - [Rule Name]: Timeout of [X] seconds ### Recommendations - [Specific remediation steps]
Security Considerations
Privilege Escalation Vectors
- Weak Authorization Rules: Rules with
grant access without authenticationclass: allow - Excessive Timeouts: Long timeout values extend privilege windows
- High Tries Values: Large
values enable brute-force attemptstries - Group-Based Access: Rules using
depend on group membership integritygroup: admin
Defense Recommendations
- Audit authorization rules regularly
- Remove or restrict unnecessary
class rulesallow - Set appropriate timeout values (30-60 seconds typical)
- Limit
to prevent brute-force attackstries - Monitor
for suspicious activity/var/log/authd.log
Reference Files
- Authorization database/var/db/auth.db
- Initial authorization configuration/System/Library/Security/authorization.plist
- Authd daemon logs/var/log/authd.log
- Built-in authentication mechanisms/System/Library/CoreServices/SecurityAgentPlugins/
- Custom authentication plugins/Library/Security/SecurityAgentPlugins/
Example Analysis
TCC Admin Modification Rule
<dict> <key>class</key> <string>rule</string> <key>comment</key> <string>For modification of TCC settings.</string> <key>rule</key> <array> <string>authenticate-admin-nonshared</string> </array> </dict>
Analysis: This rule requires admin authentication to modify TCC (privacy) settings. The
authenticate-admin-nonshared subrule means:
- User must be in
groupadmin - Authentication is not shared across sessions
- 30-second timeout
- 10000 allowed attempts
Security Implications
- TCC controls privacy permissions (camera, mic, screen recording, etc.)
- Admin authentication is required, which is appropriate
- High
value (10000) could allow brute-force if password is weaktries - Non-shared authentication limits session reuse attacks
Tools and Scripts
Use the bundled
query-auth-db.sh script for common authorization database queries:
# Run the query script ./scripts/query-auth-db.sh # Query specific rule ./scripts/query-auth-db.sh --rule "authenticate-admin-nonshared" # Export all rules to CSV ./scripts/query-auth-db.sh --export auth_rules.csv
When to Use This Skill
Use this skill when:
- Conducting macOS security assessments
- Investigating privilege escalation paths
- Auditing system authorization configurations
- Understanding how macOS controls sensitive operations
- Testing authorization enforcement mechanisms
- Documenting macOS security posture
- Preparing for compliance audits (SOC2, ISO27001, etc.)
Limitations
- Requires root/sudo access to query the authorization database
- Some authorization rights may be system-protected and cannot be modified
- Authd behavior may vary across macOS versions
- SecurityAgentPlugins may have version-specific implementations