r/linux • • 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

0 Upvotes

42 comments sorted by

15

u/bendani3l 4d ago

What flood of ai-malware ?

-14

u/Beneficial-Sock-5130 4d ago

severl examples

VoidLink: Discovered in late 2025 and attributed to a Chinese-affiliated actor using AI models and coding agents (such as TRAE SOLO) to build the framework rapidly. It performs host reconnaissance first, then has its C2 server compile and return a custom kernel module tailored to the target's kernel and security setup.

Koske: A 2025 Linux cryptomining campaign showing signs of LLM-assisted modular code and adaptive logic. It uses startup script persistence (insmod in /etc/rc.local and related scripts) and disguises kernel object files under legitimate-sounding names like intel_audio.ko.

sysinitd.ko (Ivanti compromise, Fortinet analysis): a rootkit installed by shell script after compromise. The module hooks Netfilter at PRE_ROUTING to hijack inbound TCP traffic, and persistence comes from entries in rc.loca

Reused open-source rootkits: Diamorphine and Reptile are public loadable-kernel-module rootkits that attackers widely reuse. TeamTNT used Diamorphine to hide cryptomining, and Winnti (APT41) used adore-ng and suterusu

CopyFail

-4

u/Beneficial-Sock-5130 4d ago

who the fck is downvoting examples of mod loading malware? lmaoo

jfc...

27

u/abotelho-cbn 4d ago

If malware can load kernel modules, you're fucked regardless.

-16

u/Beneficial-Sock-5130 4d ago

thats the entire point of this thread, i want to block loading any mods outside of a whitelist

32

u/kido5217 4d ago

You don't get it. If malware has enough privilege to load modules, you're already fucked. End of story.

17

u/zapman449 4d ago

The point people are making is, effectively if the attacker has ability to inject kernel mods, they already have root privs... so they can undo most any protection you setup here.

The real value is blocking an attacker from getting the privs they want in the first place.

11

u/Alternative_Web7202 4d ago

It's too late when something is able to load module.

8

u/ersentenza 4d ago

If a malware has the privilege to load modules it also has the privilege to disable your block and load whatever it wants.

4

u/hackingdreams 4d ago

You're missing the point. If they have local root, it doesn't matter. They already own the box.

You can compile a kernel without module loading support, only building in the modules you want... but why bother? You're worrying about the wrong attack surface. You need to stop the attack before it gets root, not after.

18

u/kcat__ 4d ago

Is this you just shilling for your ai product modulejail?

-8

u/Beneficial-Sock-5130 4d ago

also how can i be 'shiling' for it when it clearly doesnt work in the screenshot lmao

-7

u/Beneficial-Sock-5130 4d ago

its not my project, i found it on linkedin convo re module loading malware, its made by another developer

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? 

-1

u/Beneficial-Sock-5130 4d ago

its a runtime setting /proc/sys/kernel/modules_disabled , doesnt do anything if placed into grub

7

u/alpha417 4d ago

If they have access to your system, to the point where they can get into grub, you're f***** anyway.

something something deckchairs on the titanic something something...

55

u/hitsujiTMO 4d ago

If an attacker can run " modprobe -i", you are already fucked to be honest.

1

u/Netblock 3d ago

Eh, while gaining access to root is very bad, there is a divorce between root and kernel in a trusted boot (eg, lockdown, IMA). For example, with a divorce, an encrypted VM remains unleaked.

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?

3

u/burner-miner 4d ago

modprobe is for loading modules not built into the kernel AFAIK. The kernel is already built without them

3

u/gmes78 4d ago

modprobe is not only for out-of-tree modules, if that's what you mean.

1

u/grnis 4d ago

No, that's not what I meant.

Can you remove the modules you don't use? Can you disable them in your kernel Config so they don't build?

1

u/gmes78 4d ago

Can you remove the modules you don't use?

You can just delete the files in /usr/lib/modules/, or tell your package manager not to install them.

Can you disable them in your kernel Config so they don't build?

Yes, that's 90% of what the kernel config is for.

-1

u/grnis 4d ago

Good. Now you understand what I suggested.

2

u/gmes78 4d ago

???

1

u/grnis 4d ago

My original reply was "Why not just remove the modules you don't need? Or build the kernel without them?"

Then you answered and didn't seem to understand what I meant.

You can remove the modules or build the kernels without the modules the OP doesn't need.

What exactly is it that is unclear for you?

1

u/gmes78 4d ago

No. I replied to your second comment, which was an incorrect description of modprobe.

I did understand your first message perfectly fine. That's not what I replied to.

1

u/grnis 4d ago

Jesus christ... Sorry I mistook you for the guy I replied to :)

→ More replies

1

u/grnis 4d ago

I'm sure you understood what I meant.

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 root user. Don't have password-less sudo privileges anywhere, don't have too many processes running as root, don't expose ports for services running as root.

DBs, web servers, whatever else should ideally run with their own users, anything that runs with root should be trusted and up-to-date software.

That way, modprobe -i zram will always fail with Operation not permitted for any of those users. If someone gets hold of your root anyways, they will undo any possible protection you add as root yourself.

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

short of running kernel.modules_disabled=1, which doesn't survive a reboot

So put it in a systemd unit. Something like

[Unit]
Description=Disable kernel module loading

[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo 1 > /proc/sys/kernel/modules_disabled"

[Install]
WantedBy=multi-user.target

2

u/BaconCatBug 3d ago

how do admins deal with the flood of ai-malware now thats loading custom mods?

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