From owner-freebsd-arch@FreeBSD.ORG Tue Jan 2 23:07:55 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F153716A403; Tue, 2 Jan 2007 23:07:55 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id C6AF213C45E; Tue, 2 Jan 2007 23:07:55 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 72B0049717; Tue, 2 Jan 2007 18:07:55 -0500 (EST) Date: Tue, 2 Jan 2007 23:07:55 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Colin Percival In-Reply-To: <4599E57C.5090904@freebsd.org> Message-ID: <20070102230111.M7974@fledge.watson.org> References: <459745DA.1010801@freebsd.org> <20061231124431.GG97921@submonkey.net> <4599E57C.5090904@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Ceri Davies , "freebsd-arch@freebsd.org" Subject: Re: default value of security.bsd.hardlink_check_[ug]id X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2007 23:07:56 -0000 On Mon, 1 Jan 2007, Colin Percival wrote: > Ceri Davies wrote: >> On Sat, Dec 30, 2006 at 09:08:42PM -0800, Colin Percival wrote: >>> I'd like to make security.bsd.hardlink_check_[ug]id default to 1, starting >>> with FreeBSD 7.x. This would make it impossible for a user to create a hard >>> link to a file which he does not own. >> >> a) you have provided no rationale; > > Allowing users to create hard links to files which they do not own creates > problems: > 1. If disk quotas are enabled, a user can waste another user's disk quota by > making it impossible for said other user to delete files. > 2. It becomes difficult to apply security fixes for issues involving setuid > binaries, since a local attacker could create hard links to all the setuid > binaries (or at least those on filesystems where he can write somewhere) and > wait for a security issue to be found. I find the second argument here most compelling, and use it as an example frequently when complaining about hard links. Hard links also one of the elements that makes it difficult to usefully generate names for file system objects, due to their introducing ambiguity. > I honestly can't see why it was ever possible for users to create hard links > to files which they don't own; hopefully someone can provide the historical > background and tell me if the original reasons (whatever they were) still > apply. It's generally consistent with the world view that says names of objects are property of the directory they appear in. In terms of history: remember that before there was rename(), there were link() and unlink(), and if you want to give users who own directories the right to rename within those directories, that required the ability to link() and unlink(). That model is quite consistent, but interacts poorly with the way users, and especially administrators, expect the system to work. > If it isn't possible to outlaw such hard linking entirely, I'd like to make > it impossible by default for > (a) a user to create a hard link to a setuid file which they do not own, and > (b) a user to create a hard link to a setgid file if they are not in the right > group, > since these are the important cases for security. I think we should give the change in defaults (after cleaning up the implementation per bde's and my comments) for the sysctl a trial run in 7-CURRENT for a few months and see what breaks. If we get lots of complaints, we can back out the change, refine it, etc. History suggests that this isn't a foolproof way to find problems (remember how long it took to shake out changes in signaling protection), but it may well turn up something useful. Robert N M Watson Computer Laboratory University of Cambridge