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>
9
Forwarded: not-needed, it's from upstream
10
Reviewed-by: Jonathan Riddell
11
Last-Update: 2014-11-05
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);
22
-void Dtime::findNTPutility(){
23
- QByteArray envpath = qgetenv("PATH");
24
- if (!envpath.isEmpty() && envpath[0] == ':') {
25
- envpath = envpath.mid(1);
28
- QString path = "/sbin:/usr/sbin:";
29
- if (!envpath.isEmpty()) {
30
- path += QString::fromLocal8Bit(envpath);
32
- path += QLatin1String("/bin:/usr/bin");
35
- foreach(const QString &possible_ntputility, QStringList() << "ntpdate" << "rdate" ) {
36
- if( !((ntpUtility = KStandardDirs::findExe(possible_ntputility, path)).isEmpty()) ) {
37
- kDebug() << "ntpUtility = " << ntpUtility;
39
+void Dtime::findNTPutility()
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()) {
50
- kDebug() << "ntpUtility not found!";
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;
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
67
// clears it. So we have to use a reasonable default.
68
static const QString exePath = QLatin1String("/usr/sbin:/usr/bin:/sbin:/bin");
70
-int ClockHelper::ntp( const QStringList& ntpServers, bool ntpEnabled,
71
- const QString& ntpUtility )
72
+static QString findNtpUtility()
74
+ foreach(const QString &possible_ntputility, QStringList() << "ntpdate" << "rdate" ) {
75
+ const QString ntpUtility = KStandardDirs::findExe(possible_ntputility, exePath);
76
+ if (!ntpUtility.isEmpty()) {
83
+int ClockHelper::ntp( const QStringList& ntpServers, bool ntpEnabled )
87
@@ -69,6 +79,8 @@ int ClockHelper::ntp( const QStringList&
88
config.writeEntry("servers", ntpServers );
89
config.writeEntry("enabled", ntpEnabled );
91
+ QString ntpUtility(findNtpUtility());
93
if ( ntpEnabled && !ntpUtility.isEmpty() ) {
95
QString timeServer = ntpServers.first();
96
@@ -111,6 +123,13 @@ int ClockHelper::date( const QString& ne
97
int ClockHelper::tz( const QString& selectedzone )
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)) {
107
#if defined(USE_SOLARIS) // MARCO
110
@@ -236,7 +255,7 @@ ActionReply ClockHelper::save(const QVar
111
int ret = 0; // error code
112
// The order here is important
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());
117
ret |= date( args.value("newdate").toString(), args.value("olddate").toString() );
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);
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);