6.2.3.31 Ensure kernel module loading unloading and modification is collected

Information

Monitor the loading and unloading of kernel modules. All the loading / listing / dependency checking of modules is done by kmod via symbolic links.

Monitoring the use of all the various ways to manipulate kernel modules could provide system administrators with evidence that an unauthorized change was made to a kernel module, possibly compromising the security of the system.

Solution

- Add the audit rule(s) that monitor use of the /usr/bin/kmod command. The procedure adds each rule only for targets that exist, so augenrules --load does not error. Run:

#!/usr/bin/env bash

{
UID_MIN="$(awk '/^[[:space:]]*UID_MIN/{print $2}' /etc/login.defs)"
[ -e /usr/bin/kmod ] && printf '%s\n' "-a always,exit -S all -F path=/usr/bin/kmod -F perm=x -F auid>=$UID_MIN -F auid!=unset -k kernel_modules"
} >> /etc/audit/rules.d/50-kernel_modules.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

See Also

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