Blame SOURCES/flatpak-1.0.2-CVE-2019-5736.patch

55c332
From 86d9d711bdaada5677166a99b96b769df2c5e7b6 Mon Sep 17 00:00:00 2001
55c332
From: Alexander Larsson <alexl@redhat.com>
55c332
Date: Sun, 10 Feb 2019 18:23:44 +0100
55c332
Subject: [PATCH] Don't expose /proc when running apply_extra
55c332
55c332
As shown by CVE-2019-5736, it is sometimes possible for the sandbox
55c332
app to access outside files using /proc/self/exe. This is not
55c332
typically an issue for flatpak as the sandbox runs as the user which
55c332
has no permissions to e.g. modify the host files.
55c332
55c332
However, when installing apps using extra-data into the system repo
55c332
we *do* actually run a sandbox as root. So, in this case we disable mounting
55c332
/proc in the sandbox, which will neuter attacks like this.
55c332
---
55c332
 common/flatpak-common-types-private.h | 1 +
55c332
 common/flatpak-dir.c                  | 2 +-
55c332
 common/flatpak-run.c                  | 6 +++++-
55c332
 3 files changed, 7 insertions(+), 2 deletions(-)
55c332
55c332
diff --git a/common/flatpak-common-types-private.h b/common/flatpak-common-types-private.h
55c332
index 8c40d2e8..1e94bd1c 100644
55c332
--- a/common/flatpak-common-types-private.h
55c332
+++ b/common/flatpak-common-types-private.h
55c332
@@ -44,6 +44,7 @@ typedef enum {
55c332
   FLATPAK_RUN_FLAG_SANDBOX            = (1 << 14),
55c332
   FLATPAK_RUN_FLAG_NO_DOCUMENTS_PORTAL = (1 << 15),
55c332
   FLATPAK_RUN_FLAG_BLUETOOTH          = (1 << 16),
55c332
+  FLATPAK_RUN_FLAG_NO_PROC            = (1 << 19),
55c332
 } FlatpakRunFlags;
55c332
 
55c332
 typedef struct FlatpakDir          FlatpakDir;
55c332
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
55c332
index eb69225d..be370d49 100644
55c332
--- a/common/flatpak-dir.c
55c332
+++ b/common/flatpak-dir.c
55c332
@@ -6509,7 +6509,7 @@ apply_extra_data (FlatpakDir   *self,
55c332
                           NULL);
55c332
 
55c332
   if (!flatpak_run_setup_base_argv (bwrap, runtime_files, NULL, runtime_ref_parts[2],
55c332
-                                    FLATPAK_RUN_FLAG_NO_SESSION_HELPER,
55c332
+                                    FLATPAK_RUN_FLAG_NO_SESSION_HELPER | FLATPAK_RUN_FLAG_NO_PROC,
55c332
                                     error))
55c332
     return FALSE;
55c332
 
55c332
diff --git a/common/flatpak-run.c b/common/flatpak-run.c
55c332
index 6ab466af..b4f2c475 100644
55c332
--- a/common/flatpak-run.c
55c332
+++ b/common/flatpak-run.c
55c332
@@ -2347,9 +2347,13 @@ flatpak_run_setup_base_argv (FlatpakBwrap   *bwrap,
55c332
     "# Disable user pkcs11 config, because the host modules don't work in the runtime\n"
55c332
     "user-config: none\n";
55c332
 
55c332
+  if ((flags & FLATPAK_RUN_FLAG_NO_PROC) == 0)
55c332
+    flatpak_bwrap_add_args (bwrap,
55c332
+                            "--proc", "/proc",
55c332
+                            NULL);
55c332
+
55c332
   flatpak_bwrap_add_args (bwrap,
55c332
                           "--unshare-pid",
55c332
-                          "--proc", "/proc",
55c332
                           "--dir", "/tmp",
55c332
                           "--dir", "/var/tmp",
55c332
                           "--dir", "/run/host",
55c332
-- 
55c332
2.20.1
55c332