public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* can chroot be made safe for non-root?
@ 2002-10-16  5:51 Eric Buddington
  2002-10-16  6:44 ` Philippe Troin
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Eric Buddington @ 2002-10-16  5:51 UTC (permalink / raw)
  To: linux-kernel

I am eager to be able to sandbox my processes on a system without the
help of suid-root programs (as I prefer to have none of these on my
system).

Would it be reasonable to allow non-root processes to chroot(), if the
chroot syscall also changed the cwd for non-root processes?

Is there a reason besides standards compliance that chroot() does not
already change directory to the chroot'd directory for root processes?
Would it actually break existing apps if it did change the directory?

-Eric
(who wishes there were better ways to run untrusted code)

^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: can chroot be made safe for non-root?
@ 2002-10-17  5:08 Niels Provos
  0 siblings, 0 replies; 24+ messages in thread
From: Niels Provos @ 2002-10-17  5:08 UTC (permalink / raw)
  To: Eric Buddington; +Cc: marius, linux-kernel

>I am eager to be able to sandbox my processes on a system without the
>help of suid-root programs (as I prefer to have none of these on my
>system).

>Would it be reasonable to allow non-root processes to chroot(), if the
>chroot syscall also changed the cwd for non-root processes?
You might want to look into systrace, see

  http://www.citi.umich.edu/u/provos/systrace/

Sandboxing your own applications does not require special privileges.
Policy generation is intuitive and interactive.  Thats means you can
generate your policies on the fly without complete knowledge of the
exact code paths an application takes.  (I run all my 3rd-party
software and most system daemons under systrace)

Policy violations are reported and can be resolved directly in
interactive mode.

To avoid setuid-root programs, systrace supports Privilege Elevation.

This is a novel feature that allows you to run an application without
special privileges.  The policy can momentarily elevate the privileges
of the application, for example to bind a reserved port or to create a
raw socket.  Basically, it allows as fine grained capabilities as
possible.

The Linux port is basically finished and should appear on the web page
in the next couple days.

Niels.

^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: can chroot be made safe for non-root?
@ 2002-10-19 19:42 Hank Leininger
  2002-10-20 10:40 ` Bernd Eckenfels
  0 siblings, 1 reply; 24+ messages in thread
From: Hank Leininger @ 2002-10-19 19:42 UTC (permalink / raw)
  To: linux-kernel

On 2002-10-19, Eric Buddington <eric@ma-northadams1b-3.bur.adelphia.net>   
wrote:   
   
> On Tue, Oct 15, 2002 at 11:44:32PM -0700, Philippe Troin wrote:   
> > > Would it be reasonable to allow non-root processes to chroot(), if   
> > > the chroot syscall also changed the cwd for non-root processes?   
> >    
> > No.   
> >    
> > fd = open("/", O_RDONLY);   
> > chroot("/tmp");   
> > fchdir(fd);   
> >    
> > and you're out of the chroot.   
   
> I see. From my aesthetic, it would make sense for chroots to 'stack',   
> such that once a directory is made the root directory, its '..' entry   
> *always* points to itself, even after another chroot(). That would   
> prevent the above break (you could be outside the new root, but you   
> still couldn't back out past the old root), though perhaps at an   
> unacceptable in complexity.   
   
And not quite enough, if I understand your suggestion properly.  It's not   
necessary above to chroot or fchroot using fd; its existance is enough to  
monkey with things outside/above the chroot jail, which is unacceptable.   
   
> I do like the idea of preventing multiple chroots, as a second option.   
  
That's far from enough though.  You also must consider:  
  
-signals to non-chrooted processes  
-shared memory (maybe obsolete now with shmfs)  
-running a setuid file such as /bin/su which has been hardlinked in by  
  a process outside the jail, reading your bogus passwd file in the jail   
  (collusion/multifactor attack)  
-chmod +s a chrooted file, to be accessed by another, unprivileged UID  
  which is not jailed (collusion/multifactor attack)  
-ptrace non-chrooted processes  
-in addition, for root:  
  -open raw devices / mknod of block and char devices  
  -mount(2)  
  -various capabilities need to be dropped (sysctl, module loading, ...)  
  
Any of these allow a chrooted process to interact too much with the rest  
of the system, if not leading to outright, immediate chroot-breaking.   
Some of them can be protected against without kernel patching, just  
careful policing of chroot usage: don't ever chroot a UID who also has  
processes outside of chroot (or in a different jail); make the parent of  
the chroot dir inaccessible by non-chrooted processes / regular users, 
dont't give write access/directory ownership anywhere under chroot, etc.  
Some can't be made safe(r) w/o help.  
  
I have a patch to do all of the above here (only for 2.2 atm):  
http://www.theaimsgroup.com/~hlein/hap-linux/  
Look for CONFIG_SECURE_CHROOT.  Double chroots are forbidden, but also, a  
warning is printed if a process attempts to chroot with an open fd to a  
directory (I decided against making the chroot call fail, as any software  
buggy enough to chroot with open directory fds is likely to not check the  
return value of chroot(2), and blindly continue on failure--even worse).   
I'd be happy to hear about (and fix ;) anything I've missed.  
  
IIRC, FreeBSD allow a chroot'ed process to chroot again if and only if 
the  
new root is a subdirectory of the initial chroot.  This allows things 
like  
traditional, chrooting anonymous FTP to be run under an initial chroot.    
  
Double-chroot would also be desirable if you wanted to, say, have init  
spawn some kind of supervisory daemon (or just /bin/login on a serial  
port) and then have *everything* else be chrooted, all multiuser daemons,  
etc.  Then a compromise can play all they want in the sandbox; you still  
have an opportunity for integrity checking tools, etc to run in a 
somewhat  
trustworthy environment.  
  
--   
Hank Leininger <hlein@progressive-comp.com>    
     

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

end of thread, other threads:[~2002-10-22 16:49 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-16  5:51 can chroot be made safe for non-root? Eric Buddington
2002-10-16  6:44 ` Philippe Troin
2002-10-16 21:18   ` David Wagner
2002-10-16 22:04     ` Philippe Troin
2002-10-16 22:00       ` David Wagner
2002-10-19 17:44   ` Eric Buddington
2002-10-19 19:07     ` Bernd Eckenfels
     [not found]       ` <200210201715.07150.landley@trommello.org>
2002-10-21 20:29         ` Bernd Eckenfels
2002-10-22 15:42     ` Jesse Pollard
2002-10-22 16:55       ` Shaya Potter
2002-10-21 15:22   ` Alan Cox
2002-10-22  7:21     ` Ville Herva
2002-10-22 14:15       ` Shaya Potter
2002-10-22 15:55         ` Martin Josefsson
2002-10-16 21:14 ` David Wagner
2002-10-18 19:01 ` Pavel Machek
2002-10-18 20:14   ` David Wagner
2002-10-18 21:07     ` Shaya Potter
2002-10-18 21:00       ` David Wagner
2002-10-18 21:36         ` Shaya Potter
  -- strict thread matches above, loose matches on Subject: below --
2002-10-17  5:08 Niels Provos
2002-10-19 19:42 Hank Leininger
2002-10-20 10:40 ` Bernd Eckenfels
2002-10-20 14:49   ` Shaya Potter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox