All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael C Thompson <thompsmc@us.ibm.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Daniel J Walsh <dwalsh@redhat.com>,
	SE Linux <selinux@tycho.nsa.gov>,
	jdesai@us.ibm.com
Subject: Re: [RFC PATCH] newrole suid breakdown
Date: Thu, 05 Oct 2006 11:07:21 -0500	[thread overview]
Message-ID: <45252DB9.4000506@us.ibm.com> (raw)
In-Reply-To: <1160059227.2132.88.camel@moss-spartans.epoch.ncsc.mil>

Stephen Smalley wrote:
> On Wed, 2006-10-04 at 17:17 -0500, Michael C Thompson wrote:
>>  From what I have seen, the points of possible attack (i.e. input) to 
>> newrole include:
>> * command line options
>> * reading the password from stdin
>> * reading the contents of /etc/passwd and /etc/shell
>>
>> I doubt this is an exhaustive list. Since /etc/passwd and /etc/shell are 
>> restricted to root-only write, I've discounted these. Since we require 
>> PAM to do namespaces, which will cause PAM to handle the password check, 
>> we should be able to defer any vulnerabilities to PAM, and I would hope 
>> that PAM is secure.
>>
>> This leaves command line options. These are parsed with getopt_long, and 
>> are currently passed into libselinux without any scrubbing. Since 
>> SELinux doesn't apply a limit on the length of its context strings, is 
>> there any checks that need to be done before handing these strings into 
>> libselinux?
> 
> I don't think so.  The larger concern is not the command line arguments
> but the environment.  glibc does some automatic sanitization of the
> environment for setuid programs, but is limited in what it can do.
> You likely want to save the environment or portions of it for
> propagation to the newrole'd shell, reset the environment to a clean
> state for newrole itself, and then invoke the user shell with the
> previously saved environment.  Look at other setuid programs, like su
> and sudo, as possible examples.   Also see:
> http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/environment-variables.html
> 
> Since pam_namespace further executes a script (namespace.init), the
> environment is especially critical, and you need to consider the
> implications of how the shell handles setuid execution.  For example,
> unless namespace.init invokes /bin/sh with the -p option (privileged
> mode), bash will reset the effective identities to the real identities
> during startup, such that the script itself will run in the caller's
> identity (and thus likely fail if it tries to do its job, like bind
> mounting the .X11-unix directory into the member directory, as well as
> creating any files or directories in the caller's uid).  If you change
> namespace.init to use the -p option, then bash will leave the effective
> identities alone, and will ignore certain aspects of the environment
> that would normally affect it.  One might argue that pam_namespace
> itself should do some environment cleansing, since it executes a script
> and this won't be immediately obvious to all potential users of
> pam_namespace.
> 
>> The cleanup process for errors within newrole currently does not make a 
>> call to pam_end (after pam_start). Is this an issue? There are also 
>> other cases where cleanup isn't really handled as nicely as it could. 
>> Since this is a user-space app, a lot of cleanup is handled by the 
>> kernel, but I do have some patches that go a ways to begin cleaning this 
>> sort of thing up. Are they desirable?
> 
> Yes.

OK, shall I merge these changes into 1 large patch? or how would you 
like this delivered? I can do some seperate smaller patches, which take 
care of cleanup, and then those that take care of adding suid related 
changes.

>> I have tested all 4 ways of compiling newrole (no priv, AUDIT_LOG_PRIV, 
>> NAMESPACE_PRIV, LSPP_PRIV (both)), and it functions as expected.
> 
> Did you check the effective identity and capability sets at each stage
> of execution to see if they were what you expected?  Within newrole
> after each change?  On entry to pam_namespace?  On entry to
> namespace.init?  In the newrole'd shell?

I have run this with debug output (omitted from my patches) and yes the 
capabilities, uid and euid are all as I expected them to be. I did not 
check the capabilities on entrance to namespace.init since I would 
require rebuilding pam_namespace.so, I can do this if desired. From 
looking at the code, it didn't look like pam_namespace did anything to 
the capabilities or uids, but I'm only human, so I could be wrong.

> Also, I'm not clear on how this resolves the issue of being able to have
> a single newrole binary in a distribution, and of not requiring any
> additional exposure for systems that do not require the privileged
> functionality, which Dan also noted.

Yes, I basically glossed over that requirement in my mind.



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  reply	other threads:[~2006-10-05 16:07 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-04 22:17 [RFC PATCH] newrole suid breakdown Michael C Thompson
2006-10-05 13:57 ` Daniel J Walsh
2006-10-05 14:42   ` Michael C Thompson
2006-10-05 14:52     ` Daniel J Walsh
2006-10-05 15:46       ` Michael C Thompson
2006-10-05 17:56         ` Stephen Smalley
2006-10-05 14:58     ` Stephen Smalley
2006-10-05 15:55       ` Michael C Thompson
2006-10-05 18:39         ` Stephen Smalley
2006-10-05 19:53           ` Michael C Thompson
2006-10-05 20:12             ` Stephen Smalley
2006-10-05 20:47               ` Michael C Thompson
2006-10-05 21:48                 ` Steve Grubb
2006-10-06 14:52                   ` Stephen Smalley
2006-10-06 15:16                     ` Russell Coker
2006-10-06 15:22                     ` Linda Knippers
2006-10-06 15:22                     ` Michael C Thompson
2006-10-06 15:36                       ` Steve Grubb
2006-10-06 15:49                       ` Stephen Smalley
2006-10-06 15:34                     ` Steve Grubb
2006-10-06 16:14                       ` Stephen Smalley
2006-10-06 17:08                         ` Daniel J Walsh
2006-10-06 17:13                           ` Stephen Smalley
2006-10-05 23:15   ` Russell Coker
2006-10-06 17:01     ` Daniel J Walsh
2006-10-06 17:37       ` Russell Coker
2006-10-06 18:50         ` Daniel J Walsh
2006-10-06 18:54         ` Stephen Smalley
2006-10-06 19:03           ` Russell Coker
2006-10-06 21:36           ` Michael C Thompson
2006-10-06 21:50             ` Stephen Smalley
2006-10-05 14:40 ` Stephen Smalley
2006-10-05 16:07   ` Michael C Thompson [this message]
2006-10-05 17:40     ` Stephen Smalley
2006-10-05 20:10   ` Michael C Thompson
2006-10-05 20:24     ` Stephen Smalley
2006-10-05 20:42       ` Michael C Thompson

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=45252DB9.4000506@us.ibm.com \
    --to=thompsmc@us.ibm.com \
    --cc=dwalsh@redhat.com \
    --cc=jdesai@us.ibm.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /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.