Blame SOURCES/flatpak-1.8.5-fix-CVE-2021-21381.patch

496c31
From cb6fce9e4122ace2960c437def3b1a197bb49b3a Mon Sep 17 00:00:00 2001
496c31
From: Ryan Gonzalez <rymg19@gmail.com>
496c31
Date: Tue, 2 Mar 2021 13:20:07 -0600
496c31
Subject: [PATCH 1/3] Disallow @@ and @@u usage in desktop files
496c31
496c31
Fixes #4146.
496c31
---
496c31
 common/flatpak-dir.c | 2 ++
496c31
 1 file changed, 2 insertions(+)
496c31
496c31
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
496c31
index e6e4d6fb3..7d3374dad 100644
496c31
--- a/common/flatpak-dir.c
496c31
+++ b/common/flatpak-dir.c
496c31
@@ -7139,6 +7139,8 @@ export_desktop_file (const char         *app,
496c31
                 g_string_append_printf (new_exec, " @@ %s @@", arg);
496c31
               else if (strcasecmp (arg, "%u") == 0)
496c31
                 g_string_append_printf (new_exec, " @@u %s @@", arg);
496c31
+              else if (strcmp (arg, "@@") == 0 || strcmp (arg, "@@u") == 0)
496c31
+                g_print (_("Skipping invalid Exec argument %s\n"), arg);
496c31
               else
496c31
                 g_string_append_printf (new_exec, " %s", arg);
496c31
             }
496c31
496c31
From 0bdcb88b2d0013aa435dc03950fb42cef2cbd359 Mon Sep 17 00:00:00 2001
496c31
From: Simon McVittie <smcv@collabora.com>
496c31
Date: Fri, 5 Mar 2021 13:49:36 +0000
496c31
Subject: [PATCH 2/3] dir: Reserve the whole @@ prefix
496c31
496c31
If we add new features analogous to file forwarding later, we might
496c31
find that we need a different magic token. Let's reserve the whole
496c31
@@* namespace so we can call it @@something-else.
496c31
496c31
Signed-off-by: Simon McVittie <smcv@collabora.com>
496c31
---
496c31
 common/flatpak-dir.c | 2 +-
496c31
 1 file changed, 1 insertion(+), 1 deletion(-)
496c31
496c31
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
496c31
index 7d3374dad..facfab37a 100644
496c31
--- a/common/flatpak-dir.c
496c31
+++ b/common/flatpak-dir.c
496c31
@@ -7139,7 +7139,7 @@ export_desktop_file (const char         *app,
496c31
                 g_string_append_printf (new_exec, " @@ %s @@", arg);
496c31
               else if (strcasecmp (arg, "%u") == 0)
496c31
                 g_string_append_printf (new_exec, " @@u %s @@", arg);
496c31
-              else if (strcmp (arg, "@@") == 0 || strcmp (arg, "@@u") == 0)
496c31
+              else if (g_str_has_prefix (arg, "@@"))
496c31
                 g_print (_("Skipping invalid Exec argument %s\n"), arg);
496c31
               else
496c31
                 g_string_append_printf (new_exec, " %s", arg);
496c31
496c31
From 230f4c3521cd0dffa446ab9b70e958cdd9241bbe Mon Sep 17 00:00:00 2001
496c31
From: Simon McVittie <smcv@collabora.com>
496c31
Date: Fri, 5 Mar 2021 13:51:33 +0000
496c31
Subject: [PATCH 3/3] dir: Refuse to export .desktop files with suspicious uses
496c31
 of @@ tokens
496c31
496c31
This is either a malicious/compromised app trying to do an attack, or
496c31
a mistake that will break handling of %f, %u and so on. Either way,
496c31
if we refuse to export the .desktop file, resulting in installation
496c31
failing, then it makes the rejection more obvious than quietly
496c31
removing the magic tokens.
496c31
496c31
Signed-off-by: Simon McVittie <smcv@collabora.com>
496c31
---
496c31
 common/flatpak-dir.c | 6 +++++-
496c31
 1 file changed, 5 insertions(+), 1 deletion(-)
496c31
496c31
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c
496c31
index facfab37a..c5edf346f 100644
496c31
--- a/common/flatpak-dir.c
496c31
+++ b/common/flatpak-dir.c
496c31
@@ -7140,7 +7140,11 @@ export_desktop_file (const char         *app,
496c31
               else if (strcasecmp (arg, "%u") == 0)
496c31
                 g_string_append_printf (new_exec, " @@u %s @@", arg);
496c31
               else if (g_str_has_prefix (arg, "@@"))
496c31
-                g_print (_("Skipping invalid Exec argument %s\n"), arg);
496c31
+                {
496c31
+                  flatpak_fail_error (error, FLATPAK_ERROR_EXPORT_FAILED,
496c31
+                                     _("Invalid Exec argument %s"), arg);
496c31
+                  goto out;
496c31
+                }
496c31
               else
496c31
                 g_string_append_printf (new_exec, " %s", arg);
496c31
             }