The FreeBSD jail mechanism is a type of Operating system-level virtualization that allows administrators to partition a FreeBSD-based computer system into several independent mini-systems called jails.
The need for the FreeBSD jails came from service providers willing to establish a clean cut between their services and those of their customers, mainly for security and ease of administration reasons. Instead of adding a new layer of fine-grained configuration options, the solution adopted was to compartment the system, both its files and its resources, in a way they can only be accessed by the right compartment.
Those familiar with Unix will recognize the chroot jail method of restricting the scope of processes. The FreeBSD jail mechanism is more than that: each process is attached a specific kernel structure whose purpose is to limit its interaction with processes running in other jails and restrict the things they can do (for instance a jail is bound to only one IP address and cannot access raw, divert or routing sockets).
The jail(8) utility and jail(2) system call first appeared in FreeBSD 4.0. New utilities (for example jls(8) to list jails) and system calls (for example jail_attach(2) to attach a new process to a jail) that render jail management much easier have been added in FreeBSD 5.1.
Virtualization is valuable to service providers wishing to offer their users the ability to have custom configurations and yet keep the overall system easy to maintain. For example two different customers could need different versions of the same software. The traditional way of configuring different software versions is to install both versions in different directories and try to make sure that they do not encroach on each other. Needless to say, this configuration isn't easy to maintain and rapidly tends to become messy, especially if the software hasn't been designed with this in mind (e.g. XFree86 is notoriously hard to move around). The approach with jails is that every piece of software feels at home because it thinks it has the whole system for itself. It is even possible to allow the customer to do the configuration, or even the installation of new software himself by providing him access to the jail's root account.
However, the FreeBSD jail doesn't achieve true virtualization because it doesn't allow the virtual machines to run different kernel versions than that of the base system. All virtual servers share the same kernel and hence expose the same bugs and potential security holes. There is no clustering or process migration capability included, so the host kernel and host computer is still a single point of failure for all virtual servers. It is possible to use jails to safely test new software, but not new kernels.
For example, suppose that a system is running an Apache web server as user www and that the administrator responsible for its contents introduces a PHP include vulnerability. With the traditional scheme, this would compromise the entire system: the attacker would have the rights of the user www which can typically modify files on the web server, wander about in the directory tree and get lots of information, such as the full user list, shell and home directory from /etc/passwd. If the box is serving other purposes than hosting a web server, this can be of a great concern.
However, if the web server is jailed, the scope of user www is limited to the jail, which can, in turn, be minimalist enough not to give away unnecessary information. For example, besides the compulsory basic accounts, only www and perhaps ftp (to update the web server's contents) would be added as users. So the attacker could only mess around with the web server, even though he finds a way to gain superuser access.
If the root account of a FreeBSD jail is compromised, the attacker still cannot access the entire system because jails are limited in the following ways:
With jails it is possible to install different daemons in different jails and delegate their administration to other people by giving them access to the superuser account. It is safe for two reasons:
This will spawn several processes that are executed in the context of the jail and cannot interact with anything else than other processes of the same jail or access anything in the filesystem below the jail's root (i.e. /usr/jail).
The jail(8) man page is a good source of information to start with jails.
This article is licensed under the GNU Free Documentation License.
It uses material from the
"FreeBSD Jail".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world