|
|
Log in / Subscribe / Register

Security

What chroot() is really for

By Jake Edge
October 3, 2007

The chroot() system call is often misunderstood, as it can appear to do much more than it actually does. The confusion arises because it appears to some to be a security tool – there are limited security uses – when it is meant as a tool for isolating processes for installation, debugging, and legacy library usage.

What chroot() actually does is fairly simple, it modifies pathname lookups for a process and its children so that any reference to a path starting '/' will effectively have the new root, which is passed as the single argument, prepended onto the path. The current working directory is left unchanged and relative paths can still refer to files outside of the new root.

Calls to chroot() do not stack, with additional calls essentially overwriting the existing one. It can only be called by privileged programs and can be trivially bypassed by those who can call it as man 2 chroot describes:

    This  call does not change the current working directory, so that after
    the call '.' can be outside the tree rooted at '/'.  In particular, the
    superuser  can  escape from a 'chroot jail' by doing 'mkdir foo; chroot
    foo; cd ..'.

The use of the term "chroot jail" in the manpage is unfortunate as it may help perpetuate a common misconception about chroot(). It often gets mentioned in the same context as the "jail" calls for the BSDs, but it has little in common with them. A BSD jail is a mini-virtualization that partitions a system into multiple virtual systems each of which can have its own root account. chroot() has none of that sophistication.

A patch posted to the linux-kernel mailing list was aimed at fixing the "hole" described in the manpage, but led, instead, to a rather contentious thread. The patch changes chroot() by setting the current working directory to the new root if it was not already somewhere underneath it. This violates POSIX and other standards, which specify the current behavior, as well as numerous typical use cases for chroot(). In addition, as was forcefully pointed out in the thread, there are innumerable ways for a privileged process to access files that are not underneath the new root. Even if it did not run afoul of the standards, there is no point in fixing something that is so trivially bypassed in other ways.

The proponents of fixing the problem that they see – even if most of the kernel hackers disagree – seem to believe that, while you can circumvent a chroot() call, it should not be possible by using chroot() itself. It is an argument that didn't seem to get anywhere for a pretty simple reason: chroot() is not meant to be a security-oriented access control mechanism. It is, instead, a way to run processes with a partitioned view of the filesystem.

There are reasonable uses of chroot() for very limited security purposes. Daemons that do not run as root can be placed into their own filesystem subtree – bind/named and Apache are sometimes run this way – to prevent any access outside of it. That will work, even if the daemon gets exploited, as long as there is no way to elevate privileges after the exploit. For example, if there are vulnerable setuid() programs accessible from within the chroot(), full filesystem access is possible.

chroot() is a useful call, many install programs use it, as do programs that need to see a consistent set of older libraries, but it has very limited use in security applications. It does not provide a sandbox that can be used to test suspicious code, that code might escalate its privilege and access anything it wished. Maintaining an up-to-date chroot() environment adds an additional burden on administrators as well; update tools do nothing to help keep utilities secure if they live outside of the normal places. It is probably safest to avoid using it as any kind of security tool.

Comments (29 posted)

New vulnerabilities

bugzilla: multiple vulnerabilities

Package(s):bugzilla CVE #(s):CVE-2007-4543 CVE-2007-4538 CVE-2007-4539
Created:October 1, 2007 Updated:October 3, 2007
Description: Masahiro Yamada found that from the 2.17.1 version, Bugzilla does not properly sanitize the content of the "buildid" parameter when filing bugs (CVE-2007-4543). The next two vulnerabilities only affect Bugzilla 2.23.3 or later, hence the stable Gentoo Portage tree does not contain these two vulnerabilities: Loic Minier reported that the "Email::Send::Sendmail()" function does not properly sanitise "from" email information before sending it to the "-f" parameter of /usr/sbin/sendmail (CVE-2007-4538), and Frédéric Buclin discovered that the XML-RPC interface does not correctly check permissions in the time-tracking fields (CVE-2007-4539).
Alerts:
Gentoo 200709-18 bugzilla 2007-09-30

Comments (1 posted)

kernel: ALSA returns incorrect write size

Package(s):kernel CVE #(s):CVE-2007-4571
Created:September 28, 2007 Updated:June 20, 2008
Description: The snd_mem_proc_read function in sound/core/memalloc.c in the Advanced Linux Sound Architecture (ALSA) in the Linux kernel before 2.6.22.8 does not return the correct write size, which allows local users to obtain sensitive information (kernel memory contents) via a small count argument, as demonstrated by multiple reads of /proc/driver/snd-page-alloc.
Alerts:
Ubuntu USN-618-1 linux-source-2.6.15/20/22 2008-06-19
Debian DSA-1505 alsa-driver 2008-02-22
Debian DSA-1479 linux-2.6 2008-01-29
Red Hat RHSA-2007:0993-01 kernel 2007-11-29
Red Hat RHSA-2007:0939-01 kernel 2007-11-01
SuSE SUSE-SA:2007:053 kernel 2007-10-12
Fedora FEDORA-2007-714 kernel 2007-10-08
Fedora FEDORA-2007-2349 kernel 2007-09-28
rPath rPSA-2007-0202-1 kernel 2007-09-27

Comments (none posted)

mplayer: heap-based buffer overflow

Package(s):mplayer CVE #(s):CVE-2007-4938
Created:October 2, 2007 Updated:October 3, 2007
Description: A heap-based buffer overflow in libmpdemux/aviheader.c in MPlayer 1.0rc1 and earlier allows remote attackers to cause a denial of service (application crash) or possibly execute arbitrary code via a .avi file with certain large "indx truck size" and nEntriesInuse values, and a certain wLongsPerEntry value.
Alerts:
Mandriva MDKSA-2007:192 mplayer 2007-10-01

Comments (none posted)

openssl: off-by-one error

Package(s):openssl CVE #(s):CVE-2007-5135
Created:October 3, 2007 Updated:July 31, 2008
Description: From the Debian advisory: An off-by-one error has been identified in the SSL_get_shared_ciphers() routine in the libssl library from OpenSSL, an implementation of Secure Socket Layer cryptographic libraries and utilities. This error could allow an attacker to crash an application making use of OpenSSL's libssl library, or potentially execute arbitrary code in the security context of the user running such an application.
Alerts:
Gentoo 201412-11 emul-linux-x86-baselibs 2014-12-11
rPath rPSA-2008-0241-1 openssl 2008-07-30
SuSE SUSE-SR:2008:005 acroread, asterisk, cacti, compat-openssl097g, icu, libcdio, wireshark/ethereal, Jakarta, perl-tk 2008-03-06
Red Hat RHSA-2007:1003-02 OpenSSL 2007-11-15
Red Hat RHSA-2007:0813-01 OpenSSL 2007-10-22
Fedora FEDORA-2007-2530 openssl 2007-10-18
Fedora FEDORA-2007-725 openssl 2007-10-15
SuSE SUSE-SR:2007:020 TK, openssl, hugin, lighttpd, novell-groupwise-gwclient, sylpheed-claws 2007-10-12
Red Hat RHSA-2007:0964-01 OpenSSL 2007-10-12
Debian DSA-1379-2 openssl097 2007-10-10
Gentoo 200710-06 openssl 2007-10-07
Mandriva MDKSA-2007:193 openssl 2007-10-04
rPath rPSA-2007-0206-1 openssl 2007-10-03
Foresight FLEA-2007-0058-1 dist 2007-10-03
Debian DSA-1379 openssl 2007-10-02

Comments (none posted)

pidgin: denial of service

Package(s):pidgin CVE #(s):CVE-2007-4996
Created:October 3, 2007 Updated:November 2, 2007
Description: Pidgin can be forced to crash by an MSN user sending "nudge" messages.
Alerts:
Fedora FEDORA-2007-2368 pidgin 2007-10-03
Slackware SSA:2007-275-01 pidgin 2007-10-03
Foresight FLEA-2007-0057-1 pidgin 2007-10-02

Comments (1 posted)

Page editor: Jake Edge
Next page: Kernel development>>


Copyright © 2007, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds