All of lore.kernel.org
 help / color / mirror / Atom feed
* prevent breaking a chroot() jail?
@ 2002-07-05 13:50 Shaya Potter
  2002-07-05 14:02 ` Miquel van Smoorenburg
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Shaya Potter @ 2002-07-05 13:50 UTC (permalink / raw)
  To: linux-kernel

I'm trying to develop a way to ensure that one can't break out of a
chroot() jail, even as root.  I'm willing to change the way the syscalls
work (most likely only for a subset of processes, i.e. processes that
are run in the jail end up getting a marker which is passed down to all
their children that causes the syscalls to behave differently).

What should I be aware of?  I figure devices (no need to run mknod in
this jail) and chroot (as per man page), is there any other way of
breaking the chroot jail (at a syscall level or otherwise)?

or is this 100% impossible?

thanks,

shaya




^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: prevent breaking a chroot() jail?
@ 2002-07-05 15:16 Hank Leininger
  2002-07-05 16:17 ` Ville Herva
  0 siblings, 1 reply; 18+ messages in thread
From: Hank Leininger @ 2002-07-05 15:16 UTC (permalink / raw)
  To: linux-kernel

On 2002-07-05, Shaya Potter <spotter@cs.columbia.edu> wrote:

> On Fri, 2002-07-05 at 10:02, Miquel van Smoorenburg wrote:
> > In article <1025877004.11004.59.camel@zaphod>,
> > Shaya Potter  <spotter@cs.columbia.edu> wrote:
> > > I'm trying to develop a way to ensure that one can't break out of a
> > > chroot() jail, even as root.  I'm willing to change the way the
[snip]
> > Run as root and you're out of the chroot jail. This is because
> > chroot() doesn't chdir() to the new root, so after a chroot() in
> > the chroot jail you're suddenly out of it.

> yes, that's what the man page says.  Is that the only hole? i.e. if one
> changed the semantics of chroot() to also do a chdir() to the new root,
> would that be fixed? (not arguing on changing this for everything, just
> for something specific)

No, there are many ways that root can break out of chroot(2).  I maintain
some patches[1] against 2.2 (and grsecurity[2] has ported most of them to
2.4) which aim to try to make it harder for root to break out of chroot(2),
but I won't say I've got them all--in fact I'll say I'm sure I *don't* have
them all, and I'd like to hear suggestions for more.  Here are some things
to worry about:

-chroot(2)'ing with an open directory fd
-prevent chroot(2) by a process already chrooted ("double-chroot")
-block mount(2) attempts inside chroot ("chroot(../..)" ...)
-block mknod of char or block devices inside chroot ("mknod /dev/hda",
   "mknod /dev/kmem")
-block chmod +s by a chrooted process
-block ptrace(2) by a chrooted process of processes outside the jail
-block most signals by a chrooted process to processes outside the jail
-block setting capabilities (capset) by a chrooted process of processes 
   outside the jail
-drop "dangerous" capabilities when chroot(2)'ing.  (See the patch, but
   basically, various *_ADMIN, *RAW*, etc to block ioctl, sysctl for
   dangerous things.)

One area I have not looked at sufficiently is sysv IPC (shared memory,
semaphores...).  It's quite possible that a chrooted process can tamper
with shared memory segments that other, outside-chroot processes are using
(especially if some app is designed to use them to communicate across the
chroot boundary; I don't know of any but they could exist) and use that
vector to attack and try to subvert the other, non-chrooted process(es).

I'd appreciate any suggestions in addition to the above, and/or holes poked
in the implementation (which I'm sure isn't the best...).

[1] http://www.theaimsgroup.com/~hlein/hap-linux/
[2] http://www.grsecurity.org/

Thanks,

--
Hank Leininger <hlein@progressive-comp.com> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2002-07-09 13:43 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-05 13:50 prevent breaking a chroot() jail? Shaya Potter
2002-07-05 14:02 ` Miquel van Smoorenburg
2002-07-05 14:37   ` Shaya Potter
2002-07-05 16:14     ` Jesse Pollard
2002-07-05 21:00     ` David Wagner
2002-07-05 22:26       ` Martin Josefsson
2002-07-05 14:15 ` Thunder from the hill
2002-07-05 15:17 ` Vance Lankhaar
2002-07-05 18:15 ` H. Peter Anvin
2002-07-05 18:45   ` Ville Herva
2002-07-05 21:15     ` Alan Cox
2002-07-05 21:48     ` Jeff Dike
2002-07-05 21:07       ` Ville Herva
2002-07-05 21:35 ` Alan Cox
2002-07-09  3:07 ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2002-07-05 15:16 Hank Leininger
2002-07-05 16:17 ` Ville Herva
2002-07-09 13:41   ` Bill Davidsen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.