r/linux • u/Beneficial-Sock-5130 • 4d ago
Kernel Locking down unnecessary kernel mods
how do admins deal with the flood of ai-malware now thats loading custom mods?
I tried a tool called modulejail, it basically generates a blacklist of mods that arent actively used by running OS
https://modulejail.com/#install
its helpful, but any attacker can still bypass this by running modprobe -i
ie here, I ran mdulejail, it created blacklist txt file, running lsmod <mod> doesnt load it now, but running lsmod -i <mod> still loads
there is no concrete way to ban a module from loading short of running kernel.modules_disabled=1 , which doesnt survive a reboot
is there a way to block a mod from loading regardless of context? This is a huge attck vector now, and I wanted to audit our servers and lock down anything unecessary , like the copyfail exploit few months ago using alg mod

15
u/bendani3l 4d ago
What flood of ai-malware ?
27
u/abotelho-cbn 4d ago
If malware can load kernel modules, you're fucked regardless.
18
u/kcat__ 4d ago
Is this you just shilling for your ai product modulejail?
6
u/SurreptitiousSophist 4d ago
If you'd like to disable kennel module loading at every boot, just put modules_disabled=1 into your grub config file. Or am I missing something?
55
u/hitsujiTMO 4d ago
If an attacker can run " modprobe -i", you are already fucked to be honest.
4
u/[deleted] 4d ago
Don't run things as unrestricted root?
4
u/CardOk755 4d ago
Secure boot?
4
u/grnis 4d ago
Why not just remove the modules you don't need? Or build the kernel without them?
4
u/krav_mark 4d ago
Who or what is able to compile kernel modules on your systems and load them to begin with? Anything being able to do that will be able to circumvent whatever you put in place.
4
u/darth_chewbacca 4d ago
The kernel can be configured to only allow the loading of cryptographically signed modules
I forget precisely how it's done because the last time I cared about this was like 8 years ago, but hopefully I've given you a jumping off point to start googling.
4
u/natermer 4d ago
How you deal with this is by using secure boot and using signed kernel modules.
Then keeping your kernel up to date.
That way any security vulnerabilities in existing modules are fixed ASAP and attackers can't insert malicious code into the kernel that will survive a reboot.
That is about the best you can do right now and probably should be considered the bare baseline. If you don't get that done then any other mitigation you want to try to use are kinda pointless.
3
u/burner-miner 4d ago
The advice you are looking for is to not use the
rootuser. Don't have password-lesssudoprivileges anywhere, don't have too many processes running asroot, don't expose ports for services running asroot.DBs, web servers, whatever else should ideally run with their own users, anything that runs with
rootshould be trusted and up-to-date software.That way,
modprobe -i zramwill always fail withOperation not permittedfor any of those users. If someone gets hold of yourrootanyways, they will undo any possible protection you add asrootyourself.2
u/Luigi003 4d ago
You can put the kernel in lockdown mode if you have secure boot active, but if someone has root privileges kernel modules are probably the least of your worries
2
u/northrupthebandgeek 4d ago
So put it in a systemd unit. Something like
2
u/BaconCatBug 3d ago
Don't install random AI Malware modules?
1
u/aieidotch 4d ago
use /etc for sysctl to have it on after reboots?
also: https://github.com/a13xp0p0v/kernel-hardening-checker