~ubuntu-branches/ubuntu/trusty/kde-workspace/trusty-security

« back to all changes in this revision

Viewing changes to debian/patches/upstream_clock-privilage-escalation.diff

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-11-05 13:14:49 UTC
  • mfrom: (126.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20141105131449-3krnlvav3css6tr4
Tags: 4:4.11.11-0ubuntu0.2
* SECURITY UPDATE: Privilege Escalation via KDE Clock KCM polkit helper
 - Add upstream_clock-privilage-escalation.diff, checks which
   binary is being run
 - https://www.kde.org/info/security/advisory-20141106-1.txt
 - LP: #1389665

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Privilege Escalation via KDE Clock KCM polkit helper
 
2
 KDE workspace configuration module for setting the date and time has a
 
3
 helper program which runs as root for performing actions. This is
 
4
 secured with polkit. This helper takes the name of the ntp utility to
 
5
 run as an argument. This allows a hacker to run any arbitrary command
 
6
 as root under the guise of updating the time.
 
7
Author: David Edmundson <davidedmundson@kde.org>
 
8
Origin: upstream
 
9
Forwarded: not-needed, it's from upstream
 
10
Reviewed-by: Jonathan Riddell 
 
11
Last-Update: 2014-11-05
 
12
---
 
13
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
 
14
Index: kde-workspace-4.11.12/kcontrol/dateandtime/dtime.cpp
 
15
===================================================================
 
16
--- kde-workspace-4.11.12.orig/kcontrol/dateandtime/dtime.cpp
 
17
+++ kde-workspace-4.11.12/kcontrol/dateandtime/dtime.cpp
 
18
@@ -142,27 +142,15 @@ void Dtime::serverTimeCheck() {
 
19
   //kclock->setEnabled(enabled);
 
20
 }
 
21
 
 
22
-void Dtime::findNTPutility(){
 
23
-  QByteArray envpath = qgetenv("PATH");
 
24
-  if (!envpath.isEmpty() && envpath[0] == ':') {
 
25
-    envpath = envpath.mid(1);
 
26
-  }
 
27
-
 
28
-  QString path = "/sbin:/usr/sbin:";
 
29
-  if (!envpath.isEmpty()) {
 
30
-    path += QString::fromLocal8Bit(envpath);
 
31
-  } else {
 
32
-    path += QLatin1String("/bin:/usr/bin");
 
33
-  }
 
34
-
 
35
-  foreach(const QString &possible_ntputility, QStringList() << "ntpdate" << "rdate" ) {
 
36
-    if( !((ntpUtility = KStandardDirs::findExe(possible_ntputility, path)).isEmpty()) ) {
 
37
-      kDebug() << "ntpUtility = " << ntpUtility;
 
38
-      return;
 
39
+void Dtime::findNTPutility()
 
40
+{
 
41
+    const QString exePath = QLatin1String("/usr/sbin:/usr/bin:/sbin:/bin");
 
42
+    foreach(const QString &possible_ntputility, QStringList() << "ntpdate" << "rdate" ) {
 
43
+        ntpUtility = KStandardDirs::findExe(possible_ntputility, exePath);
 
44
+        if (!ntpUtility.isEmpty()) {
 
45
+            return;
 
46
+        }
 
47
     }
 
48
-  }
 
49
-
 
50
-  kDebug() << "ntpUtility not found!";
 
51
 }
 
52
 
 
53
 void Dtime::set_time()
 
54
@@ -238,7 +226,6 @@ void Dtime::save( QVariantMap& helperarg
 
55
   helperargs["ntp"] = true;
 
56
   helperargs["ntpServers"] = list;
 
57
   helperargs["ntpEnabled"] = setDateTimeAuto->isChecked();
 
58
-  helperargs["ntpUtility"] = ntpUtility;
 
59
 
 
60
   if(setDateTimeAuto->isChecked() && !ntpUtility.isEmpty()){
 
61
     // NTP Time setting - done in helper
 
62
Index: kde-workspace-4.11.12/kcontrol/dateandtime/helper.cpp
 
63
===================================================================
 
64
--- kde-workspace-4.11.12.orig/kcontrol/dateandtime/helper.cpp
 
65
+++ kde-workspace-4.11.12/kcontrol/dateandtime/helper.cpp
 
66
@@ -52,8 +52,18 @@
 
67
 // clears it. So we have to use a reasonable default.
 
68
 static const QString exePath = QLatin1String("/usr/sbin:/usr/bin:/sbin:/bin");
 
69
 
 
70
-int ClockHelper::ntp( const QStringList& ntpServers, bool ntpEnabled,
 
71
-                      const QString& ntpUtility )
 
72
+static QString findNtpUtility()
 
73
+{
 
74
+    foreach(const QString &possible_ntputility, QStringList() << "ntpdate" << "rdate" ) {
 
75
+        const QString ntpUtility = KStandardDirs::findExe(possible_ntputility, exePath);
 
76
+        if (!ntpUtility.isEmpty()) {
 
77
+            return ntpUtility;
 
78
+        }
 
79
+    }
 
80
+    return QString();
 
81
+}
 
82
+
 
83
+int ClockHelper::ntp( const QStringList& ntpServers, bool ntpEnabled )
 
84
 {
 
85
   int ret = 0;
 
86
 
 
87
@@ -69,6 +79,8 @@ int ClockHelper::ntp( const QStringList&
 
88
   config.writeEntry("servers", ntpServers );
 
89
   config.writeEntry("enabled", ntpEnabled );
 
90
 
 
91
+  QString ntpUtility(findNtpUtility());
 
92
+
 
93
   if ( ntpEnabled && !ntpUtility.isEmpty() ) {
 
94
     // NTP Time setting
 
95
     QString timeServer = ntpServers.first();
 
96
@@ -111,6 +123,13 @@ int ClockHelper::date( const QString& ne
 
97
 int ClockHelper::tz( const QString& selectedzone )
 
98
 {
 
99
     int ret = 0;
 
100
+
 
101
+    //only allow letters, numbers hyphen underscore plus and forward slash
 
102
+    //allowed pattern taken from time-util.c in systemd
 
103
+    if (!QRegExp("[a-zA-Z0-9-_+/]*").exactMatch(selectedzone)) {
 
104
+        return ret;
 
105
+    }
 
106
+
 
107
 #if defined(USE_SOLARIS)       // MARCO
 
108
 
 
109
         KTemporaryFile tf;
 
110
@@ -236,7 +255,7 @@ ActionReply ClockHelper::save(const QVar
 
111
   int ret = 0; // error code
 
112
 //  The order here is important
 
113
   if( _ntp )
 
114
-    ret |= ntp( args.value("ntpServers").toStringList(), args.value("ntpEnabled").toBool(), args.value("ntpUtility").toString() );
 
115
+    ret |= ntp( args.value("ntpServers").toStringList(), args.value("ntpEnabled").toBool());
 
116
   if( _date )
 
117
     ret |= date( args.value("newdate").toString(), args.value("olddate").toString() );
 
118
   if( _tz )
 
119
Index: kde-workspace-4.11.12/kcontrol/dateandtime/helper.h
 
120
===================================================================
 
121
--- kde-workspace-4.11.12.orig/kcontrol/dateandtime/helper.h
 
122
+++ kde-workspace-4.11.12/kcontrol/dateandtime/helper.h
 
123
@@ -42,8 +42,7 @@ class ClockHelper : public QObject
 
124
         ActionReply save(const QVariantMap &map);
 
125
 
 
126
     private:
 
127
-        int ntp(const QStringList& ntpServers, bool ntpEnabled,
 
128
-                const QString& ntpUtility);
 
129
+        int ntp(const QStringList& ntpServers, bool ntpEnabled);
 
130
         int date(const QString& newdate, const QString& olddate);
 
131
         int tz(const QString& selectedzone);
 
132
         int tzreset();