mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: LD_PRELOAD and RTLD_NEXT support
Date: Tue, 16 Aug 2011 08:59:17 -0400	[thread overview]
Message-ID: <20110816125917.GP132@brightrain.aerifal.cx> (raw)
In-Reply-To: <20110816124600.GA15681@albatros>

On Tue, Aug 16, 2011 at 04:46:00PM +0400, Vasiliy Kulikov wrote:
> On Tue, Aug 16, 2011 at 07:47 -0400, Rich Felker wrote:
> > > 1) This check should be extended to support AT_SECURE (dumpable flag,
> > > any LSM security domains, capabilities).
> > 
> > Indeed, I'll add this. Do I just check for aux[AT_SECURE] != 0?
> 
> Looks like so.
> 
> glibc has some crazy dance with these flags and get*id() values, which
> we patch in Owl ;-)

Well glibc tries to be clever and let you use LD_PRELOAD with suid as
long as the library is in a "trusted" path and has the sgid bit set.
To me this seems really misguided; the valid use cases are very few,
and it seems impossible to predict all the future kernel
"enhancements" that might create gaping holes in whatever method you
use to validate... In my opinion, the only safe thing to do when
running with elevated privileges is to completely ignore anything the
user controls in the initial environment.

> ....btw, I feel it would be cleaner if you check for untrusted environment
> at the time of initializing env_* variables.  Currently there is not
> much code between env_X assignment and zeroing, but it might be in the
> future (with addition of ld features, etc.).
> 
>     for (p = argv+i; ... ) {
>         if (is_secure_env)
>             env_path = ...

Notice the problem is that this code is in the loop that's responsible
for *finding* auxv. For now I've just moved the code closer together,
but if you think it would help, I might first load the env vars into
temp variables and switch the conditionals for secure mode, so that
env_* would never get loaded in the suid/sgid/caps case.

Rich


  reply	other threads:[~2011-08-16 12:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-16  5:17 Rich Felker
2011-08-16  6:34 ` Vasiliy Kulikov
2011-08-16 11:47   ` Rich Felker
2011-08-16 12:46     ` Vasiliy Kulikov
2011-08-16 12:59       ` Rich Felker [this message]
2011-08-22 17:02       ` env vars in SUID/SGID programs (was: LD_PRELOAD and RTLD_NEXT support) Solar Designer
2011-08-22 18:13         ` Rich Felker

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=20110816125917.GP132@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).