![]() |
|
![]() |
|||
|
By |
|||||||||||||||||||||||||||
Other Security Resources!
TD>
|
/var/spool/mail), other files in
spool (such as mqueue), user's home directories (to check for .forward
files) and system configuration files in /etc. There is no place on
the filesystem where sendmail can be effectively confined. Of course,
some makeshift solution is possible, but it is not clear that it will
add to security, but rather cause it to lax. If sendmail functionality
is separated into spool daemon and mail transfer program (like done in
FWTK smap and smapd), than chrooting is entirely possible.Chrooting shell users is possible if there is a business need to keep them in some particular directory. Suggestions for doing this with ssh2 are provided in the SSH FAQ, and for OpenSSH in the Linux From Scratch archives and SF Linux archives. However, it might involve copying multiple system libraries, files and other resources such as Linux Pluggable Authentication Modules (PAM) architecture, used by most modern Linux distributions.
Anything else such as bind, apache, squid can be chrooted, but sometimes the benefits are unclear, especially for daemons that run as root. This URL (http://www.networkdweebs.com/chroot.html) provides a nice list of daemons that its author chrooted successfully.
"What daemon should be chrooted?" is an entirely different question from "What daemons can be chrooted?" Before we answer it, lets analyze how attackers break out of chroot.
First, the more software is deployed within chroot environment, the more dangerous it becomes, since it is hard to keep track of programs that can be used by the attacker to elevate permission and escape.
Second, the number of ways that root user can break out of chroot is
huge. Starting from simple use of a chroot() call with no chdir() [see
code below] to esoteric methods as the creation of your own /dev/hda
or /dev/kmem devices, injection code into the running kernel
(http://www.big.net.au/~silvio/runtime-kernel-kmem-patching.txt),
using open directory handles outside chroot or chroot-breaking buffer
|
EnGarde Secure Linux
|
Sample code to break out of chroot:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
int main(void)
{
int i;
mkdir("breakout", 0700);
chroot("breakout");
for (i = 0; i < 100; i++)
chdir("..") ;
chroot(".");
execl("/bin/sh", "/bin/sh",NULL);
}
compile statically (using "gcc -static") and run within chrooted
directory (after doing "chroot ." or similar from shell prompt) to
escape.
Third, if there is no root user defined within the chroot environment,
no SUID binaries, no devices, and the daemon itself dropped root
privileges right after calling chroot() call (like in the code below),
breaking out of chroot appears to be impossible. In other words, if
there is no way to gain root shell or perform actions that only root
can usually perform (e.g. create devices, or access raw memory)
breaking chroot is not clearly possible. Ideally, if the custom
software uses chroot for security the sequence of calls should be:
chdir("/home/safedir");
chroot("/home/safedir");
setuid(500);
Keep in mind, that after these lines are executed there will be no way
for the program to regain root privileges.
Fourth, in some cases attackers might not be able to break (i.e. run
processes outside of chrooted directory), but instead will be able to
somewhat affect such processes. For example, if bind is chrooted,
several devices should be created. One of them is /dev/log, necessary
for logging bind messages into the regular system logs. By crafting a
malicious log message and sending it into /dev/log from within the
chrooted directory attacker will influence the behavior of syslog
daemon running outside the chroot. If there is a buffer overflow in
syslog (which runs as root), additional privileges can be obtained.
What daemons can be chrooted but with no valuable security outcome? In
light of the above, chrooting programs that do not drop root
privileges while running, or programs that provide root shell access
(sshd, telnet with a root account within chrooted directory) does not
provide any extra security.
To conclude, chroot() is a good way to increase the security of the
software provided that secure programming guidelines are utilized and
chroot() system call limitations are taken into account. Chrooting
will prevent an attacker from reading files outside the chroot jail
and will prevent many local UNIX attacks (such as SUID abuse and /tmp
race conditions).
chroot() but be sure to heed
the instructions provided in this article before chrooting all services
running on your system.
| Contact Us | Legal Notice | About Our Site © Guardian Digital, Inc., 2000 |