Blame 0107-dbus-process-only-valid-sub-directories-of-the-dump-.patch

69165ba
From 6e811d78e2719988ae291181f5b133af32ce62d8 Mon Sep 17 00:00:00 2001
69165ba
From: Jakub Filak <jfilak@redhat.com>
69165ba
Date: Thu, 23 Apr 2015 14:46:27 +0200
69165ba
Subject: [ABRT PATCH] dbus: process only valid sub-directories of the dump
69165ba
 location
69165ba
69165ba
Must have correct rights and must be a direct sub-directory of the dump
69165ba
location.
69165ba
69165ba
This issue was discovered by Florian Weimer of Red Hat Product Security.
69165ba
69165ba
Related: #1214451
69165ba
69165ba
Signed-off-by: Jakub Filak <jfilak@redhat.com>
69165ba
---
69165ba
 src/dbus/abrt-dbus.c | 36 ++++++++++++++++++++++++++----------
69165ba
 1 file changed, 26 insertions(+), 10 deletions(-)
69165ba
69165ba
diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c
69165ba
index 308a9af..7400dff 100644
69165ba
--- a/src/dbus/abrt-dbus.c
69165ba
+++ b/src/dbus/abrt-dbus.c
69165ba
@@ -132,18 +132,34 @@ static uid_t get_caller_uid(GDBusConnection *connection, GDBusMethodInvocation *
69165ba
     return caller_uid;
69165ba
 }
69165ba
 
69165ba
-static bool allowed_problem_dir(const char *dir_name)
69165ba
+bool allowed_problem_dir(const char *dir_name)
69165ba
 {
69165ba
-//HACK HACK HACK! Disabled for now until we fix clients (abrt-gui) to not pass /home/user/.cache/abrt/spool
69165ba
+    if (!dir_is_in_dump_location(dir_name))
69165ba
+    {
69165ba
+        error_msg("Bad problem directory name '%s', should start with: '%s'", dir_name, g_settings_dump_location);
69165ba
+        return false;
69165ba
+    }
69165ba
+
69165ba
+    /* We cannot test correct permissions yet because we still need to chown
69165ba
+     * dump directories before reporting and Chowing changes the file owner to
69165ba
+     * the reporter, which causes this test to fail and prevents users from
69165ba
+     * getting problem data after reporting it.
69165ba
+     *
69165ba
+     * Fortunately, libreport has been hardened against hard link and symbolic
69165ba
+     * link attacks and refuses to work with such files, so this test isn't
69165ba
+     * really necessary, however, we will use it once we get rid of the
69165ba
+     * chowning files.
69165ba
+     *
69165ba
+     * abrt-server refuses to run post-create on directories that have
69165ba
+     * incorrect owner (not "root:(abrt|root)"), incorrect permissions (other
69165ba
+     * bits are not 0) and are complete (post-create finished). So, there is no
69165ba
+     * way to run security sensitive event scripts (post-create) on crafted
69165ba
+     * problem directories.
69165ba
+     */
69165ba
 #if 0
69165ba
-    unsigned len = strlen(g_settings_dump_location);
69165ba
-
69165ba
-    /* If doesn't start with "g_settings_dump_location[/]"... */
69165ba
-    if (strncmp(dir_name, g_settings_dump_location, len) != 0
69165ba
-     || (dir_name[len] != '/' && dir_name[len] != '\0')
69165ba
-    /* or contains "/." anywhere (-> might contain ".." component) */
69165ba
-     || strstr(dir_name + len, "/.")
69165ba
-    ) {
69165ba
+    if (!dir_has_correct_permissions(dir_name))
69165ba
+    {
69165ba
+        error_msg("Problem directory '%s' isn't owned by root:abrt or others are not restricted from access", dir_name);
69165ba
         return false;
69165ba
     }
69165ba
 #endif
69165ba
-- 
69165ba
1.8.3.1
69165ba