Restrict Services with Sandboxed Environments
Mitigate system damage by keeping service compromises contained.
Sometimes keeping up with the latest patches just isn’t enough to prevent a break-in. Often, a new exploit will circulate in private circles long before an official advisory is issued, during which time your servers may be open to unexpected attack. With this in mind, it’s wise to take extra preventative measures to contain the aftermath of a compromised service. One way to do this is to run your services in sandbox environments. Ideally, this lets the service be compromised while minimizing the effects on the overall system.
Most Unix and Unix-like systems include some sort of system call or
other mechanism for sandboxing that offers various levels of
isolation between the host and the sandbox. The least restrictive and
easiest to set up is a chroot()
environment, which is available on nearly all Unix and Unix-like
systems. In addition to chroot(), FreeBSD
includes another mechanism called jail( )
, which
provides a few more restrictions beyond those provided by
chroot().
chroot()
very simply changes the
root directory of a process and all of its children. While this is a
powerful feature, there are many caveats to using it. Most
importantly, there should be no way for anything running within the
sandbox to change its effective UID (EUID) to 0, which is root’s UID. Naturally, this implies that you don’t want to run anything as root within the jail. If an attacker ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access