linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
[parent not found: <fa.f26d55g.1qgijbi@ifi.uio.no>]
[parent not found: <fa.n4rmmgg.2423pm@ifi.uio.no>]
[parent not found: <fa.f4bs2b4.fhub0m@ifi.uio.no>]
* Re: posix capabilities inheritance
@ 2003-10-23  1:41 Albert Cahalan
  0 siblings, 0 replies; 19+ messages in thread
From: Albert Cahalan @ 2003-10-23  1:41 UTC (permalink / raw)
  To: linux-kernel mailing list; +Cc: luto

Andy Lutomirski writes:

> I agree with these problems, but I think the proper
> fix is complicated.  AFAICT, POSIX capability
> evolution, as specified by whatever draft it was,
> is broken, so the hacks in prepare_binprm
> (cap_bprm_set_security in 2.6) are needed to avoid 
> security problems.  Aside from the fact that
> non-inheritable-by-default makes little sense
> (and requires root to get capabilities re-added
> from the file _permitted_ set), POSIX cap
> evolution has some other problems:

You've noticed!  :-)

The people who wrote the code were working from
two different drafts of the spec. I think some
people used draft 16, while others used draft 17.
(or 15 and 16, or 17 and 18 -- a difference of 1)
Between these two drafts there had been BIG changes.
Well, a critical equation changed.

People at SGI, mindlessly cloning the IRIX code,
stuck us with the half-ass set of capability bits
we have today. They ignored the DG-UX implementation
using 256 bits and slightly different equations.
They ignored the fact that the security model will
be terribly inconsistent if you still have apps
making UID-based decisions -- that is, you need to
allocate bits for glibc, XFree86, Linux vendors,
admin tools, various databases, and local site usage.
Yes it's yucky, but it's required. Covering ears
and burying the head won't make this go away.

Nobody thought to have half the bits default
to "on" for stuff currently allowed for regular
users. For example, the right to listen for
incoming network connections could be limited
if this had been given a default-enabled bit.

Then there's the emergency hack done to patch a
security hole that the capability bits introduced.
I think that was back in the early 2.4.x days.

People like to ignore the fact that apps tend
to answer "Do I need setuid-style precautions?"
by examining UID.

People like to ignore the fact that privileged
code, written with setuid in mind, can lead to
all sorts of mayhem if 42% of the privileged
operations are prohibited. Yeah, you'd hope
that a setuid app has great error checking and
can cope... but "hope" shouldn't satisfy you.
We really need a way for app authors to mark a
binary as "always block rights P, Q, and R" and
"block all rights unless given V, W, and X",
with the assumption that an unmarked app requires
an all-or-none situation.

Probably there should be two worlds on the
system. Apps with "funny" rights should be
kept away from UID 0 and setuid apps, while
apps with UID 0 or setuid should be kept
away from "funny" rights. Give the init
process a special ability to cross worlds.

The authors of our code seem to have given up
and moved on. Nobody cleaned up the mess.
Is it any wonder the POSIX draft didn't ever
make it beyond the draft state?

(and damn, WTF is with !capable(...) meaning
that you are capable of performing something?)

One final horror: just imagine trying to write
up some sane documentation for the average admin.
Poorly-understood security mechanisms are a
hazard. BTW, don't forget to imagine documenting
all the interactions with UID, filesystems, etc.

Face it: admins will think in terms of assigning
rights to users, never minding that there are
some weird equations, UID interactions, and
perhaps per-executable bits.



^ permalink raw reply	[flat|nested] 19+ messages in thread
[parent not found: <fa.f9mv0tb.27sf3j@ifi.uio.no>]
[parent not found: <fa.f36f4t9.1rg8j3v@ifi.uio.no>]
* posix capabilities inheritance
@ 2003-10-21 11:26 Michael Glasgow
  2003-10-23 16:46 ` Theodore Ts'o
  0 siblings, 1 reply; 19+ messages in thread
From: Michael Glasgow @ 2003-10-21 11:26 UTC (permalink / raw)
  To: linux-kernel

I wrote a simple setuid-root wrapper which sets some capabilities, 
gives up all other privs, and and then execs a shell.  I was hoping
to use this wrapper as a login shell so that I could have a user  
log in interactively with a small subset of elevated privileges.

Unfortunately after looking over the capabilities code in the 2.4
kernel, it would appear that this is not currently possible, and
my wrapper cannot work without filesystem support for capabilities.
And even then, I'd have to set each file's inheritable flag for the
capabilities I want on every executable that I am likely to run,
including the shell.  Am I mising something, or is this an accurate
description?

I think I understand the rationale behind this behavior; the draft
posix 1003.1e specification states:

     The purpose of assigning capability states to files is
     to provide the exec() function with information regarding
     the capabilities that any process image created with the
     program in the file is capable of dealing with and have
     been granted by some authority to use.

So, the lack of an inheritable flag on a file can serve to prevent
that file from executing with the corresponding capability enabled.

Fine, but what about my semi-superuser shell situation?  How can
I force the retention of a capability set across exec() for all
executables?  It would seem that neither the spec nor the current
implementation in the 2.4 kernel allow for this, but it strikes
me as a pretty reasonable and useful thing to do in some cases.

As an interim workaround, how about assuming all capabilities are
inheritable in fs/exec.c:prepare_binprm, i.e. instead of
cap_clear(bprm->cap_inheritable), call cap_set_full() ???  I don't
think this would break anything, and it would make capabilities a
lot more useful until we get fs support merged in.

-- 
Michael Glasgow < glasgow at beer dot net >

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2003-10-25 19:52 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <fa.hehull9.10mmngt@ifi.uio.no>
2003-10-21 18:24 ` posix capabilities inheritance Andy Lutomirski
     [not found] <fa.f26d55g.1qgijbi@ifi.uio.no>
     [not found] ` <fa.hq0dft9.9i0obd@ifi.uio.no>
2003-10-24 21:24   ` Andy Lutomirski
     [not found] <fa.n4rmmgg.2423pm@ifi.uio.no>
     [not found] ` <fa.l1oevhb.1s5k583@ifi.uio.no>
2003-10-24  8:44   ` Andy Lutomirski
2003-10-24 12:41     ` Theodore Ts'o
2003-10-24 16:44       ` Andy Lutomirski
2003-10-24 20:58         ` David Wagner
     [not found] <fa.f4bs2b4.fhub0m@ifi.uio.no>
2003-10-23 22:05 ` Michael Glasgow
2003-10-23 22:59   ` Theodore Ts'o
2003-10-24  1:36   ` Ernie Petrides
2003-10-24  2:19     ` Bernd Eckenfels
2003-10-24  5:10       ` Ernie Petrides
2003-10-25 19:51     ` Pavel Machek
2003-10-23  1:41 Albert Cahalan
     [not found] <fa.f9mv0tb.27sf3j@ifi.uio.no>
2003-10-23  1:36 ` Michael Glasgow
2003-10-23  1:57   ` Andy Lutomirski
     [not found] <fa.f36f4t9.1rg8j3v@ifi.uio.no>
2003-10-22  7:11 ` Michael Glasgow
2003-10-22 19:40   ` Andy Lutomirski
  -- strict thread matches above, loose matches on Subject: below --
2003-10-21 11:26 Michael Glasgow
2003-10-23 16:46 ` Theodore Ts'o

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).