Blame SOURCES/0001-comics-Remove-support-for-tar-and-tar-like-commands.patch

676a83
From 717df38fd8509bf883b70d680c9b1b3cf36732ee Mon Sep 17 00:00:00 2001
676a83
From: Bastien Nocera <hadess@hadess.net>
676a83
Date: Thu, 6 Jul 2017 20:02:00 +0200
676a83
Subject: [PATCH] comics: Remove support for tar and tar-like commands
676a83
676a83
When handling tar files, or using a command with tar-compatible syntax,
676a83
to open comic-book archives, both the archive name (the name of the
676a83
comics file) and the filename (the name of a page within the archive)
676a83
are quoted to not be interpreted by the shell.
676a83
676a83
But the filename is completely with the attacker's control and can start
676a83
with "--" which leads to tar interpreting it as a command line flag.
676a83
676a83
This can be exploited by creating a CBT file (a tar archive with the
676a83
.cbt suffix) with an embedded file named something like this:
676a83
"--checkpoint-action=exec=bash -c 'touch ~/hacked;'.jpg"
676a83
676a83
CBT files are infinitely rare (CBZ is usually used for DRM-free
676a83
commercial releases, CBR for those from more dubious provenance), so
676a83
removing support is the easiest way to avoid the bug triggering. All
676a83
this code was rewritten in the development release for GNOME 3.26 to not
676a83
shell out to any command, closing off this particular attack vector.
676a83
676a83
This also removes the ability to use libarchive's bsdtar-compatible
676a83
binary for CBZ (ZIP), CB7 (7zip), and CBR (RAR) formats. The first two
676a83
are already supported by unzip and 7zip respectively. libarchive's RAR
676a83
support is limited, so unrar is a requirement anyway.
676a83
676a83
Discovered by Felix Wilhelm from the Google Security Team.
676a83
676a83
https://bugzilla.gnome.org/show_bug.cgi?id=784630
676a83
---
676a83
 backend/comics/comics-document.c | 40 +---------------------------------------
676a83
 configure.ac                     |  2 +-
676a83
 2 files changed, 2 insertions(+), 40 deletions(-)
676a83
676a83
diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c
676a83
index 4c747310..641d7856 100644
676a83
--- a/backend/comics/comics-document.c
676a83
+++ b/backend/comics/comics-document.c
676a83
@@ -56,8 +56,7 @@ typedef enum
676a83
 	RARLABS,
676a83
 	GNAUNRAR,
676a83
 	UNZIP,
676a83
-	P7ZIP,
676a83
-	TAR
676a83
+	P7ZIP
676a83
 } ComicBookDecompressType;
676a83
 
676a83
 typedef struct _ComicsDocumentClass ComicsDocumentClass;
676a83
@@ -117,9 +116,6 @@ static const ComicBookDecompressCommand command_usage_def[] = {
676a83
 
676a83
         /* 7zip */
676a83
 	{NULL               , "%s l -- %s"     , "%s x -y %s -o%s", FALSE, OFFSET_7Z},
676a83
-
676a83
-        /* tar */
676a83
-	{"%s -xOf"          , "%s -tf %s"      , NULL             , FALSE, NO_OFFSET}
676a83
 };
676a83
 
676a83
 static GSList*    get_supported_image_extensions (void);
676a83
@@ -364,13 +360,6 @@ comics_check_decompress_command	(gchar          *mime_type,
676a83
 			comics_document->command_usage = GNAUNRAR;
676a83
 			return TRUE;
676a83
 		}
676a83
-		comics_document->selected_command =
676a83
-				g_find_program_in_path ("bsdtar");
676a83
-		if (comics_document->selected_command) {
676a83
-			comics_document->command_usage = TAR;
676a83
-			return TRUE;
676a83
-		}
676a83
-
676a83
 	} else if (g_content_type_is_a (mime_type, "application/x-cbz") ||
676a83
 		   g_content_type_is_a (mime_type, "application/zip")) {
676a83
 		/* InfoZIP's unzip program */
676a83
@@ -396,12 +385,6 @@ comics_check_decompress_command	(gchar          *mime_type,
676a83
 			comics_document->command_usage = P7ZIP;
676a83
 			return TRUE;
676a83
 		}
676a83
-		comics_document->selected_command =
676a83
-				g_find_program_in_path ("bsdtar");
676a83
-		if (comics_document->selected_command) {
676a83
-			comics_document->command_usage = TAR;
676a83
-			return TRUE;
676a83
-		}
676a83
 
676a83
 	} else if (g_content_type_is_a (mime_type, "application/x-cb7") ||
676a83
 		   g_content_type_is_a (mime_type, "application/x-7z-compressed")) {
676a83
@@ -425,27 +408,6 @@ comics_check_decompress_command	(gchar          *mime_type,
676a83
 			comics_document->command_usage = P7ZIP;
676a83
 			return TRUE;
676a83
 		}
676a83
-		comics_document->selected_command =
676a83
-				g_find_program_in_path ("bsdtar");
676a83
-		if (comics_document->selected_command) {
676a83
-			comics_document->command_usage = TAR;
676a83
-			return TRUE;
676a83
-		}
676a83
-	} else if (g_content_type_is_a (mime_type, "application/x-cbt") ||
676a83
-		   g_content_type_is_a (mime_type, "application/x-tar")) {
676a83
-		/* tar utility (Tape ARchive) */
676a83
-		comics_document->selected_command =
676a83
-				g_find_program_in_path ("tar");
676a83
-		if (comics_document->selected_command) {
676a83
-			comics_document->command_usage = TAR;
676a83
-			return TRUE;
676a83
-		}
676a83
-		comics_document->selected_command =
676a83
-				g_find_program_in_path ("bsdtar");
676a83
-		if (comics_document->selected_command) {
676a83
-			comics_document->command_usage = TAR;
676a83
-			return TRUE;
676a83
-		}
676a83
 	} else {
676a83
 		g_set_error (error,
676a83
 			     EV_DOCUMENT_ERROR,
676a83
diff --git a/configure.ac b/configure.ac
676a83
index 9e9f8316..7eb0f1f3 100644
676a83
--- a/configure.ac
676a83
+++ b/configure.ac
676a83
@@ -795,7 +795,7 @@ AC_SUBST(TIFF_MIME_TYPES)
676a83
 AC_SUBST(APPDATA_TIFF_MIME_TYPES)
676a83
 AM_SUBST_NOTMAKE(APPDATA_TIFF_MIME_TYPES)
676a83
 if test "x$enable_comics" = "xyes"; then
676a83
-        COMICS_MIME_TYPES="application/x-cbr;application/x-cbz;application/x-cb7;application/x-cbt;application/x-ext-cbr;application/x-ext-cbz;application/vnd.comicbook+zip;application/x-ext-cb7;application/x-ext-cbt"
676a83
+        COMICS_MIME_TYPES="application/x-cbr;application/x-cbz;application/x-cb7;application/x-ext-cbr;application/x-ext-cbz;application/vnd.comicbook+zip;application/x-ext-cb7"
676a83
         APPDATA_COMICS_MIME_TYPES=$(echo "<mimetype>$COMICS_MIME_TYPES</mimetype>" | sed -e 's/;/<\/mimetype>\n    <mimetype>/g')
676a83
         if test -z "$EVINCE_MIME_TYPES"; then
676a83
            EVINCE_MIME_TYPES="${COMICS_MIME_TYPES}"
676a83
-- 
676a83
2.13.0
676a83