-
Notifications
You must be signed in to change notification settings - Fork 522
User namespace requirements
Flatpak uses bubblewrap (bwrap) to set up its sandbox environment. Depending on how Flatpak was configured for your operating system, it can either use a system copy of the bubblewrap executable (usually /usr/bin/bwrap), or its own included copy of bubblewrap (usually /usr/libexec/flatpak-bwrap).
There are two ways this can work.
This is the preferred mode for modern operating systems. The kernel must allow unprivileged users to create new user namespaces.
This mode is available in most recent operating systems in their default configuration, including:
- all recent versions of Ubuntu, Fedora, etc.
- Debian version 11 or newer, in its default configuration
- Red Hat Enterprise Linux version 8 or newer, in its default configuration
- Arch Linux with the default
linuxkernel and thebubblewrappackage
If you are designing an operating system or tuning system parameters, the requirements for this mode are:
- The
bwraporflatpak-bwrapexecutable must not be setuid root: its permissions should usually be-rwxr-xr-x(0755). - The kernel must have at least
CONFIG_USER_NS=yenabled. Other namespace features likeCONFIG_PID_NS=yare recommended. - sysctl parameters that limit namespace creation, such as
user.max_user_namespacesanduser.max_mnt_namespaces(/proc/sys/user/max_user_namespacesand so on) must be set to a sufficiently large value. The default value is usually suitable: it depends on available RAM and is usually in the tens of thousands. - If the kernel has been patched to add a
kernel.unprivileged_userns_clonesysctl (/proc/sys/kernel/unprivileged_userns_clone), then that option must be set to 1.
This mode is a fallback for older operating systems where the kernel either does not support user namespaces, or has been configured to disallow their use by unprivileged users.
This mode is not recommended, and some Flatpak apps and features will not work. In particular, this affects anything that needs flatpak-spawn --share-pids or flatpak-spawn --expose-pids, including Chromium and Steam. We expect that increasingly many Flatpak apps will require unprivileged bubblewrap in future.
Only a few operating systems are known to need this:
- Debian version 10 or older (including Debian derivatives like SteamOS 2, but not Ubuntu)
- Red Hat Enterprise Linux (RHEL) version 7 or older
- Arch Linux with the non-default
linux-hardenedkernel in its default configuration
This is a security trade-off. Disallowing unprivileged use of user namespaces reduces the kernel's attack surface, which mitigates some attacks; but it also disallows some sandboxing techniques, which prevents other attacks from being mitigated. Making bwrap or flatpak-bwrap setuid root also carries some risk: an attacker might be able to exploit vulnerabilities in bwrap to achieve root privilege escalation.
To use this mode, the bwrap or flatpak-bwrap executable must be setuid root. Its permissions should usually be -rwsr-xr-x (04755), owned by root:root. On Arch Linux and its derivatives, installing the bubblewrap-suid package provides this.
If you are using an operating system where bwrap is setuid by default, it is possible to reconfigure it to use the recommended unprivileged mode instead:
echo kernel.unprivileged_userns_clone=1 | sudo tee /etc/sysctl.d/50-bubblewrap.confsudo sysctl -w kernel.unprivileged_userns_clone=1- Make the
bwrapexecutable non-setuid:- If you are using a Debian-based system:
sudo dpkg-statoverride --update --add root root 0755 /usr/bin/bwrap - If you are using an Arch Linux-based system: install the
bubblewrappackage instead ofbubblewrap-suid - If you are using Gentoo: disable the
suidUSE flag for thebubblewrappackage - Otherwise:
sudo chmod u-s /usr/bin/bwrap(you will need to repeat this every time you upgradebubblewrap)
- If you are using a Debian-based system:
-
systemctl --user restart flatpak-portal.service, or log out and back in
Visit flatpak.org for information on getting started, developer documentation and details of available applications and runtimes.
Information for Developers
Information for Distributors
Technical Details
Flatpak Build Service
Miscellaneous