Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Web-App-Sec
[Top] [All Lists]

Re: Chroot jails

Subject: Re: Chroot jails
Date: Tue, 20 Sep 2005 21:00:37 +0200
Hi...

Wondered if people could give me their opinions on chroot jails
AFAIK, chroot on linux is fundamentally insecure - look for the
'chroot-again' flaw.
Last time I checked it still worked and allowed to escape.
A chrooted jail without dropping privileges is vain anyway.

For the "chroot-again" exploit to work you need to be able to
execute something within the jail as root or with root privileges.

So the process running in the "jail" *must* drop root privileges after
the chroot.

e.g. (C snippet)
=== snip ===
  if (chdir( "/tmp/jaildir") ) die();
  if (chroot(".")) die();
  if (-1==setuid(jailuid)) die();
=== snap ===

After dropping privileges the process will not be able to chroot again.

The only way to escape would be some executable on the machine
with suid a/o sguid flag set that performs the "chroot-again" for the
in-jail process.
If you have something like that on your machine, or there is any non-root
user who is able to install something like that there, then you can consider 
your system to be compromised anyway...
(The problem is, that most web-app related stuff out there does NOT
disable suid executables, so you have to triple check that the process
in the jail will never be able to exec something with effective uid 0)

bottom line: 
a well-done chrooted jail could be made unescapeable,
but you have to know what you do and keep a lot of 
auxiliary conditions in mind. Generally this is far more difficult
if you have (untrusted) local users on the considered machine.

HTH & kind regards

Ingo Struck

<Prev in Thread] Current Thread [Next in Thread>