~peter-pearse/ubuntu/oneiric/policykit-1/prop001

« back to all changes in this revision

Viewing changes to debian/patches/00git-pkexec-information-disclosure.patch

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-04-09 12:09:53 UTC
  • Revision ID: james.westby@ubuntu.com-20100409120953-kvyaz7oeb0x1lz3q
Tags: 0.96-2
* Urgency medium, just two small, but important bug fixes.
* Add 00git-pkexec-information-disclosure.patch: Fix information disclosure
  vulnerability that allows an attacker to verify whether or not arbitrary
  files exist, violating directory permissions.
* 00git-fix-error-freeing.patch: Fix crash when calling CheckAuthorization()
  with an invalid PID. (LP: #540464)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 14bdfd816512a82b1ad258fa143ae5faa945df8a Mon Sep 17 00:00:00 2001
 
2
From: Dan Rosenberg <dan.j.rosenberg@gmail.com>
 
3
Date: Wed, 10 Mar 2010 12:46:19 -0500
 
4
Subject: [PATCH 1/2] =?UTF-8?q?Bug=2026982=20=E2=80=93=20pkexec=20information=20disclosure=20vulnerability?=
 
5
MIME-Version: 1.0
 
6
Content-Type: text/plain; charset=UTF-8
 
7
Content-Transfer-Encoding: 8bit
 
8
 
 
9
pkexec is vulnerable to a minor information disclosure vulnerability
 
10
that allows an attacker to verify whether or not arbitrary files
 
11
exist, violating directory permissions. I reproduced the issue on my
 
12
Karmic installation as follows:
 
13
 
 
14
 $ mkdir secret
 
15
 $ sudo chown root:root secret
 
16
 $ sudo chmod 400 secret
 
17
 $ sudo touch secret/hidden
 
18
 $ pkexec /home/drosenbe/secret/hidden
 
19
 (password prompt)
 
20
 $ pkexec /home/drosenbe/secret/doesnotexist
 
21
 Error getting information about /home/drosenbe/secret/doesnotexist: No such
 
22
 file or directory
 
23
 
 
24
I've attached my patch for the issue. I replaced the stat() call
 
25
entirely with access() using F_OK, so rather than check that the
 
26
target exists, pkexec now checks if the user has permission to verify
 
27
the existence of the program. There might be another way of doing
 
28
this, such as chdir()'ing to the parent directory of the target and
 
29
calling lstat(), but this seemed like more code than necessary to
 
30
prevent such a minor problem.  I see no reason to allow pkexec to
 
31
execute targets that are not accessible to the executing user because
 
32
of directory permissions. This is such a limited use case anyway that
 
33
this doesn't really affect functionality.
 
34
 
 
35
http://bugs.freedesktop.org/show_bug.cgi?id=26982
 
36
 
 
37
Signed-off-by: David Zeuthen <davidz@redhat.com>
 
38
---
 
39
 src/programs/pkexec.c |    5 ++---
 
40
 1 files changed, 2 insertions(+), 3 deletions(-)
 
41
 
 
42
diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c
 
43
index 860e665..17c191e 100644
 
44
--- a/src/programs/pkexec.c
 
45
+++ b/src/programs/pkexec.c
 
46
@@ -411,7 +411,6 @@ main (int argc, char *argv[])
 
47
   gchar *opt_user;
 
48
   pid_t pid_of_caller;
 
49
   uid_t uid_of_caller;
 
50
-  struct stat statbuf;
 
51
 
 
52
   ret = 127;
 
53
   authority = NULL;
 
54
@@ -520,9 +519,9 @@ main (int argc, char *argv[])
 
55
       g_free (path);
 
56
       argv[n] = path = s;
 
57
     }
 
58
-  if (stat (path, &statbuf) != 0)
 
59
+  if (access (path, F_OK) != 0)
 
60
     {
 
61
-      g_printerr ("Error getting information about %s: %s\n", path, g_strerror (errno));
 
62
+      g_printerr ("Error accessing %s: %s\n", path, g_strerror (errno));
 
63
       goto out;
 
64
     }
 
65
   command_line = g_strjoinv (" ", argv + n);
 
66
-- 
 
67
1.7.0
 
68