From: jca+dash-oD5z7zAif+Mdnm+yROfE0A@public.gmane.org (Jérémie Courrèges-Anglas)
To: Tavis Ormandy <taviso-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: Jilles Tjoelker <jilles-bQi0YA1h5vk@public.gmane.org>,
Harald van Dijk <harald-8ZdJMhgJluOEVqv0pETR8A@public.gmane.org>,
dash-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
oss-security-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org
Subject: Re: [PATCH] implement privmode support in dash
Date: Fri, 23 Aug 2013 13:13:07 +0200 [thread overview]
Message-ID: <874nag7j98.fsf@shannon.wxcvbn.org> (raw)
In-Reply-To: <CAJ_zFkJEb02d8Xs=RcWnRT7JbgDUYiAwMUUc3WFAfXr1ZN-0DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> (Tavis Ormandy's message of "Thu, 22 Aug 2013 13:42:32 -0700")
Tavis Ormandy <taviso-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> writes:
> On Thu, Aug 22, 2013 at 1:35 PM, Jilles Tjoelker <jilles-bQi0YA1h5vk@public.gmane.org> 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.
pdksh is only maintained by OpenBSD, afaik (mksh syncs regularly).
The current code rather looks like this:
if (f == FPRIVILEGED && oldval && !newval) {
gid_t gid = getgid();
setresgid(gid, gid, gid);
setgroups(1, &gid);
setresuid(ksheuid, ksheuid, ksheuid);
} ...
> 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.
--
jca | PGP: 0x06A11494 / 61DB D9A0 00A4 67CF 2A90 8961 6191 8FBF 06A1 1494
next prev parent reply other threads:[~2013-08-23 11:13 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
[not found] ` <CAJ_zFkJEb02d8Xs=RcWnRT7JbgDUYiAwMUUc3WFAfXr1ZN-0DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-23 11:13 ` Jérémie Courrèges-Anglas [this message]
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=874nag7j98.fsf@shannon.wxcvbn.org \
--to=jca+dash-od5z7zaif+mdnm+yrofe0a@public.gmane.org \
--cc=dash-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=harald-8ZdJMhgJluOEVqv0pETR8A@public.gmane.org \
--cc=jilles-bQi0YA1h5vk@public.gmane.org \
--cc=oss-security-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org \
--cc=taviso-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
/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).