Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbbGIW4t (ORCPT ); Thu, 9 Jul 2015 18:56:49 -0400 Received: from smtp103.biz.mail.bf1.yahoo.com ([98.139.221.62]:27521 "EHLO smtp103.biz.mail.bf1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbbGIW4j (ORCPT ); Thu, 9 Jul 2015 18:56:39 -0400 X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: M47f9L0VM1kKocsZOE2YiwbDd.ZTCDuzSlRA.cBti321G1a XNe63Dc8GSNATwIPf0jkH_t0KFuPDvySw3ChWpwTqpfV_Yt4.2a4VUhYJFOK vo5KM5.WVWTS5wGOQgzPfETnVfvfpowmWvwusauu0IsYru0O5OnZJFM2118z S57JYyZtWu4vmGCOtRozpukd1jXAunFtoyfpj98aTf8_XKIW7fGnpHCEHjmy IvvmLoTCOXBJy0rgaZLQdtQdZm7.lhxgQqHchXRNszOZD9UbIurFr1xtNhoO rVLfwIqMBD9Y8RXSCZXrAAJlrsHO.ipx9LgGsH3IOGcQqhrmvoVS7KF9iUPP bRgpGWBH4SPbypPhHTQLrcsjXlua5AaxK6guIg7jhu.tg09_L5CsP.VODvHA TMY9EiG.D63fBDGyR1aPyXa7VRHPuVYqacFp57dpuzBBH0yphuJfxPWKoA1c EM5Qv.y.nNEw8Nhg7jvpqrZ4e22.zjnYSvRy97M8AGI7NxDIG9ZwBtbXGOh2 rsfJhnhCkZqUn5wMt.qxruTShYbSvWQ-- X-Yahoo-SMTP: OIJXglSswBDfgLtXluJ6wiAYv6_cnw-- Message-ID: <559EFC24.5050705@schaufler-ca.com> Date: Thu, 09 Jul 2015 15:56:36 -0700 From: Casey Schaufler User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: David Herrmann , Stephen Smalley CC: Greg KH , Daniel Mack , Djalal Harouni , lkml , LSM , Paul Osmialowski , Paul Moore Subject: Re: kdbus: credential faking References: <559EBCC0.7040604@tycho.nsa.gov> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4838 Lines: 101 On 7/9/2015 3:22 PM, David Herrmann wrote: > Hi > > On Thu, Jul 9, 2015 at 8:26 PM, Stephen Smalley wrote: >> Hi, >> >> I have a concern with the support for faked credentials in kdbus, but >> don't know enough about the original motivation or intended use case to >> evaluate it concretely. I raised this issue during the "kdbus for >> 4.1-rc1" thread a while back but none of the kdbus maintainers >> responded, > Sorry, some mails might have been gone unanswered in that huge thread. > Please feel free to ping us about anything we didn't comment on. See > below.. > >> and the one D-BUS maintainer who did respond said that there >> is no API in dbus-daemon for faking client credentials, so this is not >> something inherited from dbus-daemon or required for compatibility with it. >> >> First, I have doubts as to whether there should be any way to fake the >> seclabel, no matter how "privileged" the caller. Unless there is a >> clear use case for that functionality, I would prefer to see it dropped >> altogether. >> >> Second, IIUC, the ability to fake any portion of the credentials or pids >> is granted if the caller either has CAP_IPC_OWNER or owns the bus (uid >> match). Clearly that isn't sufficient basis for seclabel faking, and it >> seems questionable as to whether it should be sufficient for faking any >> of the other credentials or pids. Compare with e.g. >> net/core/scm.c:scm_check_creds() logic for faking credentials on a Unix >> domain socket, which requires CAP_SYS_ADMIN for faking pid, CAP_SETUID >> for faking any of the uid fields, and CAP_SETGID for faking any of the >> gid fields. >> >> Thanks for any light you can shed on the matter. > To be clear, faking metadata has one use-case, and one use-case only: > dbus1 compatibility > > In dbus1, clients connect to a unix-socket placed in the file-system > hierarchy. To avoid breaking ABI for old clients, we support a > unix-kdbus proxy. This proxy is called systemd-bus-proxyd. It is > spawned once for each bus we proxy and simply remarshals messages from > the client to kdbus and vice versa. > > With dbus1, clients can ask the dbus-daemon for the seclabel of a peer > they talk to. They're free to use this information for any purpose. On > kdbus, we want to be compatible to dbus-daemon. Therefore, if a native > client queries kdbus for the seclabel of a peer behind a proxy, we > want that query to return the actual seclabel of the peer, not the > seclabel of the proxy. Same applies to PIDS and CREDS. > > This faked metadata is never used by the kernel for any security > decisions. It's sole purpose is to return them if a native kdbus > client queries another peer. Furthermore, this information is never > transmitted as send-time metadata (as it is, in no way, send-time > metadata), but only if you explicitly query the connection-time > metadata of a peer (KDBUS_CMD_CONN_INFO). > > Regarding requiring CAP_SYS_ADMIN, I don't really see the point. In > the kdbus security model, if you don't trust the bus-creator, you > should not connect to the bus. That's fine in a discretionary access control model, but not in a mandatory access control model. The decision on trust of the "other" guy is never up to the process, it's up to the mandatory access control policy. > A bus-creator can bypass kdbus > policies, sniff on any transmission and modify bus behavior. It just > seems logical to bind faked-metadata to the same privilege. However, I > also have no strong feeling about that, if you place valid points. So > please elaborate. Smack has to require CAP_MAC_ADMIN to allow a process to fake Smack metadata. This is exactly what CAP_MAC_ADMIN is for. Changing Smack metadata is considered a hugely dangerous activity. > But, please be aware that if we require privileges to fake metadata, > then you need to have such privileges to provide a dbus1 proxy for > your native bus on kdbus. In other words, users are able to create > session/user buses, but they need CAP_SYS_ADMIN to spawn the dbus1 > proxy. This will have the net-effect of us requiring to run the proxy > as root (which, I think, is worse than allowing bus-owners to fake > _connection_ metadata). I disagree with you strongly. Allowing a bus owner to fake connection metadata is insane. If you're going to allow it it should frigging well require privilege. You're allowing the program to *lie* about information that an unsuspecting client may use to make important decisions. Go ahead and cry "backward compatibility". Two wrongs don't make a right. > > Thanks > David > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/