Kernel Hardening: Protect Linux user accounts against brute force attacks
github.com
github.com
Only root can kexec anyway. "Hardening" guidance that suggests limiting the root user feels like an attempt to boil the frog of widespread Linux DRM.
Closing those holes requires using a pretty extensive MAC policy restricting root in all sorts of ways.
Or do you mean that certain programs (like one mentioned by sibling) require the switch to be on?
Another way is simply for the manufacturer to lock down the bootloader/BIOS and not let you disable "secure" boot, as is also common in the Android world.
Disabling kexec still feels relevant though as part of a defense in depth approach to stop threat actors that aren't state sponsored (eg, metasploit folk)
Other tools like aide may help detect the event as well. Fapolicyd could also help this effort.
If they get root, you can't trust anything on the system any more. You have to do 10x the work just to get to the point of having a system you can even start to use. (Do you have a bootable install ISO handy anywhere? Is it current?)
I don’t have a current bootable ISO, but I have a bunch of old 8…16 Gb USB drives just for that. Also, there is Ventoy that makes it even easier. So making an installer is a trivial task these days. For me, it’s either downloading Arch Linux media, which is 400 MB or something. Or it’s downloading a Fedora installer, which is 3…4 Gb and takes minutes to do. If I go the Fedora way (which I would, if I need a working computer right away), it’ll take up to an hour to get back to work.
I understand that for an average user that could be a serious issue, but if that user is managed by someone competent, it’s really the non-issue. The only thing that needs to be done is a proper backup system for the data of that user.
Recently, I had a case with some distant friend whom I help with his computer. He needs just a ‘Word’ and a browser, so he uses Debian and LibreOffice. I haven’t paid him visits for years, so the Debian was 10 or even 9, while the current one is 12. He wanted to install something, and as the system was very obsolete, I insisted on updating it first. I did the proper way (from version to version), but at some point the installation just broke for no reason. I tried to fix it, but even the help of ChatGPT didn’t allow me to do the job quickly. So I just nuked everything on his ssd (his data was on a separate hdd), went all-in Fedora and went talking and drinking tea with him. I was surprised how easy the whole reinstatement was.
I’m talking Linux, which is very easy when you know what you do. But macOS or Windows not that difficult these days, when all you need to do is to reinstall. Again, considering the data is saved separately. Preferably beforehand.
Arch has some decent wiki entries for this:
- https://wiki.archlinux.org/title/migrate_installation_to_new...
- https://wiki.archlinux.org/title/Install_Arch_Linux_from_exi...
Although, my way of work is quite different. I do keep a lot of notes about what I do. And when I need to reinstall my system (e.g. to a new laptop), I reconsider what I need. My Arch Desktop systems are very minimalistic. I use Arch on my laptops and servers.
I use Fedora on my desktops, so it’s different from Arch. Usually, I don’t mess with Fedora, and treat it as I treat macOS. My way of working with Fedora or macOS is just to note what I need to change, in plain text with screenshots (when needed). As most of the changes are either in Settings app or just a couple of terminal strings.
Also, I keep all my custom configs in a git repository. Usually, that system is called dotfiles.
But overall that’s a great idea.
> For me, it’s either downloading Arch Linux media, which is 400 MB or something.
...that's fine, if you have a separate non-compromised computer handy to download the installer from. Which not everyone will.
...and, is the only software you use included in that default 400 MB base system? How much else do you have to install? Did you keep a list of the extra packages you used, or are you going to have to keep going back to `pacman -S ...` every 5 minutes for the first couple of hours as you run into that thing you use frequently suddenly not being there?
... and that includes the firmware of all components involved.
On RHEL this is done by default via SELinux.
If you define a policy that prevents anyone from doing kexec, and enable the boolean to prevent root from disabling enforcing mode for selinux, there you go, done with tools that have been available for ~15-20 years.
It's a great mechanism in theory, but the practice leaves much to be desired.
If you dumb it down too much it becomes useless. Simple tools usually get their simplicity by making some choices for you. You don't always want that.
SELinux is one of those things where you don't want that.
That being said, without diving too much, I have configured many custom services to run under SELinux by just running them in a dev/staging environment, collecting violations and creating policies via the audit2allow tool. So yeah, things have improved I guess.
Good documentation and good tools would encourage more people to use it and understand it willingly and effectively.
FWIW it does look like Gentoo stepped up and filled in the gaps since I last looked. Their Wiki has good docs starting from https://wiki.gentoo.org/wiki/SELinux.
That being said, it can be configured that way but (of course, duh) it’s not the default setting.
I’ll stop replying here because this branch of the discussion doesn’t seem to be any constructive on your side (or even conducted in good faith, to be honest)
There is no such line. Everything is foss software, you can change any policy.
You can still do everything you want.
We're fundamentally talking about building up pieces in a "chain of trust" which allows the entity in charge of the UEFI to decide what can and can't be done with the system. That's a scary thing.
That said there’s nothing stopping you from trying it. It just seems unlikely to succeed.
>Trying to guess what use-case everybody will have is a horrible tooth-pulling and bikesheding exercise that nobody would do for fun.
You seem to be misunderstanding what I am saying. People could still install new applications, or uninstall preexisting applications just like how it works now.
>Isn't that arguing for the iOS-ification of Linux?
Linux distros could learn a thing or two (or 100) from how iOS handles security.
Doesn't need to be fiddled with? Sure. Can't be fiddled with? No way.
> Hardware owners shouldn't have to be the ones fixing the operating system.
Ditto. Owners shouldn't have to fix it, but they should be able to.
> Most people just want their computer to work and don't want to learn about the internals of how it works.
Most people, sure. So don't make them learn. But don't prevent people from learning if they want to.
> If a user really cares about changing the internals he can make his own operating system.
Wouldn't this mean that incremental improvements wouldn't be possible anymore?
> Linux distros could learn a thing or two (or 100) from how iOS handles security.
How so specifically?
One can make a fork of the distro and then make the change you want to incrementally improve it.
>How so specifically?
Reading the documentation and reading information about its internals.
How is that better than what we have now, where a system can be easily modified in-place without every distro needing dozens of forks for each slight preference change?
What exactly is it you're advocating for?
Because most Linux distros have terrible security.
>How is that better than what we have now, where a system can be easily modified in-place without every distro needing dozens of forks for each slight preference change?
Preferences can be done via configuration. Most people do not actually want or need to modify the operating system.
>What exactly is it you're advocating for?
The root user to be effectively removed.
Sorry no, I don't want my Linux to become like iOS. iOS security model "all powers to the manufacturer" is broken model and doesn't work.
Don't we already have that, and it's called... Linux?
They do. That way is exposing files in /etc that the administrator account can edit.
Or, labeled differently, the root user is the administrator group.
If the solution is just "use sudo" then what's the difference compared to today's model?
That would be okay too, but not all suid usages can be replaced like that.
>And how would "su" and "sudo" work in your model?
They wouldn't exist in my model.
It doesn't mention `systemd-homed` which might be useful in some cases and the kernel module signing portion is just... wrong or misguided.
I wonder what percentage of applications break or have such slow performance that they become unusable, when this set of mitigations is enabled.
https://wiki.gentoo.org/wiki/Simple_sandbox#larry_runs_firef...
The browser is likely the biggest threat vector running on my machine, yet there are no easy ways to lock it down to just reading/writing Downloads and its own cache.
So if anything else can read the browser's data, it can get that.
Disclaimer: Critics say firejail is too complicated to be audited and adds too much attack surface of its own.
People have been hacked by malicious Minecraft mods uploading browser data to nefarious places.
Full disclaimer: my company develops it.