Loadable Kernel Module Loaded via Unusual Parent
Description
This rule monitors for the loading of kernel modules by unusual parent processes. Loadable kernel modules (LKMs) are pieces of code that can be loaded into the kernel at runtime to extend its functionality. These are commonly abused by rootkits or other malicious software to hide their presence or to gain elevated privileges. These LKMs are commonly loaded through expected parent processes.
Query · eql
process where event.type == "start" and event.action == "load_module" and (
process.parent.executable like (
"/tmp/*", "/var/tmp/*", "/dev/shm/*", "./*", "/run/*", "/var/run/*", "/boot/*", "/sys/*", "/lost+found/*",
"/proc/*", "/var/mail/*", "/var/www/*", "/home/*", "/root/*"
) or
process.parent.name like~ (
// Hidden processes
".*",
// Suspicious file formats
"*.elf", "*.sh", "*.py", "*.rb", "*.pl", "*.lua*", "*.php*", "*.js",
// Scheduled tasks
"cron", "crond"
) or
(
process.parent.name like ("python*", "perl*", "ruby*", "lua*", "php*", "node", "java") and
not (
(
process.executable == "/usr/bin/kmod" and
process.args in ("/sbin/modprobe", "modprobe", "/usr/bin/modprobe", "/usr/sbin/modprobe") and
process.args_count <= 2
) or
process.executable == "/sbin/iscsiadm"
)
)
) and
not (
process.parent.command_line in (
"/usr/bin/python3 -m kcarectl.__main__ --smart-update",
"/usr/bin/python3 -m kcarectl.__main__ -q --auto-update",
"/usr/bin/perl /usr/sbin/csf -r",
"pvestatd",
"/usr/bin/python3 -sP /usr/bin/firewalld --nofork --nopid",
"/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid",
"/usr/bin/python3 -sP /usr/sbin/firewalld --nofork --nopid",
"/usr/bin/python3 -m kcarectl.__main__ --unload",
"python2 /usr/bin/kcarectl -q --auto-update"
) or
process.parent.args in ("/usr/share/ksplice/ksplice-apply", "/usr/bin/waydroid", "/usr/sbin/blksnap-loader") or
process.parent.args like "/home/*/.ansible/tmp/ansible-tmp-*/AnsiballZ_command.py" or
process.args == "ip6_tables" or
(process.name == "systemd" and process.parent.name == "runc" and process.parent.command_line == "runc init") or
(
process.parent.executable like "/usr/bin/python*" and
process.command_line in ("/usr/sbin/modprobe br_netfilter", "/usr/sbin/modprobe overlay")
) or
process.parent.executable like (
"/run/containerd/io.containerd.runtime.v2.task/k8s.io/*", "./runc", "/opt/puppetlabs/puppet/bin/ruby",
"/home/*/work/check-hardware/coco-detect/target/debug/coco-detect"
)
)