Linux DE/WM Security: Which Option Is the Safest?

What’s the most secure desktop environment or window manager for Linux? Are window managers actually recommended from a security standpoint? If so, which one is the most secure? I’ve been using GNOME as my daily driver for over two years now and I’d like to try out a few window managers. I’m planning to test niri and sway - are they considered secure options?

I’m not an expert on this, don’t know many technical details about this. I only read a few bits and pieces about this, so take everything with a grain of salt.

Are window managers actually recommended from a security standpoint?

Every piece of software you install is a potential attack surface. So, of course it would be more secure to have no window manager at all, but then personally I wouldn’t call this a Linux desktop any longer.

What you probably mean is whether it makes sense to switch away from the distros default window manager (in your case GNOME) to another one, correct? And yes, it can potentially improve security.

First of all the biggest factor is the protocol: X11 vs Wayland. As far as I know, X11 itself is generally considered insecure as it has an outdated codebase and all windows can read keystrokes even when they are unfocussed/inactive. So all window managers for X11 are generally not recommended. In your case, the recent versions of GNOME are based on Wayland. But if you haven’t updated your system for a while, you might still have a version of it installed that uses X11. You can check which protocol you are using with echo $XDG_SESSION_TYPE . All the other window managers you used are also using wayland.

In terms of security, as far as I am aware, all three are considered safe and have a good track record. Here are some things to keep in mind:

GNOME is really popular and well tested, however it also ships with a lot of additional software (=increased attack surface) and internet-integrations out of the box.

Sway is also around for a long time, well tested and it is included in some security focussed distros. Since its rather minimal it has a much smaller attack surface.

Niri is relatively new and probably not that thoroughly tested as the other two, but that doesn’t inherently make it insecure. In fact, since it is also rather minimal it also has a smaller attack surface. Also, it uses Rust instead of C/C++ (which GNOME and Sway use) which already eliminates a whole classes of vulnerabilities.

I am not sure if there exists a window manager that is considered to be the most secure, but I would consider all options you mentioned quite secure (given that GNOME uses wayland). However, since they are more minimal I would say Sway and Niri are slightly less risky. Do note, however, that if you want to rice your window manager or use something like noctalia-shell or dankmaterialshell, you might install software from yet another party you need to trust and potentially is not as secure or include internet integrations.

Honestly, I agree with @sizing387 mostly, but Gnome and KDE’s compositor probably has more eyes on it than sway’s or niri’s. What I do is I do a really minimal install of Gnome (KDE would also work, I just like gnome better), with only the settings and the WM itself, and I install the rest (the video player, web browser, etc).

This gets all the benefits of having more eyes on your software, while also removing the bloat that comes with KDE and Gnome, and makes it easier to use more secure options, like vlc instead of totem.

Unless you are wanted by the government or are installing possibly malicious files (which you should just be using QubesOS for either), the most important important thing is using Wayland instead of X11. You’re fine, probably!

GNOME or Sway:

After 20+ years with GNOME, I now use:

Written in RUST.

I use a Fedora Atomic spin with Cosmic Desktop:

Unless you are wanted by the government or are installing possibly malicious files (which you should just be using QubesOS for either), the most important important thing is using Wayland instead of X11. You’re fine, probably!

But Qubes ships with XFCE. Not Wayland.

From Privacy Guides’ Desktop/PC criteria:

  • Avoids X11, as its last major release was more than a decade ago.
    • The notable exception here is Qubes, but the isolation issues which X11 typically has are avoided by virtualization. This isolation only applies to apps running in different qubes (virtual machines); apps running in the same qube are not protected from each other.

Not that it’ll make a huge difference for their security but I believe QubesOS is working on Wayland support so we may see that in the future.