-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudit-base.rules.template
More file actions
167 lines (145 loc) · 9.01 KB
/
audit-base.rules.template
File metadata and controls
167 lines (145 loc) · 9.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# =============================================================================
# Ubuntu Server Security - auditd Base Rules (CIS Level 1)
# =============================================================================
#
# CIS Ubuntu Linux Benchmark - Section 4.1.x
# Production-ready rules with minimal performance impact
#
# Installation:
# sudo cp audit-base.rules.template /etc/audit/rules.d/99-cis-base.rules
# sudo augenrules --load
#
# =============================================================================
# -----------------------------------------------------------------------------
# Buffer and Backlog Configuration
# -----------------------------------------------------------------------------
# CIS 4.1.1.3 - Ensure audit_backlog_limit is sufficient
-b 8192
# Failure mode: 0=silent, 1=printk, 2=panic
-f 1
# -----------------------------------------------------------------------------
# CIS 4.1.3 - Ensure events that modify date and time information are collected
# -----------------------------------------------------------------------------
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -k time-change
-a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -k time-change
-a always,exit -F arch=b64 -S clock_settime -k time-change
-a always,exit -F arch=b32 -S clock_settime -k time-change
-w /etc/localtime -p wa -k time-change
# -----------------------------------------------------------------------------
# CIS 4.1.4 - Ensure events that modify user/group information are collected
# -----------------------------------------------------------------------------
-w /etc/group -p wa -k identity
-w /etc/passwd -p wa -k identity
-w /etc/gshadow -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/security/opasswd -p wa -k identity
# -----------------------------------------------------------------------------
# CIS 4.1.5 - Ensure events that modify the system's network environment are collected
# -----------------------------------------------------------------------------
-a always,exit -F arch=b64 -S sethostname -S setdomainname -k system-locale
-a always,exit -F arch=b32 -S sethostname -S setdomainname -k system-locale
-w /etc/issue -p wa -k system-locale
-w /etc/issue.net -p wa -k system-locale
-w /etc/hosts -p wa -k system-locale
-w /etc/network -p wa -k system-locale
-w /etc/netplan -p wa -k system-locale
# -----------------------------------------------------------------------------
# CIS 4.1.6 - Ensure events that modify the system's Mandatory Access Controls are collected
# -----------------------------------------------------------------------------
-w /etc/apparmor/ -p wa -k MAC-policy
-w /etc/apparmor.d/ -p wa -k MAC-policy
# -----------------------------------------------------------------------------
# CIS 4.1.7 - Ensure login and logout events are collected
# -----------------------------------------------------------------------------
-w /var/log/faillog -p wa -k logins
-w /var/log/lastlog -p wa -k logins
-w /var/log/tallylog -p wa -k logins
# -----------------------------------------------------------------------------
# CIS 4.1.8 - Ensure session initiation information is collected
# -----------------------------------------------------------------------------
-w /var/run/utmp -p wa -k session
-w /var/log/wtmp -p wa -k session
-w /var/log/btmp -p wa -k session
# -----------------------------------------------------------------------------
# CIS 4.1.9 - Ensure discretionary access control permission modification events are collected
# -----------------------------------------------------------------------------
-a always,exit -F arch=b64 -S chmod -S fchmod -S fchmodat -F auid>=1000 -F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b32 -S chmod -S fchmod -S fchmodat -F auid>=1000 -F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b64 -S chown -S fchown -S fchownat -S lchown -F auid>=1000 -F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b32 -S chown -S fchown -S fchownat -S lchown -F auid>=1000 -F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b64 -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S lremovexattr -S fremovexattr -F auid>=1000 -F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b32 -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S lremovexattr -S fremovexattr -F auid>=1000 -F auid!=4294967295 -k perm_mod
# -----------------------------------------------------------------------------
# CIS 4.1.10 - Ensure unsuccessful unauthorized file access attempts are collected
# -----------------------------------------------------------------------------
-a always,exit -F arch=b64 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EACCES -F auid>=1000 -F auid!=4294967295 -k access
-a always,exit -F arch=b32 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EACCES -F auid>=1000 -F auid!=4294967295 -k access
-a always,exit -F arch=b64 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EPERM -F auid>=1000 -F auid!=4294967295 -k access
-a always,exit -F arch=b32 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EPERM -F auid>=1000 -F auid!=4294967295 -k access
# -----------------------------------------------------------------------------
# CIS 4.1.11 - Ensure use of privileged commands is collected
# -----------------------------------------------------------------------------
# Note: Run this to generate rules for your system:
# find / -xdev \( -perm -4000 -o -perm -2000 \) -type f 2>/dev/null | \
# awk '{print "-a always,exit -F path=" $1 " -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged"}'
#
# Common privileged commands (add more as needed):
-a always,exit -F path=/usr/bin/sudo -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged
-a always,exit -F path=/usr/bin/su -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged
-a always,exit -F path=/usr/bin/passwd -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged
-a always,exit -F path=/usr/bin/chsh -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged
-a always,exit -F path=/usr/bin/chfn -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged
-a always,exit -F path=/usr/bin/newgrp -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged
-a always,exit -F path=/usr/bin/gpasswd -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged
-a always,exit -F path=/usr/bin/chage -F perm=x -F auid>=1000 -F auid!=4294967295 -k privileged
# -----------------------------------------------------------------------------
# CIS 4.1.12 - Ensure successful file system mounts are collected
# -----------------------------------------------------------------------------
-a always,exit -F arch=b64 -S mount -F auid>=1000 -F auid!=4294967295 -k mounts
-a always,exit -F arch=b32 -S mount -F auid>=1000 -F auid!=4294967295 -k mounts
# -----------------------------------------------------------------------------
# CIS 4.1.14 - Ensure changes to system administration scope (sudoers) is collected
# -----------------------------------------------------------------------------
-w /etc/sudoers -p wa -k scope
-w /etc/sudoers.d/ -p wa -k scope
# -----------------------------------------------------------------------------
# CIS 4.1.15 - Ensure system administrator command executions (sudo) are collected
# -----------------------------------------------------------------------------
-a always,exit -F arch=b64 -C euid!=uid -F euid=0 -F auid>=1000 -F auid!=4294967295 -S execve -k actions
-a always,exit -F arch=b32 -C euid!=uid -F euid=0 -F auid>=1000 -F auid!=4294967295 -S execve -k actions
# -----------------------------------------------------------------------------
# CIS 4.1.16 - Ensure kernel module loading and unloading is collected
# -----------------------------------------------------------------------------
-w /sbin/insmod -p x -k modules
-w /sbin/rmmod -p x -k modules
-w /sbin/modprobe -p x -k modules
-a always,exit -F arch=b64 -S init_module -S delete_module -k modules
# -----------------------------------------------------------------------------
# Additional Recommended Rules (beyond CIS minimum)
# -----------------------------------------------------------------------------
# SSH configuration changes
-w /etc/ssh/sshd_config -p wa -k sshd_config
-w /etc/ssh/sshd_config.d/ -p wa -k sshd_config
# Cron job modifications
-w /etc/crontab -p wa -k cron
-w /etc/cron.d/ -p wa -k cron
-w /etc/cron.daily/ -p wa -k cron
-w /etc/cron.hourly/ -p wa -k cron
-w /etc/cron.weekly/ -p wa -k cron
-w /etc/cron.monthly/ -p wa -k cron
-w /var/spool/cron/ -p wa -k cron
# Systemd service modifications
-w /etc/systemd/ -p wa -k systemd
-w /lib/systemd/ -p wa -k systemd
# PAM configuration
-w /etc/pam.d/ -p wa -k pam
-w /etc/security/ -p wa -k pam
# Audit configuration (self-protection)
-w /etc/audit/ -p wa -k auditconfig
-w /etc/audisp/ -p wa -k auditconfig
# =============================================================================
# END OF CIS LEVEL 1 BASE RULES
# =============================================================================
# To make rules immutable (recommended for production), uncomment:
# -e 2
# WARNING: With -e 2, rule changes require system reboot!