Blame SOURCES/flatpak-1.8.5-post-cve-fixes.patch

d3f705
From 93ecea3488081a726bcd2ddb04d557decaa87f80 Mon Sep 17 00:00:00 2001
d3f705
From: Simon McVittie <smcv@collabora.com>
d3f705
Date: Mon, 18 Jan 2021 17:52:13 +0000
d3f705
Subject: [PATCH] build: Convert environment into a sequence of bwrap arguments
d3f705
d3f705
This means we can systematically pass the environment variables
d3f705
through bwrap(1), even if it is setuid and thus is filtering out
d3f705
security-sensitive environment variables. bwrap itself ends up being
d3f705
run with an empty environment instead.
d3f705
d3f705
This fixes a regression when CVE-2021-21261 was fixed: before the
d3f705
CVE fixes, LD_LIBRARY_PATH would have been passed through like this
d3f705
and appeared in the `flatpak build` shell, but during the CVE fixes,
d3f705
the special case that protected LD_LIBRARY_PATH was removed in favour
d3f705
of the more general flatpak_bwrap_envp_to_args(). That reasoning only
d3f705
works if we use flatpak_bwrap_envp_to_args(), consistently, everywhere
d3f705
that we run the potentially-setuid bwrap.
d3f705
d3f705
Fixes: 6d1773d2 "run: Convert all environment variables into bwrap arguments"
d3f705
Resolves: https://github.com/flatpak/flatpak/issues/4080
d3f705
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980323
d3f705
Signed-off-by: Simon McVittie <smcv@collabora.com>
d3f705
(cherry picked from commit 9a61d2c44f0a58cebcb9b2787ae88db07ca68bb0)
d3f705
---
d3f705
 app/flatpak-builtins-build.c | 2 ++
d3f705
 1 file changed, 2 insertions(+)
d3f705
d3f705
diff --git a/app/flatpak-builtins-build.c b/app/flatpak-builtins-build.c
d3f705
index 8da0de814..07ef6fc07 100644
d3f705
--- a/app/flatpak-builtins-build.c
d3f705
+++ b/app/flatpak-builtins-build.c
d3f705
@@ -569,6 +569,8 @@ flatpak_builtin_build (int argc, char **argv, GCancellable *cancellable, GError
d3f705
                               NULL);
d3f705
     }
d3f705
 
d3f705
+  flatpak_bwrap_envp_to_args (bwrap);
d3f705
+
d3f705
   if (!flatpak_bwrap_bundle_args (bwrap, 1, -1, FALSE, error))
d3f705
     return FALSE;
d3f705
 
d3f705
From f91857c07ede7ef5150a38d6b8e49ee43d6b3d50 Mon Sep 17 00:00:00 2001
d3f705
From: Simon McVittie <smcv@collabora.com>
d3f705
Date: Mon, 18 Jan 2021 18:07:38 +0000
d3f705
Subject: [PATCH] dir: Pass environment via bwrap --setenv when running
d3f705
 apply_extra
d3f705
d3f705
This means we can systematically pass the environment variables
d3f705
through bwrap(1), even if it is setuid and thus is filtering out
d3f705
security-sensitive environment variables. bwrap ends up being
d3f705
run with an empty environment instead.
d3f705
d3f705
As with the previous commit, this regressed while fixing CVE-2021-21261.
d3f705
d3f705
Fixes: 6d1773d2 "run: Convert all environment variables into bwrap arguments"
d3f705
Signed-off-by: Simon McVittie <smcv@collabora.com>
d3f705
(cherry picked from commit fb473cad801c6b61706353256cab32330557374a)
d3f705
---
d3f705
 common/flatpak-dir.c | 2 ++
d3f705
 1 file changed, 2 insertions(+)
d3f705
d3f705
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
d3f705
index ed1248e74..40767fa77 100644
d3f705
--- a/common/flatpak-dir.c
d3f705
+++ b/common/flatpak-dir.c
d3f705
@@ -7426,6 +7426,8 @@ apply_extra_data (FlatpakDir   *self,
d3f705
                                          app_context, NULL, NULL, NULL, cancellable, error))
d3f705
     return FALSE;
d3f705
 
d3f705
+  flatpak_bwrap_envp_to_args (bwrap);
d3f705
+
d3f705
   flatpak_bwrap_add_arg (bwrap, "/app/bin/apply_extra");
d3f705
 
d3f705
   flatpak_bwrap_finish (bwrap);