Audit Rules for Security Monitoring
What you'll learn: How to implement industry-standard audit rules that detect critical security events like privilege escalation and unauthorized configuration changes.
Why Security-Focused Audit Rules Matter
Now that you understand how to use auditd for file watches, system calls, and user activity tracking, the question becomes: what exactly should you monitor? Just like a security camera system needs to point at the right doors and windows, your audit framework needs rules targeting security-critical events.
Security frameworks like CIS Benchmarks and DISA STIGs provide pre-defined audit rule sets that capture the events most commonly exploited in attacks.
Core Security Monitoring Rules
Privilege Escalation Detection
Monitor when users gain root privileges or modify privilege-granting files:
# Watch sudo usage
-w /usr/bin/sudo -p x -k privilege_escalation
# Monitor sudoers file changes
-w /etc/sudoers -p wa -k sudoers_changes
-w /etc/sudoers.d/ -p wa -k sudoers_changes
Security-Relevant Configuration Monitoring
Track changes to authentication and access control configurations:
# Monitor password and group file changes
-w /etc/passwd -p wa -k identity_changes
-w /etc/group -p wa -k identity_changes
-w /etc/shadow -p wa -k shadow_changes
# Watch PAM configuration
-w /etc/pam.d/ -p wa -k pam_changes
# Monitor SSH daemon configuration
-w /etc/ssh/sshd_config -p wa -k sshd_config_changes
Kernel Module Loading
Detect potentially malicious kernel modules:
# System call auditing for module operations
-a always,exit -F arch=b64 -S init_module -S delete_module -k kernel_modules
Implementing Standard Rulesets
Both CIS and STIG provide complete audit rule files you can deploy directly. These rules cover file integrity, privileged command execution, network activity, and critical system changes—essentially creating a comprehensive security event log.
Key Takeaway: Audit rules based on CIS/STIG standards transform your logging from generic system events into a targeted security monitoring system that detects privilege abuse and unauthorized changes.