6.3.3.7 Ensure events that modify /etc/hosts and /etc/hostname are collected

Information

Record changes to network environment files or system calls. The files being monitored are:

- /etc/hosts - file containing host names and associated IP addresses
- /etc/hostname - file contains the system's host name

The /etc/hosts file is monitored for changes that can indicate an unauthorized intruder is trying to change machine associations with IP addresses and trick users and processes into connecting to unintended machines.

Solution

Note:

- The -w option is deprecated and the rule should be updated in accordance with the Remediation Procedure.
- For best performance, the arch field should be supplied in the rule. The individual permissions will cause the selection of specific system calls that use that kind of access. Not supplying the arch will cause the selection of all system calls which will affect performance as all system calls will be evaluated.

- Edit or create a file in the /etc/audit/rules.d/ directory, ending inrules extension, with the relevant rules to monitor events that modify the system's network environment.

Example :

# printf "
-a always,exit -F arch=b64 -S all -F path=/etc/hosts -F perm=wa -F key=system-locale
-a always,exit -F arch=b64 -S all -F path=/etc/hostname -F perm=wa -F key=system-locale
" >> /etc/audit/rules.d/50-etc_host_system_locale.rules <xhtml:ol start="2"> - Merge and load the rules into active configuration:

# augenrules --load <xhtml:ol start="3"> - Check if reboot is required:

# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot required to load rules\n"; fi

See Also

https://workbench.cisecurity.org/benchmarks/24008