Running your programs in a jail with Firejail
Profile
In addition to command-line parameters, you can create your own configuration file for each program. In these security profiles, you can explicitly enable the --seccomp
and --caps
functions. Additionally, you can define in detail which directories Firejail will not pass through to the sandbox, or where access will be restricted to read-only, and you can define mountpoints to match. Finally, you can define limits for the sandbox, for example, by restricting the number of processes running in it.
All security profiles reside in the /etc/firejail
directory. Firejail 0.9.18 comes with preconfigured profiles for Chromium, Dropbox, Evince, Firefox, Iceweasel, and Midori. The profile file then starts with the program name and has a file extension of .profile
. The profile for firefox
thus resides in the firefox.profile
file.
After calling firejail firefox
, Firejail automatically applies all the settings from the matching security profile. The security profiles themselves have a very simple setup, with a setting in each line. Table 1 shows the most important settings at a glance. For more information on the structure of the security profiles, check out the man page: man firejail-profile
.
Table 1
Security Profiles
Statement | Meaning |
---|---|
blacklist /usr/bin |
The sandbox hides the /usr/bin directory |
read-only /usr/bin |
The sandbox mounts the /usr/bin directory read-only |
tmpfs /etc |
Mounts a tempfs filesystem via the /etc directory (any files stored are discarded after terminating the sandbox) |
bind /root/config/ssh, /etc/ssh |
Mounts the /root/config/ssh directory as /etc/ssh in the sandbox |
private /tmp/muell |
Mounts the directory /tmp/muell as the home directory in the sandbox |
caps |
Enables a kernel-side security filter (see text) |
seccomp |
Blocks certain security-critical actions (see text) |
rlimit-fsize 1024 |
A program in the sandbox can create files with a maximum size of 1024 bytes |
rlimit-nofile 500 |
A program in the sandbox can open a maximum of 500 files at the same time |
rlimit-nproc 1000 |
A maximum of 1,000 processes can be created in the sandbox |
Insights
The firejail --list
command lists all jails currently running and programs running in them. Using firejail --tree
lets you quickly discover which program started which other processes and identify the user accounts they are running on (Figure 7). The --top
parameter delivers a similar view to the popular top
command.
![](/var/linux_magazin/storage/images/issues/2015/173/firejail/figure-7/646715-1-eng-US/Figure-7_large.png)
You can retroactively change into the sandbox. To do so, you first need to determine the process ID (PID) of the sandbox by typing firejail --list
. In the list of all the sandboxes that is then shown, you will be able to identify the correct one by looking at the program name. At the start of the matching line, you will see the PID, such as 2652
. Then, simply append this to the --join=
parameter:
firejail --join=2652
Firejail then opens a shell running in the sandbox and subject to that sandbox's restrictions (Figure 8). To use the join function, however, you need a Linux kernel version 3.8 or newer.
Conclusions
Firejail, which is licensed under the GPL v2, is easy to use and enhances security. Applications don't need any special preparation for life in the sandbox; you can even put Dropbox in jail [4]. That said, a sandbox is not a panacea. A web server remotely controlled by hackers might not be able to destroy the system on which it is running, but it still would be able to exploit the system, using it to attack other Internet sites. Firejail is thus simply another brick in the wall for hardening your Linux system; however, it is one that you can set up quickly and pretty effectively.
For more information on Firejail, visit the Firejail homepage [1]. In addition to a small collection of links with various tutorials, you will also find a how-to that explains how to use Firejail as your login shell.
Infos
- Firejail: https://l3net.wordpress.com/projects/firejail/
- Firejail in the SlackBuilds directory: http://slackbuilds.org/repository/14.1/system/firejail/?search=firejail
- Firejail documentation: https://l3net.wordpress.com/projects/firejail/firejail-usage/
- Dropbox in a sandbox: https://l3net.wordpress.com/2014/11/18/running-dropbox-in-firejail-sandbox/
- Wikipedia entry on OverlayFS: http://en.wikipedia.org/wiki/OverlayFS
- Information on Linux Capabilities: https://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.2/capfaq-0.2.txt
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.