All of lore.kernel.org
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: Serge Hallyn <serge.hallyn@canonical.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Andrew G. Morgan" <morgan@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	Kees Cook <keescook@chromium.org>,
	James Morris <james.l.morris@oracle.com>,
	Eric Paris <eparis@redhat.com>,
	"Serge E. Hallyn" <serge@canonical.com>,
	Markku Savela <msa@moth.iki.fi>,
	Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [RFC] Capabilities still can't be inherited by normal programs
Date: Thu, 06 Dec 2012 16:57:50 -0800	[thread overview]
Message-ID: <50C13F0E.5010401@schaufler-ca.com> (raw)
In-Reply-To: <20121205222040.GB14884@sergelap>

On 12/5/2012 2:20 PM, Serge Hallyn wrote:
> Quoting Andy Lutomirski (luto@amacapital.net):
>> On Wed, Dec 5, 2012 at 1:05 PM, Serge Hallyn <serge.hallyn@canonical.com> wrote:
>>> Quoting Andy Lutomirski (luto@amacapital.net):
>>>> On Tue, Dec 4, 2012 at 5:54 AM, Serge E. Hallyn <serge@hallyn.com> wrote:
>>>>> Quoting Andy Lutomirski (luto@amacapital.net):
>>>>>>>> d) If I really wanted, I could emulate execve without actually doing
>>>>>>>> execve, and capabilities would be inherited.
>>>>>>> If you could modify the executable properties of the binary that has
>>>>>>> the privilege to wield a privilege then you are either exploiting an
>>>>>>> app bug, or doing something the privileged binary has been trusted to
>>>>>>> do.
>>>>>> That's not what I mean.  I would:
>>>>>>
>>>>>> fork()
>>>>>> munmap everything
>>>>>> mmap ld.so
>>>>>> set up a fake initial stack and the right fd or mapping or whatever
>>>>>> just to ld-linux.so
>>>>>>
>>>>>> That's almost execve, and privilege inheritance works.
>>>>> But of course that is why you only want to fill fI on programs you trust
>>>>> not to do that.  What you are arguing is that you want to give fI on
>>>>> programs you don't trust anyway, and so heck why not just give it on
>>>>> everything.
>>>>>
>>>> Huh?  I'd set fP on a program I expect to do *exactly* that (or use
>>>> actual in-kernel capability inheritance, which I would find vastly
>>>> more pleasant).  If I give a program a capability (via fP or fI & pI),
>>>> then I had better trust it not to abuse that capability.  Having it
>>>> pass that capability on to a child helper process would be just fine
>>>> with me *because it already has that capability*.
>>>>
>>>> The problem with the current inheritance mechanism is that it's very
>>>> difficult to understand what it means for an fI bit or a pI bit to be
>>>> set.  Saying "set a pI bit using pam if you want to grant permission
>>>> to that user to run a particular program with fI set" is crap -- it
>>>> only works if there is exactly one binary on the system with that bit
>>>> set.  In any case, a different administrator or package might use it
>>>> for something different.
>>>>
>>>> Suppose I use the (apparently) current suggested approach: I install a
>>>> fI=cap_net_raw copy of tcpdump somewhere.  Then I write a helper that
>>>> has fP=cap_new_raw and invokes that copy of tcpdump after appropriate
>>>> validation of parameters.  All is well.
>>> Since you're writing a special helper, you can surely have it validate
>>> the userid and make it so the calling user doesn't have to have
>>> cap_net_raw in pI?
>> I can and did.
> Oh, oops, I mis-understood what you meant was the problem.
>
> Yup, that is a real limitation.
>
> Yes, with the posix file caps you will be disappointed unless you see
> pI=X as "this user may run any program which is Inh-trusted with X" and
> fI=X as "this program may be run with X by any user Inh-trusted with X".
>
> It almost makes me want to say that there should be an execve-analogue
> to prctl(PR_SET_KEEPCAPS), which says caps will remain unchanged for one
> execve.  Or perhaps an intermediate securebits state between
> !SECBIT_NOROOT and SECBIT_NOROOT, which automatically transitions after
> the first execve to SECBIT_NOROOT.
>
>> The mere presence of a cap_net_raw+i tcpdump binary is more or less
>> equivalent to saying that users with cap_net_raw in pI can capture
>> packets.  I've just prevented pI=cap_net_raw from meaning anything
>> less than "can capture packets".  So I think we should bite the bullet
>> and just let programs opt in (via some appropriately careful
>> mechanism) to real capability inheritance.
> By real you mean more precise.  I think it'd be very interesting to get
> together with Markku and learn more from the N9 experiment!
>
> Markku, are there any post-mortem analysis papers we can read for
> starters?  Andy would not be trying to restrict root in general, so
> the ramification you cited may not necessarily be relevant.
>
> -serge

http://wt.tuxomania.net/publications/posix.1e/download.html

Everyone should read the capabilities rationale. It answers most
of the questions on this thread, and a bunch more. The capabilities
mechanism has to support what are currently setuid-root programs
without change and allow for new programs that use the mechanism
wisely and fully.


> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


  reply	other threads:[~2012-12-07  0:58 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-02  3:04 [RFC] Capabilities still can't be inherited by normal programs Andy Lutomirski
2012-12-02 17:21 ` Andrew G. Morgan
2012-12-02 18:35   ` Andy Lutomirski
2012-12-02 22:26     ` Andrew G. Morgan
2012-12-02 23:04       ` Andy Lutomirski
2012-12-03  2:20         ` Andrew G. Morgan
2012-12-03  4:48           ` Andy Lutomirski
2012-12-04 13:54             ` Serge E. Hallyn
2012-12-05 19:32               ` Andy Lutomirski
2012-12-05 20:12                 ` Markku Savela
2012-12-05 21:05                 ` Serge Hallyn
2012-12-05 21:46                   ` Andy Lutomirski
2012-12-05 22:20                     ` Serge Hallyn
2012-12-07  0:57                       ` Casey Schaufler [this message]
2012-12-07 14:42                         ` Serge E. Hallyn
2012-12-07 17:00                           ` Casey Schaufler
2012-12-07 17:07                           ` Andrew G. Morgan
2012-12-07 18:39                             ` Andy Lutomirski
2012-12-08 22:33                               ` Andrew G. Morgan
2012-12-08 23:37                                 ` Andy Lutomirski
2012-12-08 23:57                                   ` Andy Lutomirski
2012-12-12 18:29                                     ` Andy Lutomirski
2012-12-12 18:45                                       ` Serge Hallyn
2012-12-19 13:14                                       ` Pádraig Brady
2012-12-10 14:59                                   ` Serge Hallyn
2012-12-10 15:47                                     ` Casey Schaufler
2012-12-10 16:27                                       ` Serge Hallyn
2012-12-10 18:12                                       ` Andy Lutomirski
2012-12-10 19:13                                         ` Casey Schaufler
2012-12-10 19:31                                           ` Andy Lutomirski
2012-12-10 19:51                                             ` Casey Schaufler
2012-12-10 19:55                                               ` Andy Lutomirski
2012-12-10 20:17                                                 ` Kees Cook
2012-12-10 18:05                                     ` Andy Lutomirski
2012-12-10 14:36                                 ` Serge Hallyn
     [not found]                           ` <CALQRfL6UWLFpTfvan9oirtLdozJqZX4oZwDuQFVnJp8MP06C_Q@mail.gmail.com>
2012-12-10 14:27                             ` Serge Hallyn

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=50C13F0E.5010401@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=eparis@redhat.com \
    --cc=james.l.morris@oracle.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=morgan@kernel.org \
    --cc=msa@moth.iki.fi \
    --cc=serge.hallyn@canonical.com \
    --cc=serge@canonical.com \
    --cc=serge@hallyn.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.