public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Sharing credentials in general (Re: [GIT PULL] kdbus for 4.1-rc1)
@ 2015-04-23 19:41 Andy Lutomirski
  2015-04-23 21:05 ` Linus Torvalds
  2015-04-27 13:01 ` Djalal Harouni
  0 siblings, 2 replies; 12+ messages in thread
From: Andy Lutomirski @ 2015-04-23 19:41 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Greg Kroah-Hartman, Andrew Morton, Arnd Bergmann,
	Eric W. Biederman, One Thousand Gnomes, Tom Gundersen,
	Jiri Kosina, linux-kernel@vger.kernel.org, Daniel Mack,
	David Herrmann, Djalal Harouni

On Thu, Apr 23, 2015 at 11:48 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> On Thu, Apr 23, 2015 at 10:57 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>> Same goes for uid etc - if you are implementing a service daemon, the
>> uid of the requester sure as hell makes a ton of difference in what
>> you might want to expose. Things like "does this user have access
>> rights to the printer?" are very natural questions to ask.
>
> Hmm. Looking at the code, it strikes me that not only does
> kdbus_meta_proc_collect() collect too much, but some of what it
> collects it just seems to do *wrong*.
>
> So I agree with collecting user and credential information (obviously
> unlike some people ;), but I think the code that does it is just
> wrong.

Can I try again, this time without reference to the rest of this
thread from hell?

Let's say I have a shiny kdbus system.  I'm generally okay with my
printer daemon finding out that the Angry Penguins app I'm printing
from is uid 1000, that it has the admin's blessing to print, and even
that it's in such-and-such cgroup.  That's not why I dislike this.

Objection 1: This thing is omnidirectional.  I'm much less convinced
that it's okay for Angry Penguins or its associated ad network to find
out that the printer daemon is uid 38, that it's in cgroup
such-and-such, or that the printer daemon has the admin's permission
to feed the walruses.

Objection 2: There's a difference between the printer daemon knowing
that Angry Penguins has general permission to print and an explicit
assertion by Angry Penguins of its permission to print.  Suppose that
printing is implemented by having Angry Penguins call the method Write
on some kdbus thing.  Suppose further that changing root's password is
implemented by having the caller call the method Write on some other
kdbus thing.  Before changing the password, the password daemon makes
sure that the caller (or the caller's kdbus conn or whatever) has
password-changing permissions.  Before printing, the printer daemon
makes sure that the caller has printing permissions.

In kdbus, this is IMO a big problem.  See, I can try to find some
setuid root program that takes a printer object as input (however
kdbus might do this -- presumably it would be an object name) and
calls Write to print some diagnostic thing.  Now I just feed it the
password-changing thingy as input and I can get it to "print" to the
root password.  Oops.

With sensible APIs, this problem goes away.  If the actual API were:

call_a_method(object, method name, args, privileges to assert);

then it's a big red flag when a program calls:

call_a_method(untrusted_object, "Write", untrusted_data, all_my_privileges);

This is just like how open(untrusted_path) is bad news and everyone
knows it, whereas write(untrusted_fd, untrusted_data, len) is supposed
to be fine (see, for example, stdout in every setuid program ever).

In the model where system services get to know the identity of the
callers (ok so far) and where every single method call allows the
service to know every possible credential of the caller (kdbus with
sd-bus) and where those credentials are used for authentication
(probably every kdbus daemon ever), it follows that every method call
asserts every possible permission, and we're screwed.

As you pointed out with cmdline, it's not so easy to disentangle
knowledge of some attribute of a caller with use of that attribute as
authorization.  So, if we give all the system daemons (and Angry
Pigeons!) the ability to know the credentials of their callers on all
method calls, then they'll use it for authorization, and now all
privileges are potentially dangerous merely to possess for all method
calls.

IMO we need an API where assertion of a privilege is Totally Obviously
Explicit And Clearly A Thing You Only Do With Careful Thought And Is
Expressed As Such In A Method Call ().  SCM_CREDENTIALS gets this
wrong, and so does kdbus (and especially sd-bus).

(Alternatively, in a capability-based security model, access to the
password setting object *is* the permission to set passwords, and
there are no implicit/ambient privileges at all, so this is all moot.)

--Andy

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Sharing credentials in general (Re: [GIT PULL] kdbus for 4.1-rc1)
@ 2015-04-27  5:38 George Spelvin
  0 siblings, 0 replies; 12+ messages in thread
From: George Spelvin @ 2015-04-27  5:38 UTC (permalink / raw)
  To: luto, torvalds; +Cc: linux, linux-kernel

Linus wrote:
> It would be insane to say that the open system call should have an
> explicit argument saying that the vfs layer should take your privileges
> into account.

On the contrary, it would be a big improvement on the current interface.

To be clearer, it would be great if the open system call took an explicit
argument saying *which* privileges it should take into account.

All that screwing around with uid, euid and fsuid and crap would be
a lot simpler if it was explicit in the open() call which permissions
were desired.

In my "If I had a time machine and could go back and talk to Ken & Dennis"
fantasy, there would be no open(), only openat(), and the permissions
would be associated with the dirfd.

In addition to the now-current standard three fds, there would be
additional ones for root and cwd.  And, in a setuid program,
a separate set for effective uids.

So openat(fd, path, flags) would use the real or effective permissions
depending on which fd was in use.  A process could drop permissions
by closing the associated fd.  Etc.

(And a program which was written without setuid awareness would only
use the real-uid dirfds, and the setuidness would do nothing.)

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

end of thread, other threads:[~2015-05-03 19:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-23 19:41 Sharing credentials in general (Re: [GIT PULL] kdbus for 4.1-rc1) Andy Lutomirski
2015-04-23 21:05 ` Linus Torvalds
2015-04-23 22:08   ` Andy Lutomirski
2015-04-27  8:17     ` David Herrmann
2015-04-27 14:57       ` One Thousand Gnomes
2015-04-27 15:50         ` David Herrmann
2015-04-27 16:13           ` Andy Lutomirski
2015-04-27 16:33             ` David Herrmann
2015-05-02  1:48               ` Andy Lutomirski
2015-05-03 19:43                 ` Havoc Pennington
2015-04-27 13:01 ` Djalal Harouni
  -- strict thread matches above, loose matches on Subject: below --
2015-04-27  5:38 George Spelvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox