Documentation

Firejail: Sandbox Applications

Firejail is a sandbox for Linux applications. It starts a program inside a restricted environment, so that a browser, a PDF reader or a media player that gets compromised can see and touch far less of your system. Parrot Linux ships Firejail together with ready-made profiles, and this guide shows how to use it day to day, how to check that it is working, and how to adjust a profile when an application needs more (or less) access.

How Firejail works

Firejail does not run a virtual machine. It uses features built into the Linux kernel:

  • Namespaces give the sandboxed program its own view of the file system, the process list and, optionally, the network.
  • seccomp-bpf filters which system calls the program may make.
  • Capabilities are dropped, so even a program started with extra privileges cannot use most of them.

What a program may access is described in a profile. Firejail includes profiles for hundreds of common applications; anything without a profile falls back to a strict default profile.

Run an application in the sandbox

Put firejail in front of the command:

firejail firefox-esr
firejail vlc

To see which sandboxes are running, and which processes belong to each one:

firejail --list
firejail --tree

If the program you started does not appear in the list, it is not sandboxed.

Sandbox applications automatically

Typing firejail every time is easy to forget. The firecfg tool creates links in /usr/local/bin for every installed program that has a profile, so the sandboxed version starts whenever you launch the program by name:

sudo firecfg

Some menu entries call programs by their full path and skip those links. firecfg --fix copies the affected launchers into your home directory and corrects them. To undo everything firecfg did:

sudo firecfg --clean

Useful one-off options

OptionWhat it does
--privateStarts the program with a temporary, empty home directory that is deleted when it closes. Good for opening an untrusted file or browsing without leaving traces.
--private=~/sandboxUses the given folder as the home directory, so the program keeps its data there and nowhere else.
--net=noneNo network at all, for programs that should never go online.
--seccompApplies the default system-call filter (most profiles already do this).
--apparmorAdds AppArmor confinement on top of the Firejail profile. See AppArmor.
--profile=FILEUses a specific profile instead of the default one.
--noprofileRuns without a profile. Useful only to test whether a profile is causing a problem.

Example: open a document from an unknown source in a throw-away home directory with no network:

firejail --private --net=none okular suspicious.pdf

Where the profiles live

  • /etc/firejail/ holds the profiles shipped with the package, one .profile file per application.
  • ~/.config/firejail/ is for your own profiles. A profile here takes priority over the system one with the same name.

Do not edit the files in /etc/firejail/ directly: package updates overwrite them. Use .local files instead.

Change a profile the safe way: .local files

Each shipped profile includes two optional files: /etc/firejail/<program>.local and /etc/firejail/globals.local. They are read before the profile itself, survive updates, and are the right place for your changes.

Example: cut network access for every sandboxed program, but let curl keep it. In /etc/firejail/globals.local:

net none

And in /etc/firejail/curl.local:

ignore net none

A profile is built from a few kinds of rules:

  • blacklist PATH hides a file or folder; everything else stays visible.
  • whitelist PATH makes only the listed paths of a directory visible; everything else in it is hidden.
  • noblacklist / nowhitelist cancel a rule that an included file adds.
  • ignore RULE skips a rule from the profile.

The full list of options is in man firejail-profile.

Write a profile for a new application

  1. Copy a similar profile to ~/.config/firejail/<program>.profile, or start from /etc/firejail/default.profile.
  2. Start the program with firejail --profile=~/.config/firejail/<program>.profile <program>.
  3. If something breaks, relax one rule at a time and test again. Start strict and open up, not the other way round.
  4. Add whitelist rules for the folders the program really needs, such as its configuration directory and ~/Downloads.
  5. Check the result with firejail --list and by trying to open a file the program should not see.

firemon <PID> shows what a running sandbox is doing, and firejail --debug prints how the sandbox is being built.

Common problems

  • The program will not start or cannot save files. The profile blocks a path it needs. Run it once with --noprofile to confirm, then add a whitelist or noblacklist line in its .local file.
  • No sound. Check that the profile does not contain nosound, or add ignore nosound to the .local file.
  • Graphics problems with proprietary drivers. Some profiles restrict access to the GPU devices; try ignore no3d or ignore private-dev in the .local file.
  • Wine and some games do not work well under seccomp filtering and are better left outside the sandbox.

Firejail or AppArmor?

They complement each other. AppArmor policies are enforced by the kernel for every start of a program, while Firejail adds namespaces, private directories and network isolation that you can choose per launch. Parrot uses both. See AppArmor on Parrot Linux.

FAQ

Is Firejail installed on Parrot Linux by default?

Yes. Run firejail --version to check. If it is missing, install it with sudo apt install firejail.

Does Firejail slow programs down?

Not noticeably. The sandbox is set up when the program starts and then the kernel enforces it with very little overhead.

How do I stop sandboxing one program?

Delete its link in /usr/local/bin (for example sudo rm /usr/local/bin/vlc), or run sudo firecfg --clean to remove all of them.