82ef06
From 166978a09cf5edff4028e670b6074215a4c75eca Mon Sep 17 00:00:00 2001
82ef06
From: Colin Walters <walters@verbum.org>
82ef06
Date: Thu, 14 Feb 2013 10:19:34 -0500
82ef06
Subject: [PATCH] CVE-2013-0292: dbus-gproxy: Verify sender of NameOwnerChanged signals to be o.f.DBus
82ef06
82ef06
Anyone can hop on the bus and emit a signal whose interface is
82ef06
o.f.DBus; it's expected at the moments that clients (and notably DBus
82ef06
libraries) check the sender.
82ef06
82ef06
This could previously be used to trick a system service using dbus-glib
82ef06
into thinking a malicious signal came from a privileged source, by
82ef06
claiming that ownership of the privileged source's well-known name had
82ef06
changed from the privileged source's real unique name to the attacker's
82ef06
unique name.
82ef06
82ef06
[altered to be NULL-safe so it won't crash on peer connections -smcv]
82ef06
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
82ef06
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
82ef06
---
82ef06
 dbus/dbus-gproxy.c |    7 ++++---
82ef06
 1 files changed, 4 insertions(+), 3 deletions(-)
82ef06
82ef06
diff --git a/dbus/dbus-gproxy.c b/dbus/dbus-gproxy.c
82ef06
index 2fc52f9..c3ae9ec 100644
82ef06
--- a/dbus/dbus-gproxy.c
82ef06
+++ b/dbus/dbus-gproxy.c
82ef06
@@ -1250,8 +1250,11 @@ dbus_g_proxy_manager_filter (DBusConnection    *connection,
82ef06
       GSList *tmp;
82ef06
       const char *sender;
82ef06
 
82ef06
+      sender = dbus_message_get_sender (message);
82ef06
+
82ef06
       /* First we handle NameOwnerChanged internally */
82ef06
-      if (dbus_message_is_signal (message,
82ef06
+      if (g_strcmp0 (sender, DBUS_SERVICE_DBUS) == 0 &&
82ef06
+	  dbus_message_is_signal (message,
82ef06
 				  DBUS_INTERFACE_DBUS,
82ef06
 				  "NameOwnerChanged"))
82ef06
 	{
82ef06
@@ -1280,8 +1283,6 @@ dbus_g_proxy_manager_filter (DBusConnection    *connection,
82ef06
 	    }
82ef06
 	}
82ef06
 
82ef06
-      sender = dbus_message_get_sender (message);
82ef06
-
82ef06
       /* dbus spec requires these, libdbus validates */
82ef06
       g_assert (dbus_message_get_path (message) != NULL);
82ef06
       g_assert (dbus_message_get_interface (message) != NULL);
82ef06
-- 
82ef06
1.7.1
82ef06