How to Configure Custom Audit Logs and Kernel Audit Masks in macOS Using audit_control

In high-security enterprise environments, monitoring user actions, authentication failures, file access anomalies, and process executions is vital for compliance and threat detection. While macOS provides modern unified logging (log stream and os_log), it also includes a certified OpenBSM (Basic Security Module) kernel auditing subsystem. The OpenBSM daemon (auditd) operates at the Darwin kernel layer, intercepting system calls and recording tamper-resistant cryptographic audit trails. Systems administrators can customize event collection by editing the /etc/security/audit_control configuration file.

Understanding OpenBSM Auditing Architecture in macOS

The macOS OpenBSM subsystem progress through several interlocking components:

  • Darwin Kernel Audit Hook: Intercepts designated system calls (such as execve, setuid, open, or rename) and serializes security context into binary audit records.
  • auditd Daemon: The user-space daemon that receives binary audit records from the kernel and writes them into structured audit trail log files located in /var/audit/.
  • audit_control Configuration: The primary system control file defining which event classes are recorded, directory storage paths, minimum free disk thresholds, and log rotation policies.
  • praudit and auditreduce: Command-line utilities designed to parse, filter, and convert binary OpenBSM audit streams into human-readable text or XML.

Structure of the /etc/security/audit_control File

The configuration file resides at /etc/security/audit_control. Inspect its contents using Terminal:

sudo cat /etc/security/audit_control

Key directives include:

  • dir: Specifies the storage directory for binary audit logs (default: /var/audit).
  • flags: Defines the system-wide event mask for all unflagged user sessions.
  • naflags: Defines audit masks applied to non-attributable events (system events not tied to a logged-in user, such as boot daemons).
  • minfree: Defines the minimum percentage of free disk space that must remain before warnings are generated (default: 20).
  • expire-after: Specifies the retention duration or maximum aggregate file size for log rotation.

Configuring Custom Event Classes and Kernel Audit Masks

Event masks specify whether to record successful events (prefixed by +), failed events (prefixed by -), or both. Common event class identifiers include:

  • ad: Administrative actions (e.g. date changes, permission alterations).
  • lo: Login, logout, and screen-lock events.
  • aa: Authentication and authorization checks.
  • pc: Process creation and termination (calls to fork and exec).
  • fw: File write and creation events.
  • fr: File read events.
  • ex: Program execution tracking.

To edit your audit policy, open /etc/security/audit_control in an elevated text editor:

sudo nano /etc/security/audit_control

Configure a robust security monitoring profile by adjusting the flags line:

# Record all logins/logouts, administrative actions, and failed file access attempts
flags:lo,aa,ad,-fr,-fw

# Audit non-attributable authentication events
naflags:lo,aa

Applying Changes and Verifying auditd Execution

After modifying audit_control, instruct the running auditd daemon to re-read the configuration file without restarting the operating system:

sudo audit -s

Verify that the audit daemon is active and operating normally:

sudo launchctl list | grep auditd

Reading and Parsing Audit Trail Records with praudit

Because OpenBSM logs are stored in a compact binary format to prevent tampering, use praudit to convert records to text:

# Read the current active audit log file
sudo praudit -l /var/audit/current

# Format output as formatted XML for ingestion into SIEM agents
sudo praudit -x /var/audit/current | head -n 30

To filter for specific events (such as failed authentication attempts) across archived audit logs, pipe through auditreduce:

# Extract failed login events from all available logs
sudo auditreduce -c lo -m -1 | praudit -l

Configuring kernel audit masks with audit_control provides security teams with forensic visibility into low-level macOS system activities, satisfying strict compliance frameworks while maintaining efficient disk utilization.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.