c92e4a
From 07e1f547575096ad8a0a56394d8710488b4ac9ec Mon Sep 17 00:00:00 2001
c92e4a
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
c92e4a
Date: Tue, 23 Aug 2016 18:09:49 +0200
c92e4a
Subject: [PATCH] High: libcrmcommon: fix CVE-2016-7035 (improper IPC guarding)
c92e4a
MIME-Version: 1.0
c92e4a
Content-Type: text/plain; charset=UTF-8
c92e4a
Content-Transfer-Encoding: 8bit
c92e4a
c92e4a
It was discovered that at some not so uncommon circumstances, some
c92e4a
pacemaker daemons could be talked to, via libqb-facilitated IPC, by
c92e4a
unprivileged clients due to flawed authorization decision.  Depending
c92e4a
on the capabilities of affected daemons, this might equip unauthorized
c92e4a
user with local privilege escalation or up to cluster-wide remote
c92e4a
execution of possibly arbitrary commands when such user happens to
c92e4a
reside at standard or remote/guest cluster node, respectively.
c92e4a
c92e4a
The original vulnerability was introduced in an attempt to allow
c92e4a
unprivileged IPC clients to clean up the file system materialized
c92e4a
leftovers in case the server (otherwise responsible for the lifecycle
c92e4a
of these files) crashes.  While the intended part of such behavior is
c92e4a
now effectively voided (along with the unintended one), a best-effort
c92e4a
fix to address this corner case systemically at libqb is coming along.
c92e4a
c92e4a
Affected versions:  1.1.10-rc1 (2013-04-17) - 1.1.15 (2016-06-21)
c92e4a
Impact:             Important
c92e4a
CVSSv3 ranking:     7.8 : CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
c92e4a
c92e4a
Credits for independent findings, in chronological order:
c92e4a
  Jan "poki" Pokorný, of Red Hat
c92e4a
  Alain Moulle, of ATOS/BULL
c92e4a
---
c92e4a
 lib/common/ipc.c | 14 +++-----------
c92e4a
 1 file changed, 3 insertions(+), 11 deletions(-)
c92e4a
c92e4a
diff --git a/lib/common/ipc.c b/lib/common/ipc.c
c92e4a
index 6d6d3cd..9f63dfe 100644
c92e4a
--- a/lib/common/ipc.c
c92e4a
+++ b/lib/common/ipc.c
c92e4a
@@ -293,7 +293,6 @@ crm_client_disconnect_all(qb_ipcs_service_t *service)
c92e4a
 crm_client_t *
c92e4a
 crm_client_new(qb_ipcs_connection_t * c, uid_t uid_client, gid_t gid_client)
c92e4a
 {
c92e4a
-    static uid_t uid_server = 0;
c92e4a
     static gid_t gid_cluster = 0;
c92e4a
 
c92e4a
     crm_client_t *client = NULL;
c92e4a
@@ -304,7 +303,6 @@ crm_client_new(qb_ipcs_connection_t * c, uid_t uid_client, gid_t gid_client)
c92e4a
     }
c92e4a
 
c92e4a
     if (gid_cluster == 0) {
c92e4a
-        uid_server = getuid();
c92e4a
         if(crm_user_lookup(CRM_DAEMON_USER, NULL, &gid_cluster) < 0) {
c92e4a
             static bool have_error = FALSE;
c92e4a
             if(have_error == FALSE) {
c92e4a
@@ -314,16 +312,10 @@ crm_client_new(qb_ipcs_connection_t * c, uid_t uid_client, gid_t gid_client)
c92e4a
         }
c92e4a
     }
c92e4a
 
c92e4a
-    if(gid_cluster != 0 && gid_client != 0) {
c92e4a
-        uid_t best_uid = -1; /* Passing -1 to chown(2) means don't change */
c92e4a
-
c92e4a
-        if(uid_client == 0 || uid_server == 0) { /* Someone is priveliged, but the other may not be */
c92e4a
-            best_uid = QB_MAX(uid_client, uid_server);
c92e4a
-            crm_trace("Allowing user %u to clean up after disconnect", best_uid);
c92e4a
-        }
c92e4a
-
c92e4a
+    if (uid_client != 0) {
c92e4a
         crm_trace("Giving access to group %u", gid_cluster);
c92e4a
-        qb_ipcs_connection_auth_set(c, best_uid, gid_cluster, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
c92e4a
+        /* Passing -1 to chown(2) means don't change */
c92e4a
+        qb_ipcs_connection_auth_set(c, -1, gid_cluster, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
c92e4a
     }
c92e4a
 
c92e4a
     crm_client_init();
c92e4a
-- 
c92e4a
2.4.11
c92e4a