From: Djalal Harouni <tixxdz@opendz.org>
To: kernel-hardening@lists.openwall.com
Cc: Kees Cook <keescook@chromium.org>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Solar Designer <solar@openwall.com>
Subject: Re: [kernel-hardening] procfs: infoleaks and DAC permissions
Date: Sun, 12 Feb 2012 01:19:52 +0100 [thread overview]
Message-ID: <20120212001952.GA1574@dztty> (raw)
In-Reply-To: <20120210143616.GA6100@albatros>
On Fri, Feb 10, 2012 at 06:36:17PM +0400, Vasiliy Kulikov wrote:
> Hi,
>
> On Fri, Feb 10, 2012 at 03:06 +0100, Djalal Harouni wrote:
> > At least there are two issues for the procfs:
> >
> > 1) Infoleaks via self-read by a suid/guid:
> > As noted in the thread [1], this probably affects most of the procfs
> > seq files.
> > - fd = open(/proc/self/maps...)
> > - exec a setuid program
> > - fd = /proc/pid_of_setuid/maps
> > (due to the 'task_struct' and 'mm_struct' lookup logic).
> > - read data from fd, this will pass ptrace_may_access() check.
> > - setuid program gives data.
>
> AFAICS, it affects not only seq files, but every file: you can open
> /proc/self/* and pass it to a setuid binary.
Yes, brobably.
> > 2) DAC permissions and suid/guid/privileged programs (userspace):
> > This is a list of files that are supposed to be protected:
> > /proc/<pid>/maps
> > /proc/<pid>/numa_maps
> > /proc/<pid>/smaps
> > /proc/<pid>/pagemap Page table
> > /proc/<pid>/personality
> > /proc/<pid>/stack Enbled by CONFIG_STACKTRACE
> > /proc/<pid>/syscall
> > more... ?
> [...]
> > A partial fix for this (2):
> > Procfs 'hidepid=' mount option which can be used to restrict access to
> > arbitrary /proc/<pid>/ files, Vasiliy commit [3], congrats.
> > But if the procfs 'gid=' mount option is used then it can give permissions
> > back to read these files if the user is part of the 'gid' group. IOW this
> > will just restore the previous vulnerable situation.
>
> It is even weaker - you could trick setuid $SPID to open /proc/$PID/maps,
> do exec(setuid_app) as $PID and read setuid_app's maps as $SPID.
Well, if I understand that patch correctly, when procfs is mounted with
'hidepid' and without 'gid', the fix should be in the setuid application
which opens arbitrary files, right ?
My point is that open() is called by unprivileged code and it will
succeed.
>> These files should just follow DAC and be 0400, I know about glibc
>> breakage. At least files that do not break glibc should be 0400 and
>> prevent self-read infoleak.
> It doesn't work as I've showed above.
I think that I'm missing something.
> [...]
> I cannot find any solution of (2) except actually add ptrace check at
> open() time... Looks like we have to check what specific action glibc
> does with /proc/$pid/maps and whitelist these idiotic actions. I hope
Seems fine with ptrace, perhaps we can also make some files 'S_IRUSR'.
> it is not arbitrary reads :-)
Currently it is:
# chmod u+s /usr/bin/wall
$ ./procfs_leak /usr/bin/wall /proc/1/maps
...
7fcf6930b000-7fcf69328000 r-xp 00000000 08:06 652945
/sbin/
init
7fcf69527000-7fcf69529000 r--p 0001c000 08:06 652945
/sbin/
init
7fcf69529000-7fcf6952a000 rw-p 0001e000 08:06 652945
/sbin/
init
7fcf6b226000-7fcf6b2c4000 rw-p 00000000 00:00 0
[heap]
7fff0e916000-7fff0e937000 rw-p 00000000 00:00 0
[stack]
...
As I've said, one just need to find the appropriate program (not especially
setuid root), I did not bother to search.
> [1] http://grsecurity.net/~spender/dev_patches/distros_should_sponsor_me_for_doing_their_jobs.patch
Yes this patch should protect current configs of distros from (1).
Still some files, especially the writable ones.
Thank you for your input.
> Thanks,
>
> --
> Vasiliy Kulikov
> http://www.openwall.com - bringing security into open computing environments
--
tixxdz
http://opendz.org
next prev parent reply other threads:[~2012-02-12 0:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 2:06 [kernel-hardening] procfs: infoleaks and DAC permissions Djalal Harouni
2012-02-10 14:36 ` Vasiliy Kulikov
2012-02-11 9:20 ` Solar Designer
2012-02-11 10:21 ` Vasiliy Kulikov
2012-02-11 13:31 ` Solar Designer
2012-02-12 0:19 ` Djalal Harouni [this message]
2012-02-21 14:56 ` Solar Designer
2012-02-21 16:25 ` Djalal Harouni
2012-02-21 17:42 ` Solar Designer
2012-02-24 0:56 ` Solar Designer
2012-02-25 3:56 ` Solar Designer
2012-03-03 0:35 ` Djalal Harouni
2012-02-21 16:34 ` Djalal Harouni
2012-02-11 10:07 ` Solar Designer
2012-02-12 15:36 ` Djalal Harouni
2012-02-13 15:50 ` Djalal Harouni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120212001952.GA1574@dztty \
--to=tixxdz@opendz.org \
--cc=Jason@zx2c4.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=solar@openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.