1 From a2bf5c9c83b6ae46cbd5c779d3055bff81ded683 Mon Sep 17 00:00:00 2001
2 From: Jan Rybar <jrybar@redhat.com>
3 Date: Tue, 25 Jan 2022 17:21:46 +0000
4 Subject: [PATCH] pkexec: local privilege escalation (CVE-2021-4034)
7 src/programs/pkcheck.c | 5 +++++
8 src/programs/pkexec.c | 23 ++++++++++++++++++++---
9 2 files changed, 25 insertions(+), 3 deletions(-)
11 diff --git a/src/programs/pkcheck.c b/src/programs/pkcheck.c
12 index f1bb4e1..768525c 100644
13 --- a/src/programs/pkcheck.c
14 +++ b/src/programs/pkcheck.c
15 @@ -363,6 +363,11 @@ main (int argc, char *argv[])
16 local_agent_handle = NULL;
24 /* Disable remote file access from GIO. */
25 setenv ("GIO_USE_VFS", "local", 1);
27 diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c
28 index 7698c5c..84e5ef6 100644
29 --- a/src/programs/pkexec.c
30 +++ b/src/programs/pkexec.c
31 @@ -488,6 +488,15 @@ main (int argc, char *argv[])
33 gpointer local_agent_handle;
37 + * If 'pkexec' is called THIS wrong, someone's probably evil-doing. Don't be nice, just bail out.
47 @@ -614,10 +623,10 @@ main (int argc, char *argv[])
49 path = g_strdup (pwstruct.pw_shell);
53 g_printerr ("No shell configured or error retrieving pw_shell\n");
57 /* If you change this, be sure to change the if (!command_line)
59 command_line = g_strdup (path);
60 @@ -636,7 +645,15 @@ main (int argc, char *argv[])
67 + /* argc<2 and pkexec runs just shell, argv is guaranteed to be null-terminated.
68 + * /-less shell shouldn't happen, but let's be defensive and don't write to null-termination
70 + if (argv[n] != NULL)
75 if (access (path, F_OK) != 0)