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

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