dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tavis Ormandy <taviso@google.com>
To: Jilles Tjoelker <jilles@stack.nl>
Cc: Harald van Dijk <harald@gigawatt.nl>,
	dash@vger.kernel.org, oss-security@lists.openwall.com
Subject: Re: [PATCH] implement privmode support in dash
Date: Thu, 22 Aug 2013 13:42:32 -0700	[thread overview]
Message-ID: <CAJ_zFkJEb02d8Xs=RcWnRT7JbgDUYiAwMUUc3WFAfXr1ZN-0DQ@mail.gmail.com> (raw)
In-Reply-To: <20130822203500.GA21467@stack.nl>

On Thu, Aug 22, 2013 at 1:35 PM, Jilles Tjoelker <jilles@stack.nl> wrote:
> I think there is no reason to deviate from other shells here. Therefore,
> please call it "privileged".
>

Agreed.

>> In bash and FBSD, after starting with -p, set +p can be used to drop
>> privileges. With your patch, dash accepts set +p, but silently ignores it.
>
>> How does something like the attached, to be applied on top of your
>> patch, look?
>
>> [snip]
>> +     if (!on && (uid != geteuid() || gid != getegid())) {
>> +             setuid(uid);
>> +             setgid(gid);
>> +             /* PS1 might need to be changed accordingly. */
>> +             choose_ps1();
>> +     }
>> +}
>
> This code tries to use setuid() and setgid() to drop all privilege,
> which is only correct if the privilege to be dropped is UID 0, or on BSD
> systems. It would be better to use setresuid() or setreuid(), and change
> the GID before changing the UID.

This is logic duplicated from pdksh and bash, I'm slightly reluctant
to do things differently, unless it's not going to get committed
otherwise.

You can see some code snippets here:
http://blog.cmpxchg8b.com/2013/08/security-debianisms.html

> Apart from that, it is better to check the return value from setuid()
> and similar functions. In particular, some versions of Linux may fail
> setuid() for [EAGAIN], leaving the process running with the same
> privileges.

I don't think this is true anymore, but I have no strong objection to
adding it, so long as it's noted that bash and pdksh do not do this.

Tavis.

  reply	other threads:[~2013-08-22 20:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-22 17:59 [PATCH] implement privmode support in dash Tavis Ormandy
2013-08-22 19:59 ` Harald van Dijk
2013-08-22 20:05   ` Tavis Ormandy
2013-08-22 20:35   ` Jilles Tjoelker
2013-08-22 20:42     ` Tavis Ormandy [this message]
     [not found]       ` <CAJ_zFkJEb02d8Xs=RcWnRT7JbgDUYiAwMUUc3WFAfXr1ZN-0DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-23 11:13         ` Jérémie Courrèges-Anglas
2013-08-23 11:40       ` Jérémie Courrèges-Anglas
2013-08-23 14:23         ` Roy
2013-08-23  3:31 ` [oss-security] " Kurt Seifried
2013-08-23  8:36   ` Tavis Ormandy
2013-08-23  9:36   ` Florian Weimer

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='CAJ_zFkJEb02d8Xs=RcWnRT7JbgDUYiAwMUUc3WFAfXr1ZN-0DQ@mail.gmail.com' \
    --to=taviso@google.com \
    --cc=dash@vger.kernel.org \
    --cc=harald@gigawatt.nl \
    --cc=jilles@stack.nl \
    --cc=oss-security@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.
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).