Linux: auditd fundamentals
auditd stands for the audit daemon and it can be used to log events happening on a Linux host. It is a very powerful tool that can enable Threat Detection and/or - as the name suggests - create audit records. It writes to /var/log/audit/audit.log and collects such information as timestamp, PID, UID, Audit UID (auid), session info (ses), SELinux info (subj) and message (msg).
Installation
auditd is installed by default on most of the Linux distributions. In my case, I'm using RHEL 8 for the test purpose. The package is called audit.
Rules
auditd is rule-based software and it support the following three types of rules:
- control: to configure general settings of the audit system, such as event rate limit, etc.
- file: file rules or watches can monitor files or directories and are using the following syntax:
-w path-to-file -p permissions -k keyname - syscall: these rules are loaded into the matching engine that intercepts every single syscall on the system and for this reason they can impact performance; syscall rules are using the syntax below:
-a action,list -S syscall -F field=value -k keyname
Rules are stored under /etc/audit/audit.rules and /etc/audit/rules.d/.
An example of best practice auditd rules by Florian Roth: https://github.com/Neo23x0/auditd
PCI DSS compliance rules: https://github.com/linux-audit/audit-userspace/blob/master/rules/30-pci-dss-v31.rules
Custom Rules
auditctl can be used to create custom rules and is especially useful to test rules. Rules added with this utility do not persist system reboot.
Utilities
These three utilities are very helpful when working with auditd:
- ausearch: allows to search for specific events
- aureport: generic reporting utility, run with no options provides a summary (number of logins, failed logins, users, etc.)
- autrace: generates an audit trace for a command
Comments
Post a Comment