[GH-ISSUE #698] Whitelisting /var is broken #476

Closed
opened 2026-05-05 05:56:03 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @knoy on GitHub (Aug 11, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/698

Inserting the following into a profile:

blacklist /var
whitelist /var/log
whitelist /var/lib

Doesn't work and results in all of /var/lib and /var/log being unreadable.

Adding
--whitelist=/var/lib
as a command line argument makes all of /var visible

Originally created by @knoy on GitHub (Aug 11, 2016). Original GitHub issue: https://github.com/netblue30/firejail/issues/698 Inserting the following into a profile: > blacklist /var > whitelist /var/log > whitelist /var/lib Doesn't work and results in all of /var/lib and /var/log being unreadable. Adding ` --whitelist=/var/lib ` as a command line argument makes all of /var visible
gitea-mirror 2026-05-05 05:56:03 -06:00
Author
Owner

@Fred-Barclay commented on GitHub (Aug 11, 2016):

G'day knoy! What version of firejail are you using?

As far as the profile goes, blacklist should override whitelist in this case, keeping all of /var/ unreadable. What you probably want to do is this
blacklist /var
noblacklist /var/log
noblacklist /var/lib

That will blacklist all of /var except for /var/lib/ and /var/log/.

This is what --whitelist=/var/lib does on my computer:
$ ls /var/
backups cache lib local lock log mail opt run spool state tmp

$ firejail --whitelist=/var/lib /bin/dash
Reading profile /etc/firejail/default.profile
Reading profile /etc/firejail/disable-common.inc
Reading profile /etc/firejail/disable-programs.inc
Reading profile /etc/firejail/disable-passwdmgr.inc

*\* Note: you can use --noprofile to disable default.profile **

Parent pid 15236, child pid 15237

Child process initialized
$ ls /var
lib

Hope this helps. :)
Fred

<!-- gh-comment-id:239233468 --> @Fred-Barclay commented on GitHub (Aug 11, 2016): G'day knoy! What version of firejail are you using? As far as the profile goes, `blacklist` should override `whitelist` in this case, keeping all of /var/ unreadable. What you probably want to do is this `blacklist /var` `noblacklist /var/log` `noblacklist /var/lib` That will blacklist all of /var except for /var/lib/ and /var/log/. This is what `--whitelist=/var/lib` does on my computer: `$ ls /var/` `backups cache lib local lock log mail opt run spool state tmp` `$ firejail --whitelist=/var/lib /bin/dash` `Reading profile /etc/firejail/default.profile` `Reading profile /etc/firejail/disable-common.inc` `Reading profile /etc/firejail/disable-programs.inc` `Reading profile /etc/firejail/disable-passwdmgr.inc` ` ` `*\* Note: you can use --noprofile to disable default.profile **` ` ` `Parent pid 15236, child pid 15237` ` ` `Child process initialized` `$ ls /var` `lib` Hope this helps. :) Fred
Author
Owner

@knoy commented on GitHub (Aug 11, 2016):

I'm on debian using firejail version 0.9.40.

I've tried your 'noblacklist' approach but that doesn't work either:

[jails@jails ~]$ ls -la /var
ls: cannot open directory /var: Permission denied
[jails@jails ~]$ ls -la /var/lib
ls: cannot access /var/lib: Permission denied
[jails@jails ~]$ ls -la /var/log
ls: cannot access /var/log: Permission denied

If I remove the blacklist command in the profile, I can read the dirs no problem

<!-- gh-comment-id:239238421 --> @knoy commented on GitHub (Aug 11, 2016): I'm on debian using firejail version 0.9.40. I've tried your 'noblacklist' approach but that doesn't work either: ``` [jails@jails ~]$ ls -la /var ls: cannot open directory /var: Permission denied [jails@jails ~]$ ls -la /var/lib ls: cannot access /var/lib: Permission denied [jails@jails ~]$ ls -la /var/log ls: cannot access /var/log: Permission denied ``` If I remove the blacklist command in the profile, I can read the dirs no problem
Author
Owner

@knoy commented on GitHub (Aug 11, 2016):

Even without blacklisting at all this is apparently broken for /var/log and /var/lib? Looks like firejail is doing some behind the scenes magic with /var .. specifically a344c555ff/src/firejail/fs_var.c (L110)

This looks like its overriding anything done. A bunch of hardcoded and undocumented paths seems a little messy way to go about this.

<!-- gh-comment-id:239238452 --> @knoy commented on GitHub (Aug 11, 2016): Even without blacklisting at all this is apparently broken for /var/log and /var/lib? Looks like firejail is doing some behind the scenes magic with /var .. specifically https://github.com/netblue30/firejail/blob/a344c555ff282c23a8274d10ad0f75eb4fae6836/src/firejail/fs_var.c#L110 This looks like its overriding anything done. A bunch of hardcoded and undocumented paths seems a little messy way to go about this.
Author
Owner

@Fred-Barclay commented on GitHub (Aug 11, 2016):

Can you post the profile you are using?

<!-- gh-comment-id:239240952 --> @Fred-Barclay commented on GitHub (Aug 11, 2016): Can you post the profile you are using?
Author
Owner

@netblue30 commented on GitHub (Aug 11, 2016):

Let's mark it as a bug, I'll take a look. Yes, Firejail mounts by default a new /var/log and modifies some directories in /var/lib.

<!-- gh-comment-id:239283425 --> @netblue30 commented on GitHub (Aug 11, 2016): Let's mark it as a bug, I'll take a look. Yes, Firejail mounts by default a new /var/log and modifies some directories in /var/lib.
Author
Owner

@netblue30 commented on GitHub (Aug 12, 2016):

@Fred-Barclay is right:

As far as the profile goes, blacklist should override whitelist in this case, keeping all of /var/ unreadable.

By default firejail does a lot of filesystem cleanup before blacklisting and whitelisting. You can see all the steps if you run it with --debug:

$ firejail --debug
Command name #bash#
Attempting to find default.profile...
Found default profile in /etc/firejail directory
Reading profile /etc/firejail/default.profile
Reading profile /etc/firejail/disable-common.inc
Reading profile /etc/firejail/disable-programs.inc
Reading profile /etc/firejail/disable-passwdmgr.inc

** Note: you can use --noprofile to disable default.profile **

DISPLAY :0.0, 0
Using the local network stack
Parent pid 16412, child pid 16413
Initializing child process
Host network configured
PID namespace installed
Mounting tmpfs on /run/firejail/mnt directory
Mounting read-only /bin, /sbin, /lib, /lib32, /lib64, /usr, /etc, /var
Mounting tmpfs on /var/lock
Mounting tmpfs on /var/tmp
Mounting tmpfs on /var/log
Mounting tmpfs on /var/lib/dhcp
Mounting tmpfs on /var/lib/nginx
Mounting tmpfs on /var/lib/sudo
Mounting tmpfs on /var/cache/apache2
Create the new utmp file
Mount the new utmp file
Cleaning /home directory
Sanitizing /etc/passwd, UID_MIN 1000
Sanitizing /etc/group, GID_MIN 1000
Disable /home/netblue/.config/firejail
Disable /run/firejail/network
Disable /run/firejail/bandwidth
Disable /run/firejail/name
Disable /run/firejail/x11
Remounting /proc and /proc/sys filesystems
Remounting /sys directory
Disable /sys/firmware
Disable /sys/hypervisor
Disable /sys/fs
Disable /sys/module
Disable /sys/power
Disable /sys/kernel/debug
Disable /sys/kernel/vmcoreinfo
[...]

What exactly are you trying to do?

<!-- gh-comment-id:239462018 --> @netblue30 commented on GitHub (Aug 12, 2016): @Fred-Barclay is right: > As far as the profile goes, blacklist should override whitelist in this case, keeping all of /var/ unreadable. By default firejail does a lot of filesystem cleanup before blacklisting and whitelisting. You can see all the steps if you run it with --debug: ``` $ firejail --debug Command name #bash# Attempting to find default.profile... Found default profile in /etc/firejail directory Reading profile /etc/firejail/default.profile Reading profile /etc/firejail/disable-common.inc Reading profile /etc/firejail/disable-programs.inc Reading profile /etc/firejail/disable-passwdmgr.inc ** Note: you can use --noprofile to disable default.profile ** DISPLAY :0.0, 0 Using the local network stack Parent pid 16412, child pid 16413 Initializing child process Host network configured PID namespace installed Mounting tmpfs on /run/firejail/mnt directory Mounting read-only /bin, /sbin, /lib, /lib32, /lib64, /usr, /etc, /var Mounting tmpfs on /var/lock Mounting tmpfs on /var/tmp Mounting tmpfs on /var/log Mounting tmpfs on /var/lib/dhcp Mounting tmpfs on /var/lib/nginx Mounting tmpfs on /var/lib/sudo Mounting tmpfs on /var/cache/apache2 Create the new utmp file Mount the new utmp file Cleaning /home directory Sanitizing /etc/passwd, UID_MIN 1000 Sanitizing /etc/group, GID_MIN 1000 Disable /home/netblue/.config/firejail Disable /run/firejail/network Disable /run/firejail/bandwidth Disable /run/firejail/name Disable /run/firejail/x11 Remounting /proc and /proc/sys filesystems Remounting /sys directory Disable /sys/firmware Disable /sys/hypervisor Disable /sys/fs Disable /sys/module Disable /sys/power Disable /sys/kernel/debug Disable /sys/kernel/vmcoreinfo [...] ``` What exactly are you trying to do?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#476
No description provided.