CVE-2015-5273 (published 2015-12-07T18:59Z)

The abrt-action-install-debuginfo-to-abrt-cache help program in Automatic Bug Reporting Tool (ABRT) before 2.7.1 allows local users to write to arbitrary files via a symlink attack on unpacked.cpio in a pre-created directory with a predictable name in /var/tmp.

Severity: LOW
CVSS v2 base score: 3.6 (AV:L/AC:L/Au:N/C:N/I:P/A:P)

Weakness information:
cwe_id: CWE-59
cwe_name: Improper Link Resolution Before File Access ('Link Following')
description: The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.
extended_description: 
            
            
         
         

Fix information:
repo_url: https://github.com/abrt/abrt
commit_details: repo_url: https://github.com/abrt/abrt
author: Jakub Filak
author_date: 2015-09-30 11:50:18+02:00
msg: a-a-i-d-to-abrt-cache: make own random temporary directory

The set-user-ID wrapper must use own new temporary directory in order to
avoid security issues with unpacking specially crafted debuginfo
packages that might be used to create files or symlinks anywhere on the
file system as the abrt user.

Withot the forking code the temporary directory would remain on the
filesystem in the case where all debuginfo data are already available.
This is caused by the fact that the underlying libreport functionality
accepts path to a desired temporary directory and creates it only if
necessary. Otherwise, the directory is not touched at all.

This commit addresses CVE-2015-5273

Signed-off-by: Jakub Filak <jfilak@redhat.com>
repository: repo_url: https://github.com/abrt/abrt
repo_name: abrt/abrt
description: Automatic bug detection and reporting tool
repo_language: C
owner: abrt
file_changes: filename: Makefile.am
change_type: ModificationType.MODIFY
diff: @@ -371,6 +371,7 @@ abrt_action_install_debuginfo_to_abrt_cache_CPPFLAGS = \
     -D_GNU_SOURCE \
     -DBIN_DIR=\"$(bindir)\" \
     -DSBIN_DIR=\"$(sbindir)\" \
+    -DLARGE_DATA_TMP_DIR=\"$(LARGE_DATA_TMP_DIR)\" \
     $(LIBREPORT_CFLAGS) \
     -Wall -Wwrite-strings \
     -fPIE

programming_language: Shell
filename: abrt-action-install-debuginfo-to-abrt-cache.c
change_type: ModificationType.MODIFY
diff: @@ -108,8 +108,14 @@ int main(int argc, char **argv)
         build_ids_self_fd = xasprintf("/proc/self/fd/%d", build_ids_fd);
     }
 
-    /* name, -v, --ids, -, -y, -e, EXACT, -r, REPO, --, NULL */
-    const char *args[11];
+    char tmp_directory[] = LARGE_DATA_TMP_DIR"/abrt-tmp-debuginfo.XXXXXX";
+    if (mkdtemp(tmp_directory) == NULL)
+        perror_msg_and_die("Failed to create working directory");
+
+    log_info("Created working directory: %s", tmp_directory);
+
+    /* name, -v, --ids, -, -y, -e, EXACT, -r, REPO, -t, PATH, --, NULL */
+    const char *args[13];
     {
         const char *verbs[] = { "", "-v", "-vv", "-vvv" };
         unsigned i = 0;
@@ -130,6 +136,8 @@ int main(int argc, char **argv)
             args[i++] = "--repo";
             args[i++] = repo;
         }
+        args[i++] = "--tmpdir";
+        args[i++] = tmp_directory;
         args[i++] = "--";
         args[i] = NULL;
     }
@@ -204,6 +212,31 @@ int main(int argc, char **argv)
         umask(0022);
     }
 
-    execvp(EXECUTABLE, (char **)args);
-    error_msg_and_die("Can't execute %s", EXECUTABLE);
+    pid_t pid = fork();
+    if (pid < 0)
+        perror_msg_and_die("fork");
+
+    if (pid == 0)
+    {
+        execvp(EXECUTABLE, (char **)args);
+        error_msg_and_die("Can't execute %s", EXECUTABLE);
+    }
+
+    int status;
+    if (safe_waitpid(pid, &status, 0) < 0)
+        perror_msg_and_die("waitpid");
+
+    if (rmdir(tmp_directory) >= 0)
+        log_info("Removed working directory: %s", tmp_directory);
+    else if (errno != ENOENT)
+        perror_msg("Failed to remove working directory");
+
+    /* Normal execution should exit here. */
+    if (WIFEXITED(status))
+        return WEXITSTATUS(status);
+
+    if (WIFSIGNALED(status))
+        error_msg_and_die("Child terminated with signal %d", WTERMSIG(status));
+
+    error_msg_and_die("Child exit failed");
 }

programming_language: C