CVE-2023-52138: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (CWE-22)
value: Engrampa is an archive manager for the MATE environment. Engrampa is found to be vulnerable to a Path Traversal vulnerability that can be leveraged to achieve full Remote Command Execution (RCE) on the target. While handling CPIO archives, the Engrampa Archive manager follows symlink, cpio by default will follow stored symlinks while extracting and the Archiver will not check the symlink location, which leads to arbitrary file writes to unintended locations. When the victim extracts the archive, the attacker can craft a malicious cpio or ISO archive to achieve RCE on the target system. This vulnerability was fixed in commit 63d5dfa.

CWE description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
CVSS v3 base score: 9.6
Published: 2024-02-05T15:15Z
Repository: https://github.com/mate-desktop/engrampa
Language: C
Files changed: src/fr-command-cpio.c, src/fr-command-unarchiver.c
Commit date: 2024-02-04 22:21:38 +0000
Commit message: Use unar instead of cpio for CPIO archives

Diff: diff --git a/src/fr-command-cpio.c b/src/fr-command-cpio.c
index c6a7198..3d0fcd9 100644
--- a/src/fr-command-cpio.c
+++ b/src/fr-command-cpio.c
@@ -217,11 +217,11 @@ fr_command_cpio_extract (FrCommand *comm,
 	g_string_free (cmd, TRUE);
 
 	fr_process_end_command (comm->process);
 }
 
-const char *cpio_mime_type[] = { "application/x-cpio", NULL };
+const char *cpio_mime_type[] = { /*"application/x-cpio",*/ NULL };
 
 static const char **
 fr_command_cpio_get_mime_types (FrCommand *comm)
 {
 	return cpio_mime_type;
@@ -233,12 +233,12 @@ fr_command_cpio_get_capabilities (FrCommand  *comm,
 				  gboolean    check_command)
 {
 	FrCommandCaps capabilities;
 
 	capabilities = FR_COMMAND_CAN_ARCHIVE_MANY_FILES;
-	if (is_program_available (CPIO_PATH, check_command))
-		capabilities |= FR_COMMAND_CAN_READ;
+/*	if (is_program_available (CPIO_PATH, check_command))
+		capabilities |= FR_COMMAND_CAN_READ;*/
 
 	return capabilities;
 }
 
 static const char *
diff --git a/src/fr-command-unarchiver.c b/src/fr-command-unarchiver.c
index c7aa5e6..a6a8c2d 100644
--- a/src/fr-command-unarchiver.c
+++ b/src/fr-command-unarchiver.c
@@ -245,10 +245,11 @@ fr_command_unarchiver_handle_error (FrCommand   *comm,
 }
 
 const char *unarchiver_mime_type[] = { "application/zip",
 				       "application/x-cbr",
 				       "application/x-rar",
+				       "application/x-cpio",
 				       NULL };
 
 static const char **
 fr_command_unarchiver_get_mime_types (FrCommand *comm)
 {

Vulnerable code: const char *cpio_mime_type[] = { "application/x-cpio", NULL };
	if (is_program_available (CPIO_PATH, check_command))
		capabilities |= FR_COMMAND_CAN_READ;
Fixed code: const char *cpio_mime_type[] = { /*"application/x-cpio",*/ NULL };
/*	if (is_program_available (CPIO_PATH, check_command))
		capabilities |= FR_COMMAND_CAN_READ;*/
				       "application/x-cpio",