Firejail

On this page 7

Firejail is a lightweight setuid sandboxing program for Linux that starts an application inside a restricted environment built from kernel namespaces, seccomp-bpf system call filters and Linux capabilities reduction. In Linux security, it serves as a practical tool for confining untrusted or exposed programs such as web browsers, media players, mail clients and network daemons without rewriting them or running a full virtual machine.

Firejail ships with more than a thousand ready-made profiles that describe what each program may see and do. A user simply prefixes a command, for example firejail firefox, and the program runs with a private view of the filesystem, a filtered set of system calls and, optionally, its own network stack.

How Firejail builds a sandbox

Firejail builds a sandbox by combining several kernel isolation features in one launch step rather than inventing a new security mechanism. The firejail binary is installed setuid root, which lets it create mount, PID, network and user namespaces that an ordinary user could not always create alone, and then it drops privileges before executing the target program.

The launch sequence follows a fixed order. Firejail reads the matching profile, creates new namespaces, assembles a restricted mount tree with blacklisted, read-only or temporary directories, applies a seccomp filter, removes capabilities, sets the no_new_privs flag and finally starts the application as the invoking user. Each layer limits a different class of attack.

The following table maps each building block to the kernel feature behind it and the attack it addresses.

LayerKernel featureWhat it restricts
Mount namespaceCLONE_NEWNSVisible files, home directory, /dev and /tmp
PID namespaceCLONE_NEWPIDVisibility of and signals to other processes
Network namespaceCLONE_NEWNETInterfaces, routing and outbound traffic
Seccomp-bpfSeccomp mode 2Dangerous system calls such as mount or ptrace
CapabilitiesCapability bounding setRoot-level powers like CAP_SYS_ADMIN
AppArmorLinux Security ModulesOptional extra path and access rules
Isolation layers used by Firejail

Firejail profiles and key options

A Firejail profile is a plain-text file that lists the restrictions for one program, stored under /etc/firejail/ with local overrides in ~/.config/firejail/. Profiles use include files such as disable-common.inc and disable-programs.inc to blacklist sensitive paths like SSH keys, password stores and shell histories across many applications at once.

Most hardening comes from a small set of directives. The table below lists the options administrators adjust most often and the effect each one has on the sandboxed program.

DirectiveEffectTypical use
privateMounts a temporary, empty home directoryOpening untrusted documents
whitelistExposes only listed paths in the home directoryBrowsers limited to Downloads
blacklistHides specific files or directoriesProtecting ~/.ssh and ~/.gnupg
net noneCreates a network namespace with no interfacesOffline viewers and editors
seccompApplies the default system call blocklistNearly every profile
caps.drop allRemoves all Linux capabilitiesUnprivileged desktop programs
nonewprivsBlocks privilege gain through setuid binariesHardening against escalation
private-devProvides a minimal /dev treePrograms that need no hardware
Common Firejail profile directives

The firecfg utility creates symbolic links in /usr/local/bin so that launching a supported program from a menu or terminal automatically starts it through Firejail. Runtime tools such as firejail --list, --tree and --join let an administrator inspect and enter running sandboxes.

Firejail occupies the middle ground between mandatory access control systems and unprivileged container tools. Its closest neighbors in Linux security differ mainly in who configures them, how they gain privileges and how much code runs with root rights.

ToolPrivilege modelConfigurationMain strength
FirejailSetuid root binaryPer-application profilesLarge ready profile library
BubblewrapUnprivileged user namespacesCommand-line argumentsVery small trusted code base
AppArmorKernel LSM, root policySystem-wide path profilesEnforced for every launch
SELinuxKernel LSM, root policyType enforcement labelsFine-grained system policy
chrootRoot requiredDirectory change onlySimple filesystem relocation
systemd-nspawnRoot requiredContainer imagesFull operating system containers
Firejail and neighboring confinement mechanisms

The decisive difference is voluntary versus mandatory confinement. Firejail confines a program only when it is launched through Firejail, whereas AppArmor and SELinux policies apply no matter how the program starts. The two approaches are complementary, and Firejail can load an AppArmor profile inside the sandbox for defense in depth.

Deploying Firejail in practice

Firejail fits best on single-user desktops and small servers where an administrator wants to confine high-risk programs quickly. Installation from the distribution repository, followed by sudo firecfg, covers the most common applications within minutes.

Choosing the right level of restriction depends on the program and the data it touches. The decision table below summarizes typical scenarios.

SituationRecommended settingReason
Web browser for daily useDefault profile with whitelisted DownloadsLimits damage from a browser exploit
Opening an unknown PDF--private --net=noneNo network and no access to real files
Testing a downloaded binary--private --seccomp --caps.drop=allStrong isolation for untrusted code
Network daemon on a serverCustom profile with --net bridgeSeparates traffic and filesystem
Program lacking a profileStart from default.profileSafe baseline before tuning
Choosing a Firejail configuration

Profiles should be tested with --debug and adjusted through local override files, never by editing the shipped profiles directly, because package updates replace those files. When a program fails, the --trace option shows which file accesses or system calls were blocked.

Limitations and security risks of Firejail

Firejail’s largest weakness is its setuid root design. A large, complex program running with root privileges presents a substantial attack surface, and several local privilege escalation vulnerabilities have been found in Firejail itself over the years. Critics argue that a sandbox should never increase the risk to the host it protects.

  • Kernel vulnerabilities are not blocked: a sandboxed exploit that reaches a kernel bug can still escape.
  • X11 applications can read keystrokes from other windows unless an isolated display such as Xpra or Xephyr is used; Wayland reduces this risk.
  • Optional by launch path: starting a program by its full path, for example /usr/bin/firefox, bypasses the firecfg symbolic links.
  • Overly broad profiles that whitelist the whole home directory give a false sense of safety.
  • D-Bus access can allow a confined program to control other desktop services unless it is filtered.

For these reasons, many security engineers prefer Bubblewrap-based sandboxes such as Flatpak for new deployments, while still valuing Firejail as a convenient extra layer for programs that have no other confinement. Restricting the binary to a trusted group through the firejail-users file reduces exposure on multi-user systems.

A non-technical view

Firejail works like a separate room with locked cupboards for each program on a Linux computer. The program can do its job inside the room, but it cannot open the drawers that hold your passwords, private keys or personal files unless you allow it.

If a website tricks your browser into running harmful code, that code finds itself in the same small room. It sees only the folders the profile permits and may have no internet access at all. The key idea is simple: a compromised program can only damage what it can reach, and Firejail keeps that reach small.

A concrete example

A freelance accountant uses a Linux laptop to receive invoices from dozens of unknown senders. Opening every attached PDF directly in a viewer would expose tax records and client spreadsheets in the home directory if one file carried an exploit.

The accountant runs sudo firecfg once, so the browser and mail client start through Firejail automatically. For suspicious attachments, a desktop shortcut runs the viewer with firejail --private --net=none. The viewer then sees an empty temporary home directory and has no network interface, so even a successful exploit could neither read client data nor send anything out.

When the session ends, the temporary directory disappears. The result is a workflow that adds under one second of startup delay while removing the most likely path from a malicious document to a data breach.