* CLONE_NEWUSER|CLONE_FS root exploit
@ 2013-03-13 17:57 Kees Cook
2013-03-13 18:35 ` Eric W. Biederman
0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2013-03-13 17:57 UTC (permalink / raw)
To: ebiederm; +Cc: Sebastian Krahmer, linux-kernel
Hi,
It seem like we should block (at least) this combination. On 3.9, this
exploit works once uidmapping is added.
http://www.openwall.com/lists/oss-security/2013/03/13/10
-Kees
----- Forwarded message from Sebastian Krahmer <krahmer@suse.de> -----
Date: Wed, 13 Mar 2013 16:39:56 +0100
From: Sebastian Krahmer <krahmer@suse.de>
To: oss-security@lists.openwall.com
Subject: [oss-security] CLONE_NEWUSER|CLONE_FS root exploit
Envelope-To: kees@outflux.net
Hi,
Seems like CLONE_NEWUSER|CLONE_FS might be a forbidden
combination.
During evaluating the new user namespace thingie, it turned out
that its trivially exploitable to get a (real) uid 0,
as demonstrated here:
http://stealth.openwall.net/xSports/clown-newuser.c
The trick is to setup a chroot in your CLONE_NEWUSER,
but also affecting the parent, which is running
in the init_user_ns, but with the chroot shared.
Then its trivial to get a rootshell from that.
Tested on a openSUSE12.1 with a custom build 3.8.2 (x86_64).
I hope I didnt make anything wrong, mixing up the UIDs,
or disabled important checks during kernel build on my test
system. ;)
regards,
Sebastian
--
~ perl self.pl
~ $_='print"\$_=\47$_\47;eval"';eval
~ krahmer@suse.de - SuSE Security Team
----- End forwarded message -----
--
Kees Cook
Chrome OS Security
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: CLONE_NEWUSER|CLONE_FS root exploit
2013-03-13 17:57 CLONE_NEWUSER|CLONE_FS root exploit Kees Cook
@ 2013-03-13 18:35 ` Eric W. Biederman
2013-03-14 1:48 ` Andy Lutomirski
0 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2013-03-13 18:35 UTC (permalink / raw)
To: Kees Cook
Cc: Sebastian Krahmer, linux-kernel, Oleg Nesterov, Linux Containers
Kees Cook <keescook@chromium.org> writes:
> Hi,
>
> It seem like we should block (at least) this combination. On 3.9, this
> exploit works once uidmapping is added.
>
> http://www.openwall.com/lists/oss-security/2013/03/13/10
Yes. That is a bad combination. It let's chroot confuse privileged
processes.
Now to figure out if this is easier to squash by adding a user_namespace
to fs_struct or by just forbidding this combination.
Eric
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: CLONE_NEWUSER|CLONE_FS root exploit
2013-03-13 18:35 ` Eric W. Biederman
@ 2013-03-14 1:48 ` Andy Lutomirski
2013-03-14 20:29 ` Eric W. Biederman
0 siblings, 1 reply; 5+ messages in thread
From: Andy Lutomirski @ 2013-03-14 1:48 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Kees Cook, containers, Sebastian Krahmer,
Linux Kernel Mailing List, Oleg Nesterov
On 03/13/2013 11:35 AM, Eric W. Biederman wrote:
> Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> writes:
>
>> Hi,
>>
>> It seem like we should block (at least) this combination. On 3.9, this
>> exploit works once uidmapping is added.
>>
>> http://www.openwall.com/lists/oss-security/2013/03/13/10
>
> Yes. That is a bad combination. It let's chroot confuse privileged
> processes.
>
> Now to figure out if this is easier to squash by adding a user_namespace
> to fs_struct or by just forbidding this combination.
It's worth making sure that setns(2) doesn't have similar issues.
Looking through other shared-but-not-a-namespace things, there are:
fs_struct: Buggy as noted.
files_struct: Probably harmless -- SCM_RIGHTS can emulate it
signal_struct: This interacts with the tty code. Is it okay?
sighand_struct: Looks safe. Famous last words.
FWIW, I've been alarmed in the past that struct path (e.g. the root
directory) implies an mnt_namespace (hidden in struct mount), and it's
entirely possible for the root directory's mnt_namespace not to match
nsproxy->mnt_namespace. I'm not sure what the implications are, but
this doesn't seem healthy.
--Andy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: CLONE_NEWUSER|CLONE_FS root exploit
2013-03-14 1:48 ` Andy Lutomirski
@ 2013-03-14 20:29 ` Eric W. Biederman
2013-03-14 21:32 ` Andy Lutomirski
0 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2013-03-14 20:29 UTC (permalink / raw)
To: Andy Lutomirski
Cc: Kees Cook, containers, Sebastian Krahmer,
Linux Kernel Mailing List, Oleg Nesterov
Andy Lutomirski <luto@amacapital.net> writes:
> On 03/13/2013 11:35 AM, Eric W. Biederman wrote:
>> Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> writes:
>>
>>> Hi,
>>>
>>> It seem like we should block (at least) this combination. On 3.9, this
>>> exploit works once uidmapping is added.
>>>
>>> http://www.openwall.com/lists/oss-security/2013/03/13/10
>>
>> Yes. That is a bad combination. It let's chroot confuse privileged
>> processes.
>>
>> Now to figure out if this is easier to squash by adding a user_namespace
>> to fs_struct or by just forbidding this combination.
>
> It's worth making sure that setns(2) doesn't have similar issues.
setns(2) and unshare(2) are done and merged. See commit.
commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
Author: Eric W. Biederman <ebiederm@xmission.com>
Date: Wed Mar 13 11:51:49 2013 -0700
userns: Don't allow CLONE_NEWUSER | CLONE_FS
> Looking through other shared-but-not-a-namespace things, there are:
>
> fs_struct: Buggy as noted.
>
> files_struct: Probably harmless -- SCM_RIGHTS can emulate it
>
> signal_struct: This interacts with the tty code. Is it okay?
It should be. The tty code is heavily pid based, and CLONE_NEWPID
requires !CLONE_VM (which implies !CLONE_SIGHAND and !CLONE_VM).
> sighand_struct: Looks safe. Famous last words.
>
> FWIW, I've been alarmed in the past that struct path (e.g. the root
> directory) implies an mnt_namespace (hidden in struct mount), and it's
> entirely possible for the root directory's mnt_namespace not to match
> nsproxy->mnt_namespace. I'm not sure what the implications are, but
> this doesn't seem healthy.
The calls to check_mnt prevent abuse of the files found with fs_struct
not matching the current mount namespace.
static inline int check_mnt(struct mount *mnt)
{
return mnt->mnt_ns == current->nsproxy->mnt_ns;
}
Thanks for looking I know I did the same double take and wondered if I
had missed anything else by accident when this bug showed up.
So far even just looking it all over again I can't see anything. But I
have clearly been blind before.
Eric
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: CLONE_NEWUSER|CLONE_FS root exploit
2013-03-14 20:29 ` Eric W. Biederman
@ 2013-03-14 21:32 ` Andy Lutomirski
0 siblings, 0 replies; 5+ messages in thread
From: Andy Lutomirski @ 2013-03-14 21:32 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Kees Cook, containers, Sebastian Krahmer,
Linux Kernel Mailing List, Oleg Nesterov
On Thu, Mar 14, 2013 at 1:29 PM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
> Andy Lutomirski <luto@amacapital.net> writes:
>
>> On 03/13/2013 11:35 AM, Eric W. Biederman wrote:
>>> Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> writes:
>>>
>>>> Hi,
>>>>
>>>> It seem like we should block (at least) this combination. On 3.9, this
>>>> exploit works once uidmapping is added.
>>>>
>>>> http://www.openwall.com/lists/oss-security/2013/03/13/10
>>>
>>> Yes. That is a bad combination. It let's chroot confuse privileged
>>> processes.
>>>
>>> Now to figure out if this is easier to squash by adding a user_namespace
>>> to fs_struct or by just forbidding this combination.
>>
>> It's worth making sure that setns(2) doesn't have similar issues.
>
> setns(2) and unshare(2) are done and merged. See commit.
>
> commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
> Author: Eric W. Biederman <ebiederm@xmission.com>
> Date: Wed Mar 13 11:51:49 2013 -0700
>
> userns: Don't allow CLONE_NEWUSER | CLONE_FS
>
>
>> Looking through other shared-but-not-a-namespace things, there are:
>>
>> fs_struct: Buggy as noted.
>>
>> files_struct: Probably harmless -- SCM_RIGHTS can emulate it
>>
>> signal_struct: This interacts with the tty code. Is it okay?
>
> It should be. The tty code is heavily pid based, and CLONE_NEWPID
> requires !CLONE_VM (which implies !CLONE_SIGHAND and !CLONE_VM).
>
>> sighand_struct: Looks safe. Famous last words.
>>
>> FWIW, I've been alarmed in the past that struct path (e.g. the root
>> directory) implies an mnt_namespace (hidden in struct mount), and it's
>> entirely possible for the root directory's mnt_namespace not to match
>> nsproxy->mnt_namespace. I'm not sure what the implications are, but
>> this doesn't seem healthy.
>
> The calls to check_mnt prevent abuse of the files found with fs_struct
> not matching the current mount namespace.
>
> static inline int check_mnt(struct mount *mnt)
> {
> return mnt->mnt_ns == current->nsproxy->mnt_ns;
> }
>
> Thanks for looking I know I did the same double take and wondered if I
> had missed anything else by accident when this bug showed up.
>
> So far even just looking it all over again I can't see anything. But I
> have clearly been blind before.
This is way too fun. Got another one :/
I'll follow up in a sec off-list.
--Andy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-14 21:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-13 17:57 CLONE_NEWUSER|CLONE_FS root exploit Kees Cook
2013-03-13 18:35 ` Eric W. Biederman
2013-03-14 1:48 ` Andy Lutomirski
2013-03-14 20:29 ` Eric W. Biederman
2013-03-14 21:32 ` Andy Lutomirski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox