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