Skip to content

CVE-2021-21261: Flatpak sandbox escape via spawn portal

High
alexlarsson published GHSA-4ppf-fxf6-vxg2 Jan 14, 2021

Package

Flatpak (freedesktop.org)

Affected versions

>= 0.11.4 and < 1.10.0, except for 1.8.x >= 1.8.5

Patched versions

All >= 1.10.0, 1.8.x >= 1.8.5

Description

Simon McVittie discovered a bug in the flatpak-portal service that can allow sandboxed applications to execute arbitrary code on the host system (a sandbox escape).

The Flatpak portal D-Bus service (flatpak-portal, also known by its D-Bus service name org.freedesktop.portal.Flatpak) allows apps in a Flatpak sandbox to launch their own subprocesses in a new sandbox instance, either with the same security settings as the caller or with
more restrictive security settings. For example, this is used in Flatpak-packaged web browsers such as Chromium to launch subprocesses
that will process untrusted web content, and give those subprocesses a more restrictive sandbox than the browser itself.

In vulnerable versions, the Flatpak portal service passes caller-specified environment variables to non-sandboxed processes on the host system, and in particular to the flatpak run command that is used to launch the new sandbox instance. A malicious or compromised Flatpak app could set environment variables that are trusted by the flatpak run command, and use them to execute arbitrary code that is not in a sandbox.

Workaround

This vulnerability can be mitigated by preventing the flatpak-portal service from starting, but that mitigation will prevent many Flatpak apps from working correctly.

Fixes

This is fixed in Flatpak 1.10.0 and 1.8.5 (commits 6d1773d, 6e5ae7a, aeb6a7a, cc14010, with automated test coverage added in
8212498, 39a5621, d19f6c3).

The initial fixes introduced a regression (#4080) for users of a setuid version of bubblewrap (bwrap). This is fixed in 1.10.1 (commits 9a61d2c and fb473ca, also backported to the flatpak-1.8.x branch).

Out of scope

The flatpak-session-helper service (org.freedesktop.Flatpak, as accessed by flatpak-spawn --host) is intended to give specially-flagged apps the ability to run arbitrary code on the host system, so it is not a vulnerability that it also trusts the environment variables it is given. Granting access to the org.freedesktop.Flatpak service indicates that an app is trusted and can legitimately execute arbitrary code outside the sandbox. For example, the GNOME Builder integrated development environment is flagged as trusted in this way.

Severity

High

CVE ID

CVE-2021-21261

Weaknesses

No CWEs

Credits