Information
Monitor SELinux, an implementation of mandatory access controls. The parameters below monitor any write access (potential additional, deletion or modification of files in the directory) or attribute changes to the /etc/selinux/, /usr/share/selinux/, and /var/lib/selinux/ directories.
Note: If a different Mandatory Access Control method is used, changes to the corresponding directories should be audited.
Changes to files in the /etc/selinux/, /usr/share/selinux/, and /var/lib/selinux/ directories could indicate that an unauthorized user is attempting to modify access controls and change security contexts, leading to a compromise of the system.
Solution
- Add the audit rule(s) that monitor changes to /etc/selinux, /usr/share/selinux, and /var/lib/selinux . The procedure adds each rule only for targets that exist, so augenrules --load does not error. Run:
#!/usr/bin/env bash
{
[ -e /etc/selinux ] && printf '%s\n' "-a always,exit -S all -F path=/etc/selinux -F perm=wa -F key=MAC-policy"
[ -e /usr/share/selinux ] && printf '%s\n' "-a always,exit -S all -F path=/usr/share/selinux -F perm=wa -F key=MAC-policy"
[ -e /var/lib/selinux ] && printf '%s\n' "-a always,exit -S all -F path=/var/lib/selinux -F perm=wa -F key=MAC-policy"
} >> /etc/audit/rules.d/50-MAC-policy.rules
- Merge and load the rules into active configuration:
# augenrules --load
- Check if reboot is required:
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot required to load rules\n"; fi