chroot(2) security

Hall marcus at ihlpl.UUCP
Sun Oct 5 05:07:03 AEST 1986


In article <113 at nonvon.UUCP>, apn at nonvon.UUCP (apn) writes:

> 	write a program that changes the root directory to /mnt23/user/test
> 	and then procedes to exec /bin/login

Which would really execute /mnt23/user/test/bin/login.  So what?

What you have to do is to find some writable directory in the same filesystem
as /bin.  If you find such a filesystem, it would be possible to create a
subdirectory, say /writable/dir/etc which contains a fake passwd file that
has a known password for root.  Then, create a hard link from /bin/login
to /writable/dir/login, chroot to /writable/dir, and execute /login which
is really /writable/dir/login, which is linked to /bin/login.  This would
let you log in as root, create a SUID shell in /writeable/dir/... .  Next,
get back to where you started (before the chroot), execute the SUID shell,
and there you go!

The best security in this case would to be sure that there are no writable
directories in the root filesystem, or for /bin/login to make sure that it
is SUID root and has only 1 link (I'm not sure if this could be gotten
around or not).

At any rate, programs on /usr (usually /usr/bin, /usr/local, etc.) have
problems because /usr/tmp and somewhere in /usr/spool is usually writable.

In BSD systems, where SUID shells work, explicitly specified paths for
commands would become questionable, which would present a real hazard.

Marcus Hall
..!ihnp4!ihlpl!marcus



More information about the Comp.unix.wizards mailing list