From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 6 21:24:21 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 99FE51065673; Wed, 6 Jun 2012 21:24:21 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 3552E8FC1A; Wed, 6 Jun 2012 21:24:21 +0000 (UTC) Received: from toad.stack.nl (toad.stack.nl [IPv6:2001:610:1108:5010::135]) by mx1.stack.nl (Postfix) with ESMTP id 850A21DD5BB; Wed, 6 Jun 2012 23:24:20 +0200 (CEST) Received: by toad.stack.nl (Postfix, from userid 1677) id 7C6023F444; Wed, 6 Jun 2012 23:24:20 +0200 (CEST) Date: Wed, 6 Jun 2012 23:24:20 +0200 From: Jilles Tjoelker To: Pawel Jakub Dawidek Message-ID: <20120606212420.GA84474@stack.nl> References: <4FCC126C.1020600@shatow.net> <20120605213101.GA13339@stack.nl> <20120606112011.GB1381@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120606112011.GB1381@garage.freebsd.pl> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-hackers@freebsd.org, Bryan Drewery Subject: Re: [RFC] last(1) with security.bsd.see_other_uids support X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jun 2012 21:24:21 -0000 On Wed, Jun 06, 2012 at 01:20:12PM +0200, Pawel Jakub Dawidek wrote: > On Tue, Jun 05, 2012 at 11:31:01PM +0200, Jilles Tjoelker wrote: > > Also, the attack surface of such a daemon may be smaller than that of a > > setuid/setgid program. > Really? I don't see that. With current patch and setgid to utmp the > process can only read some files that don't even contain very sensitive > data (like passwords). > Any privileged daemon is much bigger threat. Also, do we really want a > daemon running all the time just to be able to parse utx files? The daemon would run with non-root privileges just sufficient to read the utmpx files. If we have a good way to start it, the attack surface is limited to what you can do with its socket and this can be cut down tightly. On the other hand, an attacker can control various process attributes of a setgid program such as the output file, a subset of signals, rlimits and a subset of environment variables. For example, last, w and who have some degree of locale support (time/date formats). Also, in this particular case, dropping privileges does not help much since the utmpx file descriptor is almost as valuable as the group credentials. I agree that leaving a daemon running for this is ugly. > > Alternatively, the daemon could be a setgid program that is spawned by > > the utmpx APIs when needed. > Still seems a bit too far for my taste. Spawning a daemon somewhere from > within library doesn't sound like a good idea to me... At least until we > have something like launchd that can start such services on demand. The suggested approach is used by old implementations of grantpt(). If the kernel does not set up the ownership of a new pseudo terminal properly, grantpt() can invoke a setuid root binary, for example /usr/libexec/pt_chown. Similarly, the utmpx APIs might invoke a setgid helper if they cannot read the files themselves. Communication would be over a pipe. This has the downside of having a setgid program at all but things like locale support are handled by the calling (unprivileged) application and not by the setgid program. -- Jilles Tjoelker