audit: Filter-out unavailable AArch64 syscalls
[ta/infra-ansible.git] / roles / audit / templates / 30-stig.rules.j2
1 ## The purpose of these rules is to meet the stig auditing requirements
2 ## These rules depends on having 10-base-config.rules & 99-finalize.rules
3 ## installed.
4
5 ## NOTE:
6 ## 1) if this is being used on a 32 bit machine, comment out the b64 lines
7 ## 2) These rules assume that login under the root account is not allowed.
8 ## 3) It is also assumed that 1000 represents the first usable user account. To
9 ##  be sure, look at UID_MIN in /etc/login.defs.
10 ## IMS uses 500 as the first usable account
11 ## 4) If these rules generate too much spurious data for your tastes, limit the
12 ## the syscall file rules with a directory, like -F dir=/etc
13 ## 5) You can search for the results on the key fields in the rules
14 ##
15
16 ## Filter syscalls not available on certain platforms
17 ##
18 {%- set S_chmod = '-S chmod' %}
19 {%- set S_chown = '-S chown' %}
20 {%- set S_lchown = '-S lchown' %}
21 {%- set S_creat = '-S creat' %}
22 {%- set S_open = '-S open' %}
23 {%- set S_rmdir = '-S rmdir' %}
24 {%- set S_unlink = '-S unlink' %}
25 {%- set S_rename = '-S rename' %}
26
27 {% if ansible_architecture in ['aarch64'] %}
28     {%- set S_chmod = '' %}
29     {%- set S_chown = '' %}
30     {%- set S_lchown = '' %}
31     {%- set S_creat = '' %}
32     {%- set S_open = '' %}
33     {%- set S_rmdir = '' %}
34     {%- set S_unlink = '' %}
35     {%- set S_rename = '' %}
36 {% endif %}
37
38 ## (GEN002880: CAT II) The IAO will ensure the auditing software can
39 ## record the following for each audit event:
40 ##- Date and time of the event
41 ##- Userid that initiated the event
42 ##- Type of event
43 ##- Success or failure of the event
44 ##- For I&A events, the origin of the request (e.g., terminal ID)
45 ##- For events that introduce an object into a user's address space, and
46 ## for object deletion events, the name of the object, and in MLS
47 ## systems, the object's security level.
48 ##
49 ## Things that could affect time
50 -a always,exit -F arch=b64 -S adjtimex -S settimeofday -k time-change
51 -a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -k time-change
52 -a always,exit -F arch=b64 -S clock_settime -F a0=0x0 -k time-change
53 -a always,exit -F arch=b32 -S clock_settime -F a0=0x0 -k time-change
54 # Introduced in 2.6.39, commented out because it can make false positives
55 #-a always,exit -F arch=b32 -S clock_adjtime -F key=time-change
56 #-a always,exit -F arch=b64 -S clock_adjtime -F key=time-change
57 -w /etc/localtime -p wa -k time-change
58
59 ## Things that affect identity
60 -w /etc/group -p wa -k identity
61 -w /etc/passwd -p wa -k identity
62 -w /etc/gshadow -p wa -k identity
63 -w /etc/shadow -p wa -k identity
64 -w /etc/security/opasswd -p wa -k identity
65
66 -a always,exit -F arch=b32 -S setuid -F key=32bit_setuid
67 -a always,exit -F arch=b64 -S setuid -F key=64bit_setuid
68 -a always,exit -F arch=b32 -S setgid -F key=32bit_setgid
69 -a always,exit -F arch=b64 -S setgid -F key=64bit_setgid
70
71 ## Things that could affect system locale
72 -a always,exit -F arch=b64 -S sethostname -S setdomainname -k system-locale
73 -a always,exit -F arch=b32 -S sethostname -S setdomainname -k system-locale
74 -w /etc/issue -p wa -k system-locale
75 -w /etc/issue.net -p wa -k system-locale
76 -w /etc/hosts -p wa -k system-locale
77 -w /etc/sysconfig/network -p wa -k system-locale
78 -w /etc/sysconfig/network-scripts/ -p wa -k system-locale
79 -a always,exit -F dir=/etc/NetworkManager/ -F perm=wa -F key=system-locale
80
81 ## Things that could affect MAC policy
82 -a always,exit -F dir=/etc/selinux/ -F perm=wa -F key=MAC-policy
83 -a always,exit -F dir=/usr/share/selinux/ -F perm=wa -F key=MAC-policy
84
85 ## (GEN002900: CAT III) The IAO will ensure audit files are retained at
86 ## least one year; systems containing SAMI will be retained for five years.
87 ##
88 ## Site action - no action in config files
89
90 ## (GEN002920: CAT III) The IAO will ensure audit files are backed up
91 ## no less than weekly onto a different system than the system being
92 ## audited or backup media.
93 ##
94 ## Can be done with cron script
95
96 ## (GEN002700: CAT I) (Previously - G095) The SA will ensure audit data
97 ## files have permissions of 640, or more restrictive.
98 ##
99 ## Done automatically by auditd
100
101 ## (GEN002720-GEN002840: CAT II) (Previously - G100-G106) The SA will
102 ## configure the auditing system to audit the following events for all
103 ## users and root:
104 ##
105 ## - Logon (unsuccessful and successful) and logout (successful)
106 ##
107 ## Handled by pam, sshd, login, and gdm
108 ## Might also want to watch these files if needing extra information
109 -w /var/log/tallylog -p wa -k logins
110 -w /var/run/faillock/ -p wa -k logins
111 -w /var/log/lastlog -p wa -k logins
112 -w /var/log/faillog -p wa -k logins
113 -w /etc/login.defs -p wa -k logins
114
115 ##- Process and session initiation (unsuccessful and successful)
116 ##
117 ## The session initiation is audited by pam without any rules needed.
118 ## Might also want to watch this file if needing extra information
119 -w /var/run/utmp -p wa -k session
120 -w /var/log/btmp -p wa -k session
121 -w /var/log/wtmp -p wa -k session
122
123 ##- Discretionary access control permission modification (unsuccessful
124 ## and successful use of chown/chmod)
125 -a always,exit -F arch=b64 {{ S_chmod }} -S fchmod -S fchmodat {{ S_chown }} -S fchown -S fchownat {{ S_lchown }} -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S lremovexattr -S fremovexattr -k perm_mod
126 -a always,exit -F arch=b32 {{ S_chmod }} -S fchmod -S fchmodat {{ S_chown }} -S fchown -S fchownat {{ S_lchown }} -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S lremovexattr -S fremovexattr -k perm_mod
127
128 ##- Unauthorized access attempts to files (unsuccessful)
129 -a always,exit -F arch=b64 {{ S_creat }} {{ S_open }} -S openat -S open_by_handle_at -S truncate -S ftruncate -F exit=-EACCES -F key=access
130 -a always,exit -F arch=b32 {{ S_creat }} {{ S_open }} -S openat -S open_by_handle_at -S truncate -S ftruncate -F exit=-EACCES -F key=access
131 -a always,exit -F arch=b64 {{ S_creat }} {{ S_open }} -S openat -S open_by_handle_at -S truncate -S ftruncate -F exit=-EPERM -F key=access
132 -a always,exit -F arch=b32 {{ S_creat }} {{ S_open }} -S openat -S open_by_handle_at -S truncate -S ftruncate -F exit=-EPERM -F key=access
133
134 ##- Use of privileged commands (unsuccessful and successful)
135 ## use find /bin -type f -perm -04000 2>/dev/null and put all those files in a rule like this
136 #-a always,exit -F path=/bin/ping -F perm=x -F key=privileged
137
138 ##- Use of print command (unsuccessful and successful)
139
140 ##- Export to media (successful)
141 ## You have to mount media before using it. You must disable all automounting
142 ## so that its done manually in order to get the correct user requesting the
143 ## export
144 -a always,exit -F arch=b64 -S mount -k mounts
145 -a always,exit -F arch=b32 -S mount -k mounts
146
147 ##- System startup and shutdown (unsuccessful and successful)
148
149 ##- Files and programs deleted by the user (successful and unsuccessful)
150 -a always,exit -F arch=b64 {{ S_rmdir }} {{ S_unlink }} -S unlinkat {{ S_rename }} -S renameat -k delete
151 -a always,exit -F arch=b32 {{ S_rmdir }} {{ S_unlink }} -S unlinkat {{ S_rename }} -S renameat -k delete
152
153 ##- All system administration actions
154 ##- All security personnel actions
155 ##
156 ## Look for pam_tty_audit and add it to your login entry point's pam configs.
157 ## If that is not found, use sudo which should be patched to record its
158 ## commands to the audit system. Do not allow unrestricted root shells or
159 ## sudo cannot record the action.
160 -w /etc/sudoers -p wa -k actions
161 -w /etc/sudoers.d/ -p wa -k actions
162
163 ## (GEN002860: CAT II) (Previously - G674) The SA and/or IAO will
164 ##ensure old audit logs are closed and new audit logs are started daily.
165 ##
166 ## Site action. Can be assisted by a cron job