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

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