All of lore.kernel.org
 help / color / mirror / Atom feed
From: Solar Designer <solar@openwall.com>
To: Matt Brown <matt@nmatt.com>
Cc: kernel-hardening@lists.openwall.com
Subject: Re: [kernel-hardening] Re: [PATCH v2 1/1] Add Trusted Path Execution as a stackable LSM
Date: Tue, 13 Jun 2017 23:27:04 +0200	[thread overview]
Message-ID: <20170613212704.GA16726@openwall.com> (raw)
In-Reply-To: <94ba5ebb-952b-2037-799e-07306629a6f9@nmatt.com>

Matt,

I removed most CC's like before, as I don't want my voice on this to be
too loud.

On Thu, Jun 08, 2017 at 11:50:32PM -0400, Matt Brown wrote:
> On 06/08/2017 10:38 PM, Kees Cook wrote:
> >On Wed, Jun 7, 2017 at 8:43 PM, Matt Brown <matt@nmatt.com> wrote:
> >>*  Issues:
> >>   *  Can be bypassed by interpreted languages such as python. You can run
> >>      malicious code by doing: python -c 'evil code'
> >
> >What's the recommendation for people interested in using TPE but
> >having interpreters installed?
> 
> If you don't need a given interpreter installed, uninstall it. While
> this is common sense system hardening it especially would make a
> difference under the TPE threat model.
> 
> I don't have a knock down answer for this. Interpreters are a hard
> problem for TPE.

Interpreters are only a tip of the iceberg.

With TPE, every program invocation becomes similar to a SUID/SGID one as
it relates to TPE's newly introduced security barrier.  However, the
dynamic linker and libc have no idea of this, and will happily grant
arbitrary code execution in context of those programs via LD_PRELOAD and
such.  Even if this is somehow dealt with (how would you do that in the
kernel alone? filter typical env var names? it quickly becomes way too
hackish and blacklistish, thus imperfect), then there's still:

I think many, and maybe most, binaries on a system will contain buffer
overflows and such that also allow for arbitrary code execution.  Those
programs were not written as carefully as SUID/SGID ones are supposed to
be.  They don't treat their input and environment as untrusted.

Closer to the topic of interpreters, there's also this old trick:

$ strace -e execve /lib/ld-linux.so.2 /bin/uname -ms
execve("/lib/ld-linux.so.2", ["/lib/ld-linux.so.2", "/bin/uname", "-ms"], [/* 28 vars */]) = 0
Linux i686
+++ exited with 0 +++

As you can see, the only execve(2) is of the dynamic linker.  Will /lib
or/and /lib64 be among trusted paths in a typical setup?  Well, maybe
not, although not including them will break ldd(1) on the more security
conscious distros, where it uses a similar trick of invoking the dynamic
linker explicitly (rather than the historical unsafe way of invoking the
binary being ldd'ed with some env vars set to tell its dynamic linker to
do the magic rather than proceed to execute the program).

But this last one is relatively minor.  The real big issue is that TPE
is either inherently fairly easily bypassable (and should be documented
as such) via many of the installed programs (by far not just explicit
interpreters, but also any programs containing "weird machines", which
is probably most non-trivial programs out there, and some trivial ones),
or it relies on all programs in the trusted paths being written as if
they were SUID/SGID (unrealistic for non-trivial systems).

Just so that you know what you're getting into, and so that you don't
mislead your users.

Alexander

  parent reply	other threads:[~2017-06-13 21:27 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08  3:43 [kernel-hardening] [PATCH v2 0/1] Add Trusted Path Execution as a stackable LSM Matt Brown
2017-06-08  3:43 ` Matt Brown
2017-06-08  3:43 ` Matt Brown
2017-06-08  3:43 ` [kernel-hardening] [PATCH v2 1/1] " Matt Brown
2017-06-08  3:43   ` Matt Brown
2017-06-08  3:43   ` Matt Brown
2017-06-08 13:05   ` [kernel-hardening] " Solar Designer
2017-06-08 13:16     ` Matt Brown
2017-06-09  2:38   ` [kernel-hardening] " Kees Cook
2017-06-09  2:38     ` Kees Cook
2017-06-09  2:38     ` Kees Cook
2017-06-09  3:50     ` [kernel-hardening] " Matt Brown
2017-06-09  3:50       ` Matt Brown
2017-06-09  3:50       ` Matt Brown
2017-06-09 10:18       ` [kernel-hardening] " Mimi Zohar
2017-06-09 10:18         ` Mimi Zohar
2017-06-09 10:18         ` Mimi Zohar
2017-06-09 12:55         ` [kernel-hardening] " Kees Cook
2017-06-09 12:55           ` Kees Cook
2017-06-09 12:55           ` Kees Cook
2017-06-09 13:15           ` [kernel-hardening] " Matt Brown
2017-06-09 13:15             ` Matt Brown
2017-06-09 13:15             ` Matt Brown
2017-06-09 13:16           ` [kernel-hardening] " Mimi Zohar
2017-06-09 13:16             ` Mimi Zohar
2017-06-09 13:16             ` Mimi Zohar
2017-06-09 13:18             ` [kernel-hardening] " Matt Brown
2017-06-09 13:18               ` Matt Brown
2017-06-09 13:44               ` Mimi Zohar
2017-06-09 13:44                 ` Mimi Zohar
2017-06-13 21:27       ` Solar Designer [this message]
2017-06-13 23:53         ` Mickaël Salaün
2017-06-14 12:36           ` Solar Designer
2017-06-14 13:15         ` Jann Horn
2017-06-14 14:28           ` Solar Designer
2017-06-14 14:33             ` Jann Horn
2017-06-14 14:34               ` Jann Horn
2017-06-14 16:24         ` Matt Brown
2017-06-16  2:25   ` kbuild test robot
2017-06-16  2:25     ` kbuild test robot
2017-06-16  2:25     ` kbuild test robot
2017-06-16  2:25   ` [kernel-hardening] [RFC PATCH] print_tpe_error() can be static kbuild test robot
2017-06-16  2:25     ` kbuild test robot
2017-06-16  2:25     ` kbuild test robot
2017-06-08 18:37 ` [kernel-hardening] Re: [PATCH v2 0/1] Add Trusted Path Execution as a stackable LSM Alan Cox
2017-06-08 18:37   ` Alan Cox
2017-06-08 18:37   ` Alan Cox
2017-06-08 19:01   ` [kernel-hardening] " Matt Brown
2017-06-08 19:01     ` Matt Brown
2017-06-08 19:01     ` Matt Brown
2017-06-08 19:23     ` [kernel-hardening] " Alan Cox
2017-06-08 19:23       ` Alan Cox
2017-06-08 19:23       ` Alan Cox
2017-06-11 11:30     ` [kernel-hardening] " Mickaël Salaün
2017-06-11 11:30       ` Mickaël Salaün
2017-06-12  0:04       ` [kernel-hardening] " Matt Brown
2017-06-12  0:04         ` Matt Brown
2017-06-12  0:04         ` Matt Brown

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=20170613212704.GA16726@openwall.com \
    --to=solar@openwall.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=matt@nmatt.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.