audit.rules

The audit.rules file is a critical component of the Linux Audit Framework (auditd). It defines the audit rules that specify which system events should be monitored and logged by auditd. These rules dictate what actions and activities are recorded in the audit logs (/var/log/audit/audit.log) and are essential for security monitoring, compliance auditing, and forensic analysis. Here's an overview of audit.rules and its importance:

Purpose of audit.rules

The primary purpose of audit.rules is to:

  • Specify detailed audit rules that define which system calls, files, directories, or processes should be audited.

  • Customize audit behavior to meet specific security requirements and compliance standards.

  • Enhance visibility into system activities, aiding in incident detection, response, and post-incident analysis.

Structure and Syntax

audit.rules uses a specific syntax to define audit rules. Each rule typically consists of:

  • Field Definitions: Specify the type of event or condition to audit (-a for action, -S for syscall, -w for file or directory).

  • Filter Parameters: Define specific attributes or criteria for auditing (e.g., path, permissions, user ID).

  • Action: Optionally assign a key (-k) to associate events with a specific identifier for easier searching and reporting.

Example Audit Rules

Here are a few examples of audit rules commonly found in audit.rules:

  1. Monitor File Access:

    -w /etc/passwd -p rwxa -k passwd_access
    • -w: Watch for events related to /etc/passwd.

    • -p rwxa: Audit read, write, execute, and attribute changes.

    • -k passwd_access: Assign a key for easier identification in audit logs.

  2. Monitor System Calls:

    -a always,exit -F arch=b64 -S execve -k syscall_execution
    • -a always,exit: Audit all exit events.

    • -F arch=b64: Filter events on a 64-bit architecture.

    • -S execve: Audit execve system calls (program execution).

    • -k syscall_execution: Key to identify syscall execution events.

  3. Monitor User Logins:

    -w /var/log/auth.log -p wa -k auth_log_changes
    • -w /var/log/auth.log: Watch changes to the authentication log file.

    • -p wa: Audit write and attribute changes.

    • -k auth_log_changes: Key for tracking authentication log changes.

Managing audit.rules

  • Editing: Use a text editor (vi, nano, etc.) with administrative privileges to modify audit.rules (/etc/audit/audit.rules).

  • Loading Rules: After editing audit.rules, load the rules into the audit system using the auditctl command:

    sudo auditctl -R /etc/audit/audit.rules
  • Persisting Rules: To make audit rules persistent across reboots, ensure they are loaded during system startup (/etc/init.d/auditd or systemd service).

Best Practices

  • Specificity: Define audit rules to capture only necessary events to minimize audit log size and optimize performance.

  • Regular Review: Periodically review audit logs (/var/log/audit/audit.log) for suspicious activities and security incidents.

  • Compliance: Align audit rules with industry standards (PCI DSS, HIPAA) and organizational security policies.

Conclusion

audit.rules is instrumental in configuring the Linux Audit Framework (auditd) to monitor and record critical system events. By defining and managing audit rules effectively, administrators can enhance system security, detect potential threats, and maintain compliance with regulatory requirements.

Last updated