Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

How To Use SELinux Auditd Log

The SELinux auditd log provides crucial information regarding security-related incidents and events in your system. To effectively use these logs, you need to understand how to view, filter, and analyze them. In this tutorial, we will discuss how to use the auditd log with the help of the ausearch and aureport tools.

  • Locate the audit log file:

auditd stores its logs in the location specified in the configuration file (default: /var/log/audit/audit.log). Make sure that the auditd daemon is running and has been configured to capture the necessary information.

  • Use the ausearch tool:

ausearch is a command-line utility that allows you to search the auditd logs for specific events or criteria. The basic syntax is:

sudo ausearch [options]

Some useful options include:

  • -k key_name: Search for events with the specified audit key.
  • -m event_type: Search for events of a specific type (e.g., LOGIN, USER_AUTH).
  • -sc syscall: Search for events associated with a specific system call.
  • -f file_path: Search for events related to a specific file.
  • -se session_id: Search for events associated with a specific session ID.
  • -ts date_time: Search for events that occurred after the specified date and time.
  • -te date_time: Search for events that occurred before the specified date and time.

Examples:

  • Search for events with the key "file_access":

    sudo ausearch -k file_access
    
  • Search for login events:

    sudo ausearch -m LOGIN
    
  • Search for events related to the /etc/passwd file:

    sudo ausearch -f /etc/passwd
    
  • Use the aureport tool:

aureport is another command-line utility that generates summary reports based on the auditd logs. The basic syntax is:

sudo aureport [options]

Some useful options include:

  • -au: Generate a report of authentication events.
  • -l: Generate a report of login events.
  • -f: Generate a report of file events.
  • -k: Generate a report of events with audit keys.
  • -e: Generate a report of executable events.
  • -r: Generate a report of anomaly events.
  • -ts date_time: Specify the start time for the report.
  • -te date_time: Specify the end time for the report.

Examples:

  • Generate an authentication report:

    sudo aureport -au
    
  • Generate a report of file events between two timestamps:

    sudo aureport -f -ts 2023-06-01 00:00:00 -te 2023-06-30 23:59:59
    
  • Parse and analyze the output:

The output of the ausearch and aureport tools might be difficult to read initially. However, with practice, you can identify key information, such as event types, timestamps, user IDs, and other relevant data. Use this information to investigate potential security incidents, track user activities, and monitor system changes.

In this tutorial, we have discussed how to use the SELinux auditd log with the ausearch and aureport tools. By leveraging these tools, you can effectively monitor and analyze your system's security-related events, helping you identify potential threats and maintain a secure environment.

  1. Interpreting auditd logs in SELinux: Use ausearch or aureport to interpret auditd logs. Example:

    ausearch -m AVC
    
  2. Searching and filtering auditd logs in SELinux: Search logs based on criteria. Example, search for a specific user's activities:

    ausearch -ua <username>
    
  3. Analyzing security events in SELinux using auditd logs: Analyze logs for security events. Example, identify unauthorized file accesses:

    ausearch -m avc -sv f
    
  4. Troubleshooting with auditd logs in SELinux: Troubleshoot issues by examining audit logs. Example, troubleshoot AVC denials:

    ausearch -m avc -ts recent