FIREJAIL(1) | firejail man page | FIREJAIL(1) |
Firejail - Linux namespaces sandbox program
Start a sandbox:
Start an AppImage program:
File transfer from an existing sandbox
Network traffic shaping for an existing sandbox:
Monitoring:
Miscellaneous:
Firejail is a SUID sandbox program that reduces the risk of security breaches by restricting the running environment of untrusted applications using Linux namespaces, seccomp-bpf and Linux capabilities. It allows a process and all its descendants to have their own private view of the globally shared kernel resources, such as the network stack, process table, mount table. Firejail can work in a SELinux or AppArmor environment, and it is integrated with Linux Control Groups.
Written in C with virtually no dependencies, the software runs on any Linux computer with a 3.x kernel version or newer. It can sandbox any type of processes: servers, graphical applications, and even user login sessions.
Firejail allows the user to manage application security using security profiles. Each profile defines a set of permissions for a specific application or group of applications. The software includes security profiles for a number of more common Linux programs, such as Mozilla Firefox, Chromium, VLC, Transmission etc.
Firejail is currently implemented as an SUID binary, which means that if a malicious or compromised user account manages to exploit a bug in Firejail, that could ultimately lead to a privilege escalation to root. To mitigate this, it is recommended to only allow trusted users to run firejail (see firejail-users(5) for details on how to achieve that). For more details on the security/usability tradeoffs of Firejail, see: #4601
Alternative sandbox technologies like snap (https://snapcraft.io/) and flatpak (https://flatpak.org/) are not supported. Snap and flatpak packages have their own native management tools and will not work when sandboxed with Firejail.
Without any options, the sandbox consists of a filesystem build in a new mount namespace, and new PID and UTS namespaces. IPC, network and user namespaces can be added using the command line options. The default Firejail filesystem is based on the host filesystem with the main system directories mounted read-only. These directories are /etc, /var, /usr, /bin, /sbin, /lib, /lib32, /libx32 and /lib64. Only /home and /tmp are writable.
Upon execution Firejail first looks in ~/.config/firejail/ for a profile and if it doesn't find one, it looks in /etc/firejail/. For profile resolution detail see https://github.com/netblue30/firejail/wiki/Creating-Profiles#locations-and-types. If an appropriate profile is not found, Firejail will use a default profile. The default profile is quite restrictive. In case the application doesn't work, use --noprofile option to disable it. For more information, please see SECURITY PROFILES section below.
If a program argument is not specified, Firejail starts the user's preferred shell. Examples:
$ firejail [OPTIONS] # starting the program specified in $SHELL, usually /bin/bash
$ firejail [OPTIONS] firefox # starting Mozilla Firefox
# sudo firejail [OPTIONS] /etc/init.d/nginx start
Example:
$ firejail --allow-debuggers --profile=/etc/firejail/firefox.profile
strace -f firefox
Example:
$ firejail --allusers
Example:
$ firejail --apparmor.print=browser
5074:netblue:/usr/bin/firejail /usr/bin/firefox-esr
AppArmor: firejail-default enforce
Example:
$ firejail --appimage --profile=krita krita-3.0-x86_64.appimage
$ firejail --quiet --appimage --private --profile=krita
krita-3.0-x86_64.appimage
$ firejail --appimage --net=none --x11 --profile=krita
krita-3.0-x86_64.appimage
Note: When using both --appimage and --profile, it is recommended to always specify the former before the latter, so that any ?HAS_APPIMAGE conditionals inside of the profile evaluate to true (see ?CONDITIONAL in firejail-profile(5)).
Example:
# firejail --bind=/config/etc/passwd,/etc/passwd
Symbolic link handling: Blacklisting a path that is a symbolic link will also blacklist the path that it points to. For example, if ~/foo is blacklisted and it points to /bar, then /bar will also be blacklisted.
Example:
$ firejail --blacklist=/sbin --blacklist=/usr/sbin
$ firejail --blacklist=~/.mozilla
$ firejail "--blacklist=/home/username/My Virtual Machines"
$ firejail --blacklist=/home/username/My\ Virtual\ Machines
Example:
$ firejail --build vlc ~/Videos/test.mp4
$ firejail --build --appimage ~/Downloads/Subsurface.AppImage
Example:
$ firejail --build=vlc.profile vlc ~/Videos/test.mp4
$ firejail --build=Subsurface.profile --appimage
~/Downloads/Subsurface.AppImage
By default root programs run with all capabilities enabled. --caps option disables the following capabilities: CAP_SYS_MODULE, CAP_SYS_RAWIO, CAP_SYS_BOOT, CAP_SYS_NICE, CAP_SYS_TTY_CONFIG, CAP_SYSLOG, CAP_MKNOD, CAP_SYS_ADMIN. The filter is applied to all processes started in the sandbox.
Example:
$ sudo firejail --caps /etc/init.d/nginx start
Example:
$ firejail --caps.drop=all warzone2100
Example:
$ firejail --caps.drop=net_broadcast,net_admin,net_raw
Example:
$ sudo firejail --caps.keep=chown,net_bind_service,setgid,\ setuid
/etc/init.d/nginx start
Example:
$ firejail --name=mygame --caps.drop=all warzone2100 &
$ firejail --caps.print=mygame
Example:
$ firejail --list
3272:netblue::firejail --private firefox
$ firejail --caps.print=3272
Example:
$ firejail --chroot=/media/ubuntu warzone2100
For automatic mounting of X11 and PulseAudio sockets set environment variables FIREJAIL_CHROOT_X11 and FIREJAIL_CHROOT_PULSE.
Note: Support for this command is controlled in firejail.config with the chroot option.
Example:
$ firejail --cpu=0,1 handbrake
Example:
$ firejail --name=mygame --caps.drop=all warzone2100 &
$ firejail --cpu.print=mygame
Example:
$ firejail --list
3272:netblue::firejail --private firefox
$ firejail --cpu.print=3272
The log file contains events for both the system and session buses if both of the --dbus-system.log and --dbus-user.log options are specified. If no log file path is given, logs are written to the standard output instead.
Example:
$ firejail --dbus-system=filter --dbus-system.log \
--dbus-log=dbus.txt
The filter policy enables the system DBus filter. This option requires installing the xdg-dbus-proxy utility. Permissions for well-known can be specified with the --dbus-system.talk and --dbus-system.own options.
The none policy disables access to the system DBus.
Only the regular system DBus UNIX socket is handled by this option. To disable the abstract sockets (and force applications to use the filtered UNIX socket) you would need to request a new network namespace using --net command. Another option is to remove unix from the --protocol set.
Example:
$ firejail --dbus-system=none
Example:
$ firejail --dbus-system=filter --dbus-system.broadcast=\
org.freedesktop.Notifications=\
org.freedesktop.Notifications.*@/org/freedesktop/Notifications
Example:
$ firejail --dbus-system=filter --dbus-system.call=\
org.freedesktop.Notifications=\
org.freedesktop.Notifications.*@/org/freedesktop/Notifications
Example:
$ firejail --dbus-system=filter --dbus-system.log
Example:
$ firejail --dbus-system=filter --dbus-system.own=\
org.gnome.ghex.*
Example:
$ firejail --dbus-system=filter --dbus-system.see=\
org.freedesktop.Notifications
Example:
$ firejail --dbus-system=filter --dbus-system.talk=\
org.freedesktop.Notifications
The filter policy enables the session DBus filter. This option requires installing the xdg-dbus-proxy utility. Permissions for well-known names can be added with the --dbus-user.talk and --dbus-user.own options.
The none policy disables access to the session DBus.
Only the regular session DBus UNIX socket is handled by this option. To disable the abstract sockets (and force applications to use the filtered UNIX socket) you would need to request a new network namespace using --net command. Another option is to remove unix from the --protocol set.
Example:
$ firejail --dbus-user=none
Example:
$ firejail --dbus-user=filter --dbus-user.broadcast=\
org.freedesktop.Notifications=\
org.freedesktop.Notifications.*@/org/freedesktop/Notifications
Example:
$ firejail --dbus-user=filter --dbus-user.call=\
org.freedesktop.Notifications=\
org.freedesktop.Notifications.*@/org/freedesktop/Notifications
Example:
$ firejail --dbus-user=filter --dbus-user.log
Example:
$ firejail --dbus-user=filter --dbus-user.own=org.gnome.ghex.*
Example:
$ firejail --dbus-user=filter --dbus-user.talk=\
org.freedesktop.Notifications
Example:
$ firejail --dbus-user=filter --dbus-user.see=\
org.freedesktop.Notifications
Example:
$ firejail --debug firefox
Example:
$ firejail --debug-blacklists firefox
Example:
$ firejail --debug-caps
Example:
$ firejail --debug-errnos
Example:
$ firejail --debug-protocols
Example:
$ firejail --debug-syscalls
Example:
$ firejail --debug-whitelists firefox
Example:
$ firejail --net=eth0 --defaultgw=10.10.20.1 firefox
Example:
$ firejail --disable-mnt firefox
Example:
$ firejail --dns=8.8.8.8 --dns=8.8.4.4 firefox
Note: this feature is not supported on systemd-resolved setups.
Example:
$ firejail --name=mygame --caps.drop=all warzone2100 &
$ firejail --dns.print=mygame
Example:
$ firejail --list
3272:netblue::firejail --private firefox
$ firejail --dns.print=3272
Without a name/pid, Firejail will monitor the main system network namespace.
Example:
$ sudo firejail --dnstrace
11:31:43 9.9.9.9 linux.com (type 1)
11:31:45 9.9.9.9 fonts.googleapis.com (type 1) NXDOMAIN
11:31:45 9.9.9.9 js.hs-scripts.com (type 1) NXDOMAIN
11:31:45 9.9.9.9 www.linux.com (type 1)
11:31:45 9.9.9.9 fonts.googleapis.com (type 1) NXDOMAIN
11:31:52 9.9.9.9 js.hs-scripts.com (type 1) NXDOMAIN
11:32:05 9.9.9.9 secure.gravatar.com (type 1)
11:32:06 9.9.9.9 secure.gravatar.com (type 1)
11:32:08 9.9.9.9 taikai.network (type 1)
11:32:08 9.9.9.9 cdn.jsdelivr.net (type 1)
11:32:08 9.9.9.9 taikai.azureedge.net (type 1)
11:32:08 9.9.9.9 www.youtube.com (type 1)
Example:
$ firejail --env=LD_LIBRARY_PATH=/opt/test/lib
Example:
$ firejail --name=mygame --caps.drop=all warzone2100 &
$ firejail --fs.print=mygame
Example:
$ firejail --list
3272:netblue::firejail --private firefox
$ firejail --fs.print=3272
Example:
$ firejail --hostname=officepc firefox
Example:
$ firejail --hosts-file=~/myhosts firefox
Example:
$ firejail --ids-check
Example:
$ firejail --ids-init
Example:
$ firejail --ignore=seccomp --ignore=caps firefox
$ firejail --ignore="net eth0" firefox
Without a name/pid, Firejail will monitor the main system network namespace.
Example
$ sudo firejail --icmptrace
20:53:54 192.168.1.60 -> 142.250.65.174 - 98 bytes - Echo request/0
20:53:54 142.250.65.174 -> 192.168.1.60 - 98 bytes - Echo reply/0
20:53:55 192.168.1.60 -> 142.250.65.174 - 98 bytes - Echo request/0
20:53:55 142.250.65.174 -> 192.168.1.60 - 98 bytes - Echo reply/0
20:53:55 192.168.1.60 -> 1.1.1.1 - 154 bytes - Destination
unreachable/Port unreachable
Example:
$ firejail --include=/etc/firejail/disable-devel.inc gedit
Example:
$ firejail --interface=eth1 --interface=eth0.vlan100
Example:
$ firejail --net=eth0 --ip=10.10.20.56 firefox
Example:
$ firejail --net=eth0 --ip=none
If the corresponding interface doesn't have an IP address configured, this option is enabled by default.
Example:
$ firejail --net=br0 --ip=dhcp
This option should not be used in conjunction with the --dns option if the DHCP server is set to configure DNS servers for the clients, because the manually specified DNS servers will be overwritten.
The DHCP client will NOT release the DHCP lease when the sandbox terminates. If your DHCP server requires leases to be explicitly released, consider running a DHCP client and releasing the lease manually in conjunction with the --net=none option.
Example:
$ firejail --net=eth0 --ip6=2001:0db8:0:f101::1/64 firefox
Note: you don't need this option if you obtain your ip6 address from router via SLAAC (your ip6 address and default route will be configured by kernel automatically).
Example:
$ firejail --net=br0 --ip6=dhcp
This option should not be used in conjunction with the --dns option if the DHCP server is set to configure DNS servers for the clients, because the manually specified DNS servers will be overwritten.
The DHCP client will NOT release the DHCP lease when the sandbox terminates. If your DHCP server requires leases to be explicitly released, consider running a DHCP client and releasing the lease manually.
Example:
$ firejail --net=eth0 --iprange=192.168.1.100,192.168.1.150
Example:
$ firejail --ipc-namespace firefox
Example:
$ firejail --name=mygame --caps.drop=all warzone2100 &
$ firejail --join=mygame
Example:
$ firejail --list
3272:netblue::firejail --private firefox
$ firejail --join=3272
# start firefox
$ firejail --net=eth0 --name=browser firefox &
# change netfilter configuration
$ sudo firejail --join-network=browser bash -c "cat
/etc/firejail/nolocal.net | /sbin/iptables-restore"
# verify netfilter configuration
$ sudo firejail --join-network=browser /sbin/iptables -vL
# verify IP addresses
$ sudo firejail --join-network=browser ip addr
Switching to pid 1932, the first child process inside the sandbox
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0-1931: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
noqueue state UNKNOWN group default
link/ether 76:58:14:42:78:e4 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.158/24 brd 192.168.1.255 scope global eth0-1931
valid_lft forever preferred_lft forever
inet6 fe80::7458:14ff:fe42:78e4/64 scope link
valid_lft forever preferred_lft forever
Example:
$ firejail --keep-config-pulse firefox
Example:
$ firejail --keep-dev-shm --private-dev
Example:
$ firejail --keep-fd=all
Example:
$ firejail --keep-fd=3,4,5
Example:
$ firejail --keep-var-tmp
Example:
$ firejail --list
7015:netblue:browser:firejail firefox
7056:netblue:torrent:firejail --net=eth0 transmission-gtk
7064:netblue::firejail --noroot xterm
Example:
$ firejail --net=eth0 --mac=00:11:22:33:44:55 firefox
Example:
$ firejail --machine-id
Example:
$ firejail --mkdir=~/work/project
Example:
$ firejail --mkfile=~/work/project/readme
Note: shmat is not implemented as a system call on some platforms including i386, and it cannot be handled by seccomp-bpf.
Example:
$ firejail --net=eth0 --mtu=1492
In case the name supplied by the user is already in use by another sandbox, Firejail will assign a new name as "name-PID", where PID is the process ID of the sandbox. This functionality can be disabled at run time in /etc/firejail/firejail.config file, by setting "name-change" flag to "no".
Example:
$ firejail --name=browser firefox &
$ firejail --name=browser --private firefox --no-remote &
$ firejail --list
1198:netblue:browser:firejail --name=browser firefox
1312:netblue:browser-1312:firejail --name=browser --private firefox
--no-remote
Example:
$ sudo brctl addbr br0
$ sudo ifconfig br0 10.10.20.1/24
$ sudo brctl addbr br1
$ sudo ifconfig br1 10.10.30.1/24
$ firejail --net=br0 --net=br1
Example:
$ firejail --net=eth0 --ip=192.168.1.80 --dns=8.8.8.8 firefox
$ firejail --net=wlan0 firefox
Example:
$ firejail --net=none vlc
Note: --net=none can crash the application on some platforms. In these cases, it can be replaced with --protocol=unix.
Example:
$ firejail --net=tap0 --ip=10.10.20.80 --netmask=255.255.255.0
--defaultgw=10.10.20.1 firefox
$ firejail --net.print=browser
Switching to pid 1853, the first child process inside the sandbox
Interface MAC IP Mask Status
lo 127.0.0.1 255.0.0.0 UP
eth0-1852 5e:fb:8e:27:29:26 192.168.1.186 255.255.255.0 UP
The default firewall is optimized for regular desktop applications. No incoming connections are accepted:
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# allow ping
-A INPUT -p icmp --icmp-type destination-unreachable -j ACCEPT
-A INPUT -p icmp --icmp-type time-exceeded -j ACCEPT
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT
# drop STUN (WebRTC) requests
-A OUTPUT -p udp --dport 3478 -j DROP
-A OUTPUT -p udp --dport 3479 -j DROP
-A OUTPUT -p tcp --dport 3478 -j DROP
-A OUTPUT -p tcp --dport 3479 -j DROP
COMMIT
Example:
$ firejail --net=eth0 --netfilter firefox
Please use the regular iptables-save/iptables-restore format for the filter file. The following examples are available in /etc/firejail directory:
webserver.net is a webserver firewall that allows access only to TCP ports 80 and 443. Example:
$ firejail --netfilter=/etc/firejail/webserver.net --net=eth0
\
/etc/init.d/apache2 start
nolocal.net/nolocal6.net is a desktop client firewall that disable access to local network. Example:
$ firejail --netfilter=/etc/firejail/nolocal.net \
--net=eth0 firefox
$ firejail --net=eth0 --ip=192.168.1.105 \
--netfilter=/etc/firejail/tcpserver.net,5001 server-program
$ firejail --name=browser --net=eth0 --netfilter firefox &
$ firejail --netfilter.print=browser
$ firejail --name=browser --net=eth0 --netfilter firefox &
$ firejail --netfilter6.print=browser
Use the network locking feature to build and deploy a custom network firewall in your sandbox. The firewall allows only the traffic to the IP addresses detected during the program startup. Traffic to any other address is quietly dropped. By default the network monitoring time is one minute.
A network namespace (--net=eth0) is required for this feature to work. Example:
$ firejail --net=eth0 --netlock \
--private=~/tor-browser_en-US ./start-tor-browser.desktop
$ sudo /sbin/brctl addbr br0
$ sudo /sbin/ifconfig br0 up
$ firejail --ip=10.10.20.67 --netmask=255.255.255.0
--defaultgw=10.10.20.1
Example:
$ firejail --netstats
PID User RX(KB/s) TX(KB/s) Command
1294 netblue 53.355 1.473 firejail --net=eth0 firefox
7383 netblue 9.045 0.112 firejail --net=eth0 transmission
Without a name/pid, Firejail will monitor the main system network namespace.
Example:
$ sudo firejail --nettrace
95 KB/s geoip 457, IP database 4436
52 KB/s *********** 64.222.84.207:443 United States
33 KB/s ******* 89.147.74.105:63930 Hungary
0 B/s 45.90.28.0:443 NextDNS
0 B/s 94.70.122.176:52309(UDP) Greece
339 B/s 104.26.7.35:443 Cloudflare
If /usr/bin/geoiplookup is installed (geoip-bin package in Debian), the country the traffic originates from is added to the trace. We also use the static IP map in /usr/lib/firejail/static-ip-map to print the domain names for some of the more common websites and cloud platforms. No external services are contacted for reverse IP lookup.
Example:
$ firejail --nice=2 firefox
Example:
$ firejail --no3d firefox
Example:
$ firejail
$ nc dict.org 2628
bash: /bin/nc: Permission denied
$ exit
$ firejail --noblacklist=/bin/nc
$ nc dict.org 2628
220 pan.alephnull.com dictd 1.12.1/rf on Linux 3.14-1-amd64
Example:
$ firejail --nodbus --net=none
Example:
$ firejail --nodvd
Example:
$ firejail --noinput
Example:
$ firejail --noexec=/tmp
/etc and /var are noexec by default if the sandbox was started as a regular user.
Note: By default all regular user groups are removed with the exception of the current user. This can be changed using --allusers command option.
Example:
$ id
uid=1000(netblue) gid=1000(netblue)
groups=1000(netblue),24(cdrom),25(floppy),27(sudo),29(audio)
$ firejail --nogroups
Parent pid 8704, child pid 8705
Child process initialized
$ id
uid=1000(netblue) gid=1000(netblue) groups=1000(netblue)
$
Example:
$ firejail
Reading profile /etc/firejail/default.profile
Parent pid 8553, child pid 8554
Child process initialized
[...]
$ firejail --noprofile
Parent pid 8553, child pid 8554
Child process initialized
[...]
Example:
$ firejail --noroot
Parent pid 8553, child pid 8554
Child process initialized
$ ping google.com
ping: icmp open socket: Operation not permitted
$
Example:
$ firejail --nosound firefox
Example:
$ firejail --notv vlc
Example:
$ firejail --nou2f
Example:
$ firejail --oom=300 firefox
Example:
$ firejail --output=sandboxlog /bin/bash
[...]
$ ls -l sandboxlog*
-rw-r--r-- 1 netblue netblue 333890 Jun 2 07:48 sandboxlog
-rw-r--r-- 1 netblue netblue 511488 Jun 2 07:48 sandboxlog.1
-rw-r--r-- 1 netblue netblue 511488 Jun 2 07:48 sandboxlog.2
-rw-r--r-- 1 netblue netblue 511488 Jun 2 07:48 sandboxlog.3
-rw-r--r-- 1 netblue netblue 511488 Jun 2 07:48 sandboxlog.4
-rw-r--r-- 1 netblue netblue 511488 Jun 2 07:48 sandboxlog.5
Example:
$ firejail --private firefox
Example:
$ firejail --private=/home/netblue/firefox-home firefox
Bug: Even with this enabled, some commands (such as mkdir, mkfile and private-cache) will still operate on the original home directory. Workaround: Disable the incompatible commands, such as by using "ignore mkdir" and "ignore mkfile". For details, see #903
Example:
$ firejail --private-bin=bash,sed,ls,cat
Parent pid 20841, child pid 20842
Child process initialized
$ ls /bin
bash cat ls sed
Example:
$ firejail --private-cache openbox
Example:
$ pwd
/tmp
$ firejail --private-cwd
$ pwd
/home/user
Example:
$ pwd
/tmp
$ firejail --private-cwd=/opt
$ pwd
/opt
Example:
$ firejail --private-dev
Parent pid 9887, child pid 9888
Child process initialized
$ ls /dev
cdrom cdrw dri dvd dvdrw full log null ptmx pts random shm snd sr0 tty
urandom zero
$
Example:
$ firejail --private-etc=group,hostname,localtime, \
nsswitch.conf,passwd,resolv.conf
Example:
$ firejail --private-home=.mozilla firefox
$ firejail --private-lib galculator
but it gets complicated really fast:
$ firejail --private-lib=x86_64-linux-gnu/xed,x86_64-linux-gnu/gdk-pixbuf-2.0,libenchant.so.1,librsvg-2.so.2 xed
The feature is integrated with --private-bin:
$ firejail --private-lib --private-bin=bash,ls,ps
$ ls /lib
ld-linux-x86-64.so.2 libgpg-error.so.0 libprocps.so.6 libsystemd.so.0
libc.so.6 liblz4.so.1 libpthread.so.0 libtinfo.so.5
libdl.so.2 liblzma.so.5 librt.so.1 x86_64-linux-gnu
libgcrypt.so.20 libpcre.so.3 libselinux.so.1
$ ps
PID TTY TIME CMD
1 pts/0 00:00:00 firejail
45 pts/0 00:00:00 bash
48 pts/0 00:00:00 ps
$
Note: Support for this command is controlled in firejail.config with the private-lib option.
Example:
$ firejail --private-opt=firefox /opt/firefox/firefox
Example:
# firejail --private-srv=www /etc/init.d/apache2 start
Example:
$ firejail --private-tmp
$ ls -al /tmp
drwxrwxrwt 4 nobody nogroup 80 Apr 30 11:46 .
drwxr-xr-x 30 nobody nogroup 4096 Apr 26 22:18 ..
drwx------ 2 nobody nogroup 4096 Apr 30 10:52 pulse-PKdhtXMmr18n
drwxrwxrwt 2 nobody nogroup 4096 Apr 30 10:52 .X11-unix
Example:
$ firejail --profile=myprofile
Example:
$ firejail --profile.print=browser
/etc/firejail/firefox.profile
Example:
$ firejail --protocol=unix,inet,inet6 firefox
Example:
$ firejail --name=mybrowser firefox &
$ firejail --protocol.print=mybrowser
unix,inet,inet6,netlink
Example:
$ firejail --list
3272:netblue::firejail --private firefox
$ firejail --protocol.print=3272
unix,inet,inet6,netlink
The same effect can be obtained by setting an environment variable FIREJAIL_QUIET to yes.
Example:
$ firejail --read-only=~/.mozilla firefox
$ mkdir ~/test
$ touch ~/test/a
$ firejail --read-only=~/test --read-write=~/test/a
Example:
$ firejail --restrict-namespaces
Example:
$ firejail --restrict-namespaces=user,net
The CPU limit is a limit on CPU seconds rather than elapsed time. CPU seconds is basically how many seconds the CPU has been in use and does not necessarily directly relate to the elapsed time. Linux kernel keeps track of CPU seconds for each process independently.
Example:
$ firejail --rmenv=DBUS_SESSION_BUS_ADDRESS
Example:
$ firejail --net=eth0 --scan
To help creating useful seccomp filters more easily, the following system call groups are defined: @aio, @basic-io, @chown, @clock, @cpu-emulation, @debug, @default, @default-nodebuggers, @default-keep, @file-system, @io-event, @ipc, @keyring, @memlock, @module, @mount, @network-io, @obsolete, @privileged, @process, @raw-io, @reboot, @resources, @setuid, @swap, @sync, @system-service and @timer. More information about groups can be found in /usr/share/doc/firejail/syscalls.txt
The default list can be customized, see --seccomp= for a description. It can be customized also globally in /etc/firejail/firejail.config file.
System architecture is strictly imposed only if flag --seccomp.block-secondary is used. The filter is applied at run time only if the correct architecture was detected. For the case of I386 and AMD64 both 32-bit and 64-bit filters are installed.
Firejail will print seccomp violations to the audit log if the kernel was compiled with audit support (CONFIG_AUDIT flag).
Example:
$ firejail --seccomp
Example:
$ firejail --seccomp=utime,utimensat,utimes firefox
$ firejail --seccomp=@clock,mkdir,unlinkat transmission-gtk
$ firejail '--seccomp=@ipc,!pipe,!pipe2' audacious
Syscalls can be specified by their number if prefix $ is added, so for example $165 would be equal to mount on i386.
Instead of dropping the syscall by returning EPERM, another error number can be returned using syscall:errno syntax. This can be also changed globally with --seccomp-error-action or in /etc/firejail/firejail.config file. The process can also be killed by using syscall:kill syntax, or the attempt may be logged with syscall:log.
Example:
$ firejail --seccomp=unlinkat:ENOENT,utimensat,utimes
Parent pid 10662, child pid 10663
Child process initialized
$ touch testfile
$ ls testfile
testfile
$ rm testfile
rm: cannot remove `testfile': No such file or directory
If the blocked system calls would also block Firejail from operating, they are handled by adding a preloaded library which performs seccomp system calls later. However, this is incompatible with 32 bit seccomp filters.
Example:
$ firejail --noprofile --seccomp=execve sh
Parent pid 32751, child pid 32752
Post-exec seccomp protector enabled
list in: execve, check list: @default-keep prelist: (null), postlist:
execve
Child process initialized in 46.44 ms
$ ls
Operation not permitted
Example:
$ firejail --seccomp.drop=utime,utimensat,utimes,@clock
Instead of dropping the syscall by returning EPERM, another error number can be returned using syscall:errno syntax. This can be also changed globally with --seccomp-error-action or in /etc/firejail/firejail.config file. The process can also be killed by using syscall:kill syntax, or the attempt may be logged with syscall:log.
Example:
$ firejail --seccomp.drop=unlinkat:ENOENT,utimensat,utimes
Parent pid 10662, child pid 10663
Child process initialized
$ touch testfile
$ ls testfile
testfile
$ rm testfile
rm: cannot remove `testfile': No such file or directory
Example:
$ firejail --seccomp.keep=poll,select,[...] transmission-gtk
Example:
$ firejail --name=browser firefox &
$ firejail --seccomp.print=browser
line OP JT JF K
=================================
0000: 20 00 00 00000004 ld data.architecture
0001: 15 01 00 c000003e jeq ARCH_64 0003 (false 0002)
0002: 06 00 00 7fff0000 ret ALLOW
0003: 20 00 00 00000000 ld data.syscall-number
0004: 35 01 00 40000000 jge X32_ABI true:0006 (false 0005)
0005: 35 01 00 00000000 jge read 0007 (false 0006)
0006: 06 00 00 00050001 ret ERRNO(1)
0007: 15 41 00 0000009a jeq modify_ldt 0049 (false 0008)
0008: 15 40 00 000000d4 jeq lookup_dcookie 0049 (false 0009)
0009: 15 3f 00 0000012a jeq perf_event_open 0049 (false 000a)
000a: 15 3e 00 00000137 jeq process_vm_writev 0049 (false 000b)
000b: 15 3d 00 0000009c jeq _sysctl 0049 (false 000c)
000c: 15 3c 00 000000b7 jeq afs_syscall 0049 (false 000d)
000d: 15 3b 00 000000ae jeq create_module 0049 (false 000e)
000e: 15 3a 00 000000b1 jeq get_kernel_syms 0049 (false 000f)
000f: 15 39 00 000000b5 jeq getpmsg 0049 (false 0010)
0010: 15 38 00 000000b6 jeq putpmsg 0049 (false 0011)
0011: 15 37 00 000000b2 jeq query_module 0049 (false 0012)
0012: 15 36 00 000000b9 jeq security 0049 (false 0013)
0013: 15 35 00 0000008b jeq sysfs 0049 (false 0014)
0014: 15 34 00 000000b8 jeq tuxcall 0049 (false 0015)
0015: 15 33 00 00000086 jeq uselib 0049 (false 0016)
0016: 15 32 00 00000088 jeq ustat 0049 (false 0017)
0017: 15 31 00 000000ec jeq vserver 0049 (false 0018)
0018: 15 30 00 0000009f jeq adjtimex 0049 (false 0019)
0019: 15 2f 00 00000131 jeq clock_adjtime 0049 (false 001a)
001a: 15 2e 00 000000e3 jeq clock_settime 0049 (false 001b)
001b: 15 2d 00 000000a4 jeq settimeofday 0049 (false 001c)
001c: 15 2c 00 000000b0 jeq delete_module 0049 (false 001d)
001d: 15 2b 00 00000139 jeq finit_module 0049 (false 001e)
001e: 15 2a 00 000000af jeq init_module 0049 (false 001f)
001f: 15 29 00 000000ad jeq ioperm 0049 (false 0020)
0020: 15 28 00 000000ac jeq iopl 0049 (false 0021)
0021: 15 27 00 000000f6 jeq kexec_load 0049 (false 0022)
0022: 15 26 00 00000140 jeq kexec_file_load 0049 (false 0023)
0023: 15 25 00 000000a9 jeq reboot 0049 (false 0024)
0024: 15 24 00 000000a7 jeq swapon 0049 (false 0025)
0025: 15 23 00 000000a8 jeq swapoff 0049 (false 0026)
0026: 15 22 00 000000a3 jeq acct 0049 (false 0027)
0027: 15 21 00 00000141 jeq bpf 0049 (false 0028)
0028: 15 20 00 000000a1 jeq chroot 0049 (false 0029)
0029: 15 1f 00 000000a5 jeq mount 0049 (false 002a)
002a: 15 1e 00 000000b4 jeq nfsservctl 0049 (false 002b)
002b: 15 1d 00 0000009b jeq pivot_root 0049 (false 002c)
002c: 15 1c 00 000000ab jeq setdomainname 0049 (false 002d)
002d: 15 1b 00 000000aa jeq sethostname 0049 (false 002e)
002e: 15 1a 00 000000a6 jeq umount2 0049 (false 002f)
002f: 15 19 00 00000099 jeq vhangup 0049 (false 0030)
0030: 15 18 00 000000ee jeq set_mempolicy 0049 (false 0031)
0031: 15 17 00 00000100 jeq migrate_pages 0049 (false 0032)
0032: 15 16 00 00000117 jeq move_pages 0049 (false 0033)
0033: 15 15 00 000000ed jeq mbind 0049 (false 0034)
0034: 15 14 00 00000130 jeq open_by_handle_at 0049 (false 0035)
0035: 15 13 00 0000012f jeq name_to_handle_at 0049 (false 0036)
0036: 15 12 00 000000fb jeq ioprio_set 0049 (false 0037)
0037: 15 11 00 00000067 jeq syslog 0049 (false 0038)
0038: 15 10 00 0000012c jeq fanotify_init 0049 (false 0039)
0039: 15 0f 00 00000138 jeq kcmp 0049 (false 003a)
003a: 15 0e 00 000000f8 jeq add_key 0049 (false 003b)
003b: 15 0d 00 000000f9 jeq request_key 0049 (false 003c)
003c: 15 0c 00 000000fa jeq keyctl 0049 (false 003d)
003d: 15 0b 00 000000ce jeq io_setup 0049 (false 003e)
003e: 15 0a 00 000000cf jeq io_destroy 0049 (false 003f)
003f: 15 09 00 000000d0 jeq io_getevents 0049 (false 0040)
0040: 15 08 00 000000d1 jeq io_submit 0049 (false 0041)
0041: 15 07 00 000000d2 jeq io_cancel 0049 (false 0042)
0042: 15 06 00 000000d8 jeq remap_file_pages 0049 (false 0043)
0043: 15 05 00 00000116 jeq vmsplice 0049 (false 0044)
0044: 15 04 00 00000087 jeq personality 0049 (false 0045)
0045: 15 03 00 00000143 jeq userfaultfd 0049 (false 0046)
0046: 15 02 00 00000065 jeq ptrace 0049 (false 0047)
0047: 15 01 00 00000136 jeq process_vm_readv 0049 (false 0048)
0048: 06 00 00 7fff0000 ret ALLOW
0049: 06 00 01 00000000 ret KILL
$
Example:
$ firejail --name=mygame --caps.drop=all warzone2100 &
$ firejail --shutdown=mygame
Example:
$ firejail --list
3272:netblue::firejail --private firefox
$ firejail --shutdown=3272
Without a name/pid, Firejail will monitor the main system network namespace.
Example:
$ sudo firejail --snitrace
07:49:51 23.185.0.3 linux.com
07:49:51 23.185.0.3 www.linux.com
07:50:05 192.0.73.2 secure.gravatar.com
07:52:35 172.67.68.93 www.howtoforge.com
07:52:37 13.225.103.59 sf.ezoiccdn.com
07:52:42 142.250.176.3 www.gstatic.com
07:53:03 173.236.250.32 www.linuxlinks.com
07:53:05 192.0.77.37 c0.wp.com
07:53:08 192.0.78.32 jetpack.wordpress.com
07:53:09 192.0.77.32 s0.wp.com
07:53:09 192.0.77.2 i0.wp.com
07:53:10 192.0.77.2 i0.wp.com
07:53:11 192.0.73.2 1.gravatar.com
$ firejail --private --tab
$ firejail --timeout=01:30:00 firefox
Example:
$ firejail --tmpfs=~/.local/share
Example:
$ firejail --top
Example:
$ firejail --trace wget -q www.debian.org
Reading profile /etc/firejail/wget.profile
3:wget:fopen64 /etc/wgetrc:0x5c8e8ce6c0
3:wget:fopen /etc/hosts:0x5c8e8cfb70
3:wget:socket AF_INET SOCK_DGRAM IPPROTO_IP:3
3:wget:connect 3 8.8.8.8 port 53:0
3:wget:socket AF_INET SOCK_STREAM IPPROTO_IP:3
3:wget:connect 3 130.89.148.14 port 80:0
3:wget:fopen64 index.html:0x5c8e8d1a60
parent is shutting down, bye...
Example:
$ firejail --tracelog firefox
Sample messages:
$ sudo tail -f /var/log/syslog
[...]
Dec 3 11:43:25 debian firejail[70]: blacklist violation - sandbox 26370,
exe firefox, syscall open64, path /etc/shadow
Dec 3 11:46:17 debian firejail[70]: blacklist violation - sandbox 26370,
exe firefox, syscall opendir, path /boot
[...]
Note: Support for this command is controlled in firejail.config with the tracelog option.
Example:
$ firejail --tree
11903:netblue:firejail iceweasel
11904:netblue:iceweasel
11957:netblue:/usr/lib/iceweasel/plugin-container
11969:netblue:firejail --net=eth0 transmission-gtk
11970:netblue:transmission-gtk
Example:
$ firejail --version
firejail version 0.9.27
Compile time support:
- AppArmor support is enabled
- AppImage support is enabled
- chroot support is enabled
- file and directory whitelisting support is enabled
- file transfer support is enabled
- firetunnel support is enabled
- networking support is enabled
- overlayfs support is enabled
- private-home support is enabled
- seccomp-bpf support is enabled
- user namespace support is enabled
- X11 sandboxing support is enabled
Example:
$ firejail --net=br0 --veth-name=if0
Symbolic link handling: Whitelisting a path that is a symbolic link will also whitelist the path that it points to. For example, if ~/foo is whitelisted and it points to ~/bar, then ~/bar will also be whitelisted. Restrictions: With the exception of the user home directory, both the link and the real file should be in the same top directory. For symbolic links in the user home directory, both the link and the real file should be owned by the user.
File globbing is supported, see FILE GLOBBING section for more details.
Example:
$ firejail --noprofile --whitelist=~/.mozilla
$ firejail --whitelist=/tmp/.X11-unix --whitelist=/dev/null
$ firejail "--whitelist=/home/username/My Virtual Machines"
$ firejail --whitelist=~/work* --whitelist=/var/backups*
Example:
$ sudo firejail --writable-etc
Example:
$ sudo firejail --writable-run-user
Example:
$ sudo firejail --writable-var
Example:
$ sudo firejail --writable-var-log
Xpra, Xephyr and Xvfb modes require a network namespace to be instantiated in order to disable X11 abstract Unix socket. If this is not possible, the user can disable the abstract socket by adding "-nolisten local" on Xorg command line at system level.
Example:
$ firejail --x11 --net=eth0 firefox
Xephyr runs in a window just like any other X11 application. The default window size is 800x600. This can be modified in /etc/firejail/firejail.config file.
The recommended way to use this feature is to run a window manager inside the sandbox. A security profile for OpenBox is provided.
Xephyr is developed by Xorg project. On Debian platforms it is installed with the command sudo apt-get install xserver-xephyr. This feature is not available when running as root.
Example:
$ firejail --x11=xephyr --net=eth0 openbox
The untrusted mode has several limitations. A lot of regular programs assume they are a trusted X11 clients and will crash or lock up when run in untrusted mode. Chromium browser and xterm are two examples. Firefox and transmission-gtk seem to be working fine. A network namespace is not required for this option.
Example:
$ firejail --x11=xorg firefox
On Debian platforms Xpra is installed with the command sudo apt-get install xpra. This feature is not available when running as root.
Example:
$ firejail --x11=xpra --net=eth0 firefox
On Debian platforms Xvfb is installed with the command sudo apt-get install xvfb. This feature is not available when running as root.
Example: remote VNC access
On the server we start a sandbox using Xvfb and openbox window manager. The default size of Xvfb screen is 800x600 - it can be changed in /etc/firejail/firejail.config (xvfb-screen). Some sort of networking (--net) is required in order to isolate the abstract sockets used by other X servers.
$ firejail --net=none --x11=xvfb openbox
*** Attaching to Xvfb display 792 ***
Reading profile /etc/firejail/openbox.profile
Reading profile /etc/firejail/disable-common.inc
Reading profile /etc/firejail/disable-common.local
Parent pid 5400, child pid 5401
On the server we also start a VNC server and attach it to the display handled by our Xvfb server (792).
$ x11vnc -display :792
On the client machine we start a VNC viewer and use it to connect to our server:
$ vncviewer
Example:
$ firejail --net=eth0 --x11=xephyr --xephyr-screen=640x480 firefox
$ ./configure --prefix=/usr --enable-apparmor
# apparmor_parser -r /etc/apparmor.d/firejail-default
- Disable ptrace. With ptrace it is possible to inspect and hijack running programs. Usually this is needed only for debugging. You should have no problems running Chromium or Firefox. This feature is available only on Ubuntu kernels.
- Whitelist write access to several files under /run, /proc and /sys.
- Allow running programs only from well-known system paths, such as /bin, /sbin, /usr/bin etc. Those paths are available as read-only. Running programs and scripts from user home or other directories writable by the user is not allowed.
- Prevent using non-standard network sockets. Only unix, inet, inet6, netlink, raw and packet are allowed.
- Deny access to known sensitive paths like .snapshots.
$ firejail --apparmor firefox
A symbolic link to /usr/bin/firejail under the name of a program, will start the program in Firejail sandbox. The symbolic link should be placed in the first $PATH position. On most systems, a good place is /usr/local/bin directory. Example:
Make a firefox symlink to /usr/bin/firejail:
$ sudo ln -s /usr/bin/firejail /usr/local/bin/firefox
Verify $PATH
$ which -a firefox
/usr/local/bin/firefox
/usr/bin/firefox
Starting firefox in this moment, automatically invokes “firejail firefox”.
This works for clicking on desktop environment icons, menus etc. Use "firejail --tree" to verify the program is sandboxed.
$ firejail --tree
1189:netblue:firejail firefox
1190:netblue:firejail firefox
1220:netblue:/bin/sh -c "/usr/lib/firefox/firefox"
1221:netblue:/usr/lib/firefox/firefox
We provide a tool that automates all this integration, please see firecfg(1) for more details.
- '?' matches any character
- '*' matches any string
- '[' denotes a range of characters
$ firejail --private-bin=sh,bash,python*
$ firejail --blacklist=~/dir[1234]
$ firejail --read-only=~/dir[1-4]
These features allow the user to inspect the filesystem container of an existing sandbox and transfer files between the container and the host filesystem.
$ firejail --name=mybrowser --private firefox
$ firejail --ls=mybrowser ~/Downloads
drwxr-xr-x netblue netblue 4096 .
drwxr-xr-x netblue netblue 4096 ..
-rw-r--r-- netblue netblue 7847 x11-x305.png
-rw-r--r-- netblue netblue 6800 x11-x642.png
-rw-r--r-- netblue netblue 34139 xpra-clipboard.png
$ firejail --get=mybrowser ~/Downloads/xpra-clipboard.png
$ firejail --put=mybrowser xpra-clipboard.png ~/Downloads/xpra-clipboard.png
$ firejail --cat=mybrowser ~/.bashrc
The host-based intrusion detection system tracks down and audits user and system file modifications. The feature is configured using /etc/firejail/ids.config file, the checksums are stored in /var/lib/firejail/USERNAME.ids, where USERNAME is the name of the current user. We use BLAKE2 cryptographic function for hashing.
As a regular user, initialize the database:
$ firejail --ids-init
Opening config file /etc/firejail/ids.config
Loading config file /etc/firejail/ids.config
Opening config file /etc/firejail/ids.config.local
500 1000 1500 2000
2466 files scanned
IDS database initialized
The default configuration targets several system executables in directories such as /bin, /sbin, /usr/bin, /usr/sbin, and several critical config files in user home directory such as ~/.bashrc, ~/.xinitrc, and ~/.config/autostart. Several system config files in /etc directory are also hashed.
Run --ids-check to audit the system:
$ firejail --ids-check
Opening config file /etc/firejail/ids.config
Loading config file /etc/firejail/ids.config
Opening config file /etc/firejail/ids.config.local
500 1000 1500
Warning: modified /home/netblue/.bashrc
2000
2466 files scanned: modified 1, permissions 0, new 0, removed 0
The program will print the files that have been modified since the database was created, or the files with different access permissions. New files and deleted files are also flagged.
Currently while scanning the file system, symbolic links are not followed, and files the user doesn't have read access to are silently dropped. The program can also be run as root (sudo firejail --ids-init/--ids-check).
Option --list prints a list of all sandboxes. The format for each process entry is as follows:
PID:USER:Sandbox Name:Command
Option --tree prints the tree of processes running in the sandbox. The format for each process entry is as follows:
PID:USER:Sandbox Name:Command
Option --top is similar to the UNIX top command, however it applies only to sandboxes.
Option --netstats prints network statistics for active sandboxes installing new network namespaces.
Listed below are the available fields (columns) in alphabetical order for --top and --netstats options:
To configure a restricted shell, replace /bin/bash with /usr/bin/firejail in /etc/passwd file for each user that needs to be restricted. Alternatively, you can specify /usr/bin/firejail in adduser command:
adduser --shell /usr/bin/firejail username
Additional arguments passed to firejail executable upon login are declared in /etc/firejail/login.users file.
Several command line options can be passed to the program using profile files. Firejail chooses the profile file as follows:
1. If a profile file is provided by the user with --profile=FILE option, the profile FILE is loaded. If a profile name is given, it is searched for first in the ~/.config/firejail directory and if not found then in /etc/firejail directory. Profile names do not include the .profile suffix. If there is a file with the same name as the given profile name, it will be used instead of doing the profile search. To force a profile search, prefix the profile name with a colon (:), eg. --profile=:PROFILE_NAME. Example:
2. If a profile file with the same name as the application is present in ~/.config/firejail directory or in /etc/firejail, the profile is loaded. ~/.config/firejail takes precedence over /etc/firejail. Example:
3. Use default.profile file if the sandbox is started by a regular user, or server.profile file if the sandbox is started by root. Firejail looks for these files in ~/.config/firejail directory, followed by /etc/firejail directory. To disable default profile loading, use --noprofile command option. Example:
$ firejail --noprofile
Parent pid 8553, child pid 8554
Child process initialized
[...]
See man 5 firejail-profile for profile file syntax information.
Network bandwidth is an expensive resource shared among all sandboxes running on a system. Traffic shaping allows the user to increase network performance by controlling the amount of data that flows into and out of the sandboxes.
Firejail implements a simple rate-limiting shaper based on Linux command tc. The shaper works at sandbox level, and can be used only for sandboxes configured with new network namespaces.
Set rate-limits:
$ firejail --bandwidth=name|pid set network download upload
Clear rate-limits:
$ firejail --bandwidth=name|pid clear network
Status:
$ firejail --bandwidth=name|pid status
where:
name - sandbox name
pid - sandbox pid
network - network interface as used by --net option
download - download speed in KB/s (kilobyte per second)
upload - upload speed in KB/s (kilobyte per second)
Example:
$ firejail --name=mybrowser --net=eth0 firefox &
$ firejail --bandwidth=mybrowser set eth0 80 20
$ firejail --bandwidth=mybrowser status
$ firejail --bandwidth=mybrowser clear eth0
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Homepage: https://firejail.wordpress.com
firemon(1), firecfg(1), firejail-profile(5), firejail-login(5), firejail-users(5), jailcheck(1)
https://github.com/netblue30/firejail/wiki, https://github.com/netblue30/firejail
Jan 2023 | 0.9.72 |