From f7dcaa0f62de7c0787b6d4b95425a47d7f23a616 Mon Sep 17 00:00:00 2001 From: Rmys Date: Tue, 5 Jul 2022 10:02:49 +0300 Subject: [PATCH] polkit-0.120 --- system/base/polkit/actions.py | 3 +- system/base/polkit/files/CVE-2021-4034.patch | 79 +++++++++++++++++++ system/base/polkit/files/CVE-2021-4115.patch | 71 +++++++++++++++++ .../polkit/files/polkit-0.118-duktape.patch | 8 +- system/base/polkit/pspec.xml | 17 +++- 5 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 system/base/polkit/files/CVE-2021-4034.patch create mode 100644 system/base/polkit/files/CVE-2021-4115.patch diff --git a/system/base/polkit/actions.py b/system/base/polkit/actions.py index 16485072..b3f5bc04 100644 --- a/system/base/polkit/actions.py +++ b/system/base/polkit/actions.py @@ -21,8 +21,9 @@ def setup(): --with-dbus \ --enable-examples \ --enable-introspection \ - --disable-libsystemd-login \ --with-systemdsystemunitdir=no \ + --enable-libsystemd-login=no \ + --enable-libelogind=yes \ --disable-man-pages \ --disable-gtk-doc \ --disable-static") diff --git a/system/base/polkit/files/CVE-2021-4034.patch b/system/base/polkit/files/CVE-2021-4034.patch new file mode 100644 index 00000000..a06300a5 --- /dev/null +++ b/system/base/polkit/files/CVE-2021-4034.patch @@ -0,0 +1,79 @@ +From a2bf5c9c83b6ae46cbd5c779d3055bff81ded683 Mon Sep 17 00:00:00 2001 +From: Jan Rybar +Date: Tue, 25 Jan 2022 17:21:46 +0000 +Subject: [PATCH] pkexec: local privilege escalation (CVE-2021-4034) + +--- + src/programs/pkcheck.c | 5 +++++ + src/programs/pkexec.c | 23 ++++++++++++++++++++--- + 2 files changed, 25 insertions(+), 3 deletions(-) + +diff --git a/src/programs/pkcheck.c b/src/programs/pkcheck.c +index f1bb4e1..768525c 100644 +--- a/src/programs/pkcheck.c ++++ b/src/programs/pkcheck.c +@@ -363,6 +363,11 @@ main (int argc, char *argv[]) + local_agent_handle = NULL; + ret = 126; + ++ if (argc < 1) ++ { ++ exit(126); ++ } ++ + /* Disable remote file access from GIO. */ + setenv ("GIO_USE_VFS", "local", 1); + +diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c +index 7698c5c..84e5ef6 100644 +--- a/src/programs/pkexec.c ++++ b/src/programs/pkexec.c +@@ -488,6 +488,15 @@ main (int argc, char *argv[]) + pid_t pid_of_caller; + gpointer local_agent_handle; + ++ ++ /* ++ * If 'pkexec' is called THIS wrong, someone's probably evil-doing. Don't be nice, just bail out. ++ */ ++ if (argc<1) ++ { ++ exit(127); ++ } ++ + ret = 127; + authority = NULL; + subject = NULL; +@@ -614,10 +623,10 @@ main (int argc, char *argv[]) + + path = g_strdup (pwstruct.pw_shell); + if (!path) +- { ++ { + g_printerr ("No shell configured or error retrieving pw_shell\n"); + goto out; +- } ++ } + /* If you change this, be sure to change the if (!command_line) + case below too */ + command_line = g_strdup (path); +@@ -636,7 +645,15 @@ main (int argc, char *argv[]) + goto out; + } + g_free (path); +- argv[n] = path = s; ++ path = s; ++ ++ /* argc<2 and pkexec runs just shell, argv is guaranteed to be null-terminated. ++ * /-less shell shouldn't happen, but let's be defensive and don't write to null-termination ++ */ ++ if (argv[n] != NULL) ++ { ++ argv[n] = path; ++ } + } + if (access (path, F_OK) != 0) + { +-- +GitLab + diff --git a/system/base/polkit/files/CVE-2021-4115.patch b/system/base/polkit/files/CVE-2021-4115.patch new file mode 100644 index 00000000..3cb55819 --- /dev/null +++ b/system/base/polkit/files/CVE-2021-4115.patch @@ -0,0 +1,71 @@ +diff --git a/src/polkit/polkitsystembusname.c b/src/polkit/polkitsystembusname.c +index 8ed1363..2fbf5f1 100644 +--- a/src/polkit/polkitsystembusname.c ++++ b/src/polkit/polkitsystembusname.c +@@ -62,6 +62,10 @@ enum + PROP_NAME, + }; + ++ ++guint8 dbus_call_respond_fails; // has to be global because of callback ++ ++ + static void subject_iface_init (PolkitSubjectIface *subject_iface); + + G_DEFINE_TYPE_WITH_CODE (PolkitSystemBusName, polkit_system_bus_name, G_TYPE_OBJECT, +@@ -364,6 +368,7 @@ on_retrieved_unix_uid_pid (GObject *src, + if (!v) + { + data->caught_error = TRUE; ++ dbus_call_respond_fails += 1; + } + else + { +@@ -405,6 +410,8 @@ polkit_system_bus_name_get_creds_sync (PolkitSystemBusName *system_bus + tmp_context = g_main_context_new (); + g_main_context_push_thread_default (tmp_context); + ++ dbus_call_respond_fails = 0; ++ + /* Do two async calls as it's basically as fast as one sync call. + */ + g_dbus_connection_call (connection, +@@ -432,11 +439,34 @@ polkit_system_bus_name_get_creds_sync (PolkitSystemBusName *system_bus + on_retrieved_unix_uid_pid, + &data); + +- while (!((data.retrieved_uid && data.retrieved_pid) || data.caught_error)) +- g_main_context_iteration (tmp_context, TRUE); ++ while (TRUE) ++ { ++ /* If one dbus call returns error, we must wait until the other call ++ * calls _call_finish(), otherwise fd leak is possible. ++ * Resolves: GHSL-2021-077 ++ */ + +- if (data.caught_error) +- goto out; ++ if ( (dbus_call_respond_fails > 1) ) ++ { ++ // we got two faults, we can leave ++ goto out; ++ } ++ ++ if ((data.caught_error && (data.retrieved_pid || data.retrieved_uid))) ++ { ++ // we got one fault and the other call finally finished, we can leave ++ goto out; ++ } ++ ++ if ( !(data.retrieved_uid && data.retrieved_pid) ) ++ { ++ g_main_context_iteration (tmp_context, TRUE); ++ } ++ else ++ { ++ break; ++ } ++ } + + if (out_uid) + *out_uid = data.uid; diff --git a/system/base/polkit/files/polkit-0.118-duktape.patch b/system/base/polkit/files/polkit-0.118-duktape.patch index 4f572c1d..3c6b826a 100644 --- a/system/base/polkit/files/polkit-0.118-duktape.patch +++ b/system/base/polkit/files/polkit-0.118-duktape.patch @@ -64,9 +64,9 @@ index e48b739cc0a4e7606be0271ba4b4e3bd33b08545..9572b067effdf6f0dcd1c6b17b2e8c59 - $(LIBJS_CFLAGS) \ + $(LIBJS_CFLAGS) \ $(NULL) - + libpolkit_backend_1_la_CXXFLAGS = $(libpolkit_backend_1_la_CFLAGS) - + libpolkit_backend_1_la_LIBADD = \ $(GLIB_LIBS) \ + $(DUKTAPE_LIBS) \ @@ -76,7 +76,7 @@ index e48b739cc0a4e7606be0271ba4b4e3bd33b08545..9572b067effdf6f0dcd1c6b17b2e8c59 - $(LIBJS_LIBS) \ + $(LIBJS_LIBS) \ $(NULL) - + +if USE_DUKTAPE +libpolkit_backend_1_la_SOURCES += polkitbackendduktapeauthority.c +libpolkit_backend_1_la_LIBADD += -lm @@ -86,7 +86,7 @@ index e48b739cc0a4e7606be0271ba4b4e3bd33b08545..9572b067effdf6f0dcd1c6b17b2e8c59 + rulesdir = $(sysconfdir)/polkit-1/rules.d rules_DATA = 50-default.rules - + diff --git a/src/polkitbackend/polkitbackendduktapeauthority.c b/src/polkitbackend/polkitbackendduktapeauthority.c new file mode 100644 index 0000000000000000000000000000000000000000..ae984535ed88003ab1b0965e3e109a848479c047 diff --git a/system/base/polkit/pspec.xml b/system/base/polkit/pspec.xml index 0c350ca1..6fbccb57 100644 --- a/system/base/polkit/pspec.xml +++ b/system/base/polkit/pspec.xml @@ -14,7 +14,7 @@ app:console PolicyKit Authorization Framework polkit is a toolkit for defining and handling authorizations. It is used for allowing unprivileged processes to speak to privileged processes. - http://www.freedesktop.org/software/polkit/releases/polkit-0.119.tar.gz + http://www.freedesktop.org/software/polkit/releases/polkit-0.120.tar.gz python3 dbus-devel @@ -23,7 +23,7 @@ expat-devel duktape-devel gettext-devel - elogind-devel + gobject-introspection-devel intltool @@ -33,6 +33,8 @@ polkit-0.118-duktape.patch polkit-0.118-elogind.patch use-system-locale-in-gobject-api.diff + CVE-2021-4034.patch + CVE-2021-4115.patch @@ -92,6 +94,13 @@ + + 2022-07-05 + 0.120 + Version bump. + Mustafa Cinasal + muscnsl@gmail.com + 2021-09-22 0.119 @@ -99,14 +108,14 @@ Mustafa Cinasal muscnsl@gmail.com - + 2021-07-08 0.118 Rebuild. Mustafa Cinasal muscnsl@gmail.com - + 2021-06-08 0.118 Rebuild.