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

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