Flatpak Permissions: Auditing Sandboxes with Flatseal

AI-generated

Flatpak applications are sandboxed by default, but the actual permissions can still be quite broad. I regularly audit Flatpak permissions on my Arch laptop and Gentoo desktop, especially filesystem and session-bus access.

Flatpak is a good compromise for desktop applications I do not fully trust or do not want to install directly on my system. The sandbox is only useful though if an application does not get access to all of my home directory, devices and desktop services.

Checking installed Flatpak applications

First I check which Flatpak applications are installed. This also shows whether an app comes from a user or system installation.

$ flatpak list --app --columns=application,name,installation
Application ID                              Name                 Installation
com.github.tchx84.Flatseal                  Flatseal             user
org.mozilla.firefox                         Firefox              system
com.valvesoftware.Steam                     Steam                system

Flatpak manifests define the default permissions provided by the application maintainer. Local overrides are listed separately, which is important when debugging something later.

$ flatpak info --show-permissions org.mozilla.firefox
[Context]
shared=network;ipc;
sockets=x11;wayland;fallback-x11;pulseaudio;
devices=dri;
filesystems=xdg-download:ro;

[Session Bus Policy]
org.freedesktop.Notifications=talk
org.freedesktop.portal.Desktop=talk

The output is usually enough for a first check. shared=network means that the application can use the network. Most browsers, mail clients and communication tools naturally need this. A local image viewer or text editor normally does not.

Filesystem entries deserve a closer look. Access to home, host, or broad paths such as ~/Documents can make the Flatpak sandbox much less useful.

A Flatpak sandbox is not a replacement for good backups. I still keep my important data outside of a single desktop machine and use immutable backup storage where possible. My Restic Backups to Backblaze B2 with Object Lock setup is one part of this.

Auditing permissions with Flatseal

Flatseal is the easiest way I found to inspect and change per-app Flatpak permissions. It presents the same settings which can be configured with flatpak override, but is much nicer for an occasional audit.

I install it from Flathub:

$ flatpak install flathub com.github.tchx84.Flatseal

After opening Flatseal, I select an application in the sidebar. It shows both the original permissions and my local overrides. I mostly look at these sections:

  • Filesystem
  • Devices
  • Socket
  • Session Bus
  • System Bus
  • Environment

I do not blindly disable everything. Some permissions are expected, and removing them just creates hard to debug problems.

Filesystem access

Filesystem access is the permission I change most often. An application which only opens files selected through the file chooser usually does not need permanent access to my whole home directory.

The Flatpak document portal can give an application access to a selected file or folder without exposing everything else. This is why I prefer using the file chooser in sandboxed applications instead of granting home access.

For example, I would remove broad home access from a PDF reader, image viewer or simple editor if it works with the document portal. In Flatseal this is just disabling the relevant filesystem entry.

On the command line, I can deny a filesystem permission with an override:

$ flatpak override --user --nofilesystem=home org.example.Application

A more useful middle ground can be read-only access to a specific folder:

$ flatpak override --user --filesystem=xdg-download:ro org.example.Application

I try to avoid permanent access to paths containing SSH keys, browser profiles, GPG material or source repositories. For SSH in particular, I prefer hardware-backed keys and scoped access. I wrote about my setup in Phishing-Resistant SSH on Linux with a YubiKey and FIDO2.

Be careful with paths mounted below your home directory. Denying home does not automatically mean that another explicitly granted path is gone.

Devices and GPU access

dri device access is common for browsers, video players and Electron applications. It allows GPU acceleration through the Direct Rendering Infrastructure. I normally keep it enabled for applications where hardware rendering matters.

For a small utility which does not render video or graphics heavily, I may disable device access. This can also be useful when I want to check if an application actually needs GPU access or just requests it by default.

Do not disable dri for Steam or a Flatpak game and expect it to remain usable. Gaming applications also often need input device access, controller support and additional filesystem paths. This is one of the cases where a stricter sandbox can be more annoying than useful.

Sockets and desktop integration

Wayland, X11, PulseAudio and PipeWire sockets are normal desktop integration permissions. On my sway setup I prefer Wayland-native applications where possible.

Removing X11 access can be a reasonable test for an application that should run natively on Wayland. If it starts without X11, it has one less legacy display protocol available. But a lot of applications still use XWayland, plugins can depend on it, and some screen-sharing workflows need special handling.

For audio applications I usually leave the PipeWire or PulseAudio socket enabled. Per-app routing is a separate topic anyway, and I use WirePlumber rules for that. My PipeWire persistent per-app audio routing setup does not require giving an application filesystem access.

Session bus access is worth checking

Session-bus policies look a bit scary in Flatseal, but many are needed for normal desktop behaviour. org.freedesktop.portal.Desktop is important for portals such as file choosers, screenshots and opening URIs. I leave that one alone.

I pay more attention to application-specific bus names. If a random desktop application can talk to another sensitive desktop service, I check whether this is really needed. Browser integration extensions, password managers and desktop helpers sometimes require bus access, but this should be a conscious decision.

I do not disable random session-bus entries just because their names are unfamiliar. First I test the application, then remove one permission, and test again. Flatseal makes this quite manageable.

Reverting a broken override

The most common pitfall is forgetting that I changed an override weeks ago. Then an application update appears to be broken, while the actual issue is my own restricted permission.

To show local overrides, I use:

$ flatpak override --user --show org.example.Application

Flatseal also highlights changed entries, which is often faster.

If I want to remove all user overrides for one application and return to its packaged defaults, I run:

$ flatpak override --user --reset org.example.Application

For system-wide overrides created as root, the command needs to be run without --user:

# flatpak override --reset org.example.Application

I restart the application completely after changing permissions. Closing its window is not always enough, as background processes can remain active.

Flatseal is not something I need every day, but it is one of the first tools I install on a new Linux desktop. A few minutes spent checking broad filesystem and device permissions is imho worth it. If you know a better way to audit Flatpak sandboxes, let me know.