From: Colin Walters <walters@verbum.org>
To: "Serge E. Hallyn" <serge@hallyn.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
alan@lxorguk.ukuu.org.uk, morgan@kernel.org,
"Eric W. Biederman" <ebiederm@xmission.com>,
luto@mit.edu, kzak@redhat.com, Steve Grubb <sgrubb@redhat.com>
Subject: Re: chroot(2) and bind mounts as non-root
Date: Mon, 12 Dec 2011 11:41:28 -0500 [thread overview]
Message-ID: <1323708089.29338.39.camel@lenny> (raw)
In-Reply-To: <20111210052945.GA14931@hallyn.com>
On Sat, 2011-12-10 at 05:29 +0000, Serge E. Hallyn wrote:
> First, what you are after is an explicit goal of user namespaces: to
> be able to change the environment without risk of fooling privileged
> setuid programs with that environment.
Hmm...so I looked at the user namespace stuff
( https://wiki.ubuntu.com/UserNamespace ) and it kind of scares me in
terms of complexity. I think I understand the intersection of cgroups,
capabilities, and SELinux as they are today; this would be a whole new
set of options. But that's an aside.
> And, thereby, to allow unprivileged
> users to clone namespaces and, in new namespaces, freely muck with the
> resources they own or create. However, they're not quite usable yet.
So I'm assuming the actual high level goal of user namespaces is more
secure "containers" where you can run a mostly unmodified General
Purpose Linux system which includes setuid binaries, creating new users
etc., right?
If that's the case then my use case is much smaller - I don't need to be
able to run setuid binaries, or in fact change user ids at all.
A tool like this would make my life *so* much better that I'm trying
hard to use existing kernel features.
> So regarding your use of securebits: You are preventing a setuid-root
> program from automatically acquiring capabilities, which is a good
> start. However, a setuid-root program will still execute as root (or
> a setuid-mysql program as setuid-mysql). That means it will own
> root (or mysql) files while it is running.
Oh, very good point. I should have noticed that =/
But it was pretty trivial to modify my tool to make a MS_NOSUID bind
mount over /:
mount (NULL, "/", "none", MS_PRIVATE | MS_REMOUNT | MS_NOSUID,
NULL);
That's hopefully enough to plug that hole (right?), albeit not in a
beautiful way. I would be happier with a prctl to turn off suid
binaries entirely.
Oh...ok, digging farther back in here from the thread Andy started I see
Eric proposed a patch for exactly this:
https://lkml.org/lkml/2009/12/30/265
Ok, I've now read most of the back threads for this - I should have
searched farther back for previous discussion, sorry.
> Second, programs with file capabilities -a
> more finegrained alternative to setuid-root - will still run with
> privilege. You could prevent that by not allowing xattrs I suppose.
Looks to me like the MS_NOSUID bind mount prevents acquisition of file
capabilities too.
I experimented with dropping all capabilities from the capability
bounding set, but the API seems a bit lame in that CAP_LAST_CAP is
encoded in the kernel capability.h, but if an old binary is run on a new
kernel, I might silently fail to drop a newly added capability. Right?
Steve Grubb's "libcap-ng" appears to not handle this scenario at all;
Steve, am I missing something?
Anyways, in the big picture here I think this tool is now pretty safe to
install suid root, since we rely on MS_NOSUID to close all privilege
escalation mechanisms today from plugging in a USB drive, which is
effectively "user controls arbitrary filesystem layout".
But getting in Eric's patch for disabling suid binaries from a process
tree would be really nice. Alan, do you still object? Your main issue
seemed to be that it should be in a LSM, but the suid issue does span
existing LSMs. And as far as adding restrictions introduces new attack
vectors, pretty much all of those are abusing suid binaries, precisely
what we just want to axe off entirely.
next prev parent reply other threads:[~2011-12-12 16:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-07 17:54 Colin Walters
2011-12-07 19:36 ` John Stoffel
2011-12-08 16:10 ` Colin Walters
2011-12-08 18:14 ` John Stoffel
2011-12-08 18:26 ` Colin Walters
2011-12-09 0:49 ` Sven-Haegar Koch
2011-12-09 14:55 ` John Stoffel
2011-12-09 15:06 ` Colin Walters
2011-12-08 17:04 ` Arnd Bergmann
2011-12-08 17:15 ` Colin Walters
2011-12-07 19:40 ` Andy Lutomirski
2011-12-08 16:58 ` Colin Walters
2011-12-07 20:34 ` H. Peter Anvin
2011-12-07 20:54 ` Alan Cox
2011-12-15 18:55 ` Andrew G. Morgan
2011-12-16 15:44 ` Colin Walters
2011-12-18 1:22 ` Andrew G. Morgan
2011-12-18 15:19 ` Colin Walters
2011-12-10 5:29 ` Serge E. Hallyn
2011-12-12 16:41 ` Colin Walters [this message]
2011-12-12 23:11 ` Serge E. Hallyn
2011-12-15 20:56 ` Colin Walters
2011-12-16 6:14 ` Eric W. Biederman
2011-12-18 16:01 ` Colin Walters
2011-12-19 0:55 ` Eric W. Biederman
2011-12-19 4:06 ` Serge E. Hallyn
2011-12-19 9:22 ` Eric W. Biederman
2011-12-20 16:49 ` Colin Walters
2011-12-20 21:23 ` Colin Walters
2011-12-21 18:15 ` Steve Grubb
2012-01-03 23:13 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323708089.29338.39.camel@lenny \
--to=walters@verbum.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=ebiederm@xmission.com \
--cc=kzak@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@mit.edu \
--cc=morgan@kernel.org \
--cc=serge@hallyn.com \
--cc=sgrubb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome