Vulnerability: The _checkPolkitPrivilege function in serviceHelper.py in Back In Time (aka backintime) 1.1.18 and earlier uses a deprecated polkit authorization method (unix-process) that is subject to a race condition (time of check, time of use). With this authorization method, the owner of a process requesting a polkit operation is checked by polkitd via /proc/<pid>/status, by which time the requesting process may have been replaced by a different process with the same PID that has different privileges then the original requester.
Vulnerability ID: CVE-2017-7572
CWE: CWE-362
Severity score: 10
Project: https://github.com/bit-team/backintime
Published: 2017-04-06
File: qt/serviceHelper.py
Commit message: polkit CheckAuthorization: fix race condition in privilege authorization

The unix-process authorization subject is deprecated:

https://www.freedesktop.org/software/polkit/docs/latest/PolkitUnixProcess.html#polkit-unix-process-new

as it is subject to a race condition. A client process requesting
authorization can replace itself by a suid or otherwise root owned
executable, thus granting the original non-privileged request
privileges.

See also:

https://bugzilla.redhat.com/show_bug.cgi?id=1002375
https://github.com/Kabot/Unix-Privilege-Escalation-Exploits-Pack/blob/master/2011/CVE-2011-1485/polkit-pwnage.c

Polkit uses the real-uid of the process by now, thus mitigating the
exploit using suid binaries. It is still possible, however, to exit the
client process and try to get a root program to get the same PID.

In worst case this would allow an unauthenticated user to get backintime
or some other program to be executed via udev rules as root user.
Commit author: Matthias Gerstner

Vulnerable version (before fix):
 def _checkPolkitPrivilege(self, sender, conn, privilege):             # bus, and it does not make sense to restrict operations here             return          info = SenderInfo(sender, conn)          # get peer PID         pid = info.connectionPid()          # query PolicyKit         self._initPolkit()         try:             # we don't need is_challenge return here, since we call with AllowUserInteraction             (is_auth, _, details) = self.polkit.CheckAuthorization(                     ('unix-process', {'pid': dbus.UInt32(pid, variant_level=1),                     'start-time': dbus.UInt64(0, variant_level=1)}),                     privilege, {'': ''}, dbus.UInt32(1), '', timeout=3000)         except dbus.DBusException as e:             if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown':

Fixed version (after fix):
 def _checkPolkitPrivilege(self, sender, conn, privilege):             # bus, and it does not make sense to restrict operations here             return          # query PolicyKit         self._initPolkit()         try:             # we don't need is_challenge return here, since we call with AllowUserInteraction             (is_auth, _, details) = self.polkit.CheckAuthorization(                     ('system-bus-name', {'name': dbus.String(sender, variant_level=1)}),                     privilege, {'': ''}, dbus.UInt32(1), '', timeout=3000)         except dbus.DBusException as e:             if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown':

Patch:
patch: @@ -282,18 +282,12 @@ def _checkPolkitPrivilege(self, sender, conn, privilege):
             # bus, and it does not make sense to restrict operations here
             return
 
-        info = SenderInfo(sender, conn)
-
-        # get peer PID
-        pid = info.connectionPid()
-
         # query PolicyKit
         self._initPolkit()
         try:
             # we don't need is_challenge return here, since we call with AllowUserInteraction
             (is_auth, _, details) = self.polkit.CheckAuthorization(
-                    ('unix-process', {'pid': dbus.UInt32(pid, variant_level=1),
-                    'start-time': dbus.UInt64(0, variant_level=1)}),
+                    ('system-bus-name', {'name': dbus.String(sender, variant_level=1)}),
                     privilege, {'': ''}, dbus.UInt32(1), '', timeout=3000)
         except dbus.DBusException as e:
             if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown':
path: qt/serviceHelper.py