[GH-ISSUE #6] Cannot blacklist ${HOME}/.config/firejail #5

Closed
opened 2026-05-05 04:42:41 -06:00 by gitea-mirror · 7 comments
Owner

Originally created by @boltronics on GitHub (Aug 10, 2015).
Original GitHub issue: https://github.com/netblue30/firejail/issues/6

I was surprised there was no line in the default configuration like so:

blacklist ${HOME}/.config/firejail

Without that, an untrusted app could modify its own firejail profile and terminate. When it is relaunched (either automatically via a service management daemon or via user intervention), it could run with elevated privileges.

Even more surprising, manually adding the entry does nothing - the line is silently ignored.

Originally created by @boltronics on GitHub (Aug 10, 2015). Original GitHub issue: https://github.com/netblue30/firejail/issues/6 I was surprised there was no line in the default configuration like so: `blacklist ${HOME}/.config/firejail` Without that, an untrusted app could modify its own firejail profile and terminate. When it is relaunched (either automatically via a service management daemon or via user intervention), it could run with elevated privileges. Even more surprising, manually adding the entry does nothing - the line is silently ignored.
gitea-mirror added the
invalid
label 2026-05-05 04:42:41 -06:00
Author
Owner

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

It seems to be working for me:

$ cat ttt
blacklist ${HOME}/.config/firejail
$ firejail --profile=ttt
Reading profile ttt
Parent pid 24098, child pid 24099
Child process initialized
$ ls ~/.config/firejail
ls: cannot open directory /home/netblue/.config/firejail: Permission denied
$

<!-- gh-comment-id:130354632 --> @netblue30 commented on GitHub (Aug 12, 2015): It seems to be working for me: $ cat ttt blacklist ${HOME}/.config/firejail $ firejail --profile=ttt Reading profile ttt Parent pid 24098, child pid 24099 Child process initialized $ ls ~/.config/firejail ls: cannot open directory /home/netblue/.config/firejail: Permission denied $
Author
Owner

@boltronics commented on GitHub (Aug 15, 2015):

I just tried with the latest from git, and this is still a problem for me, so I digged deeper.

Since I'm using GNU Stow to manage my dotfiles, ~/.config/firejail is actually a symlink. Apparently firejail doesn't support following symlinks, which means many of the default profiles aren't protecting my setup at all. This is a worry.

I believe firejail should be resolving the actual location and blocking that (where blacklist ${HOME}/.config/firejail would effectively be equivalent to blacklist $(readlink -f ${HOME}/.config/firejail).

Please see this link for more information on how it could be done in C:
https://stackoverflow.com/questions/7665/how-to-resolve-symbolic-links-in-a-shell-script

I think this can now be re-opened, or otherwise let me know if you would prefer me to open a new issue.

<!-- gh-comment-id:131275952 --> @boltronics commented on GitHub (Aug 15, 2015): I just tried with the latest from git, and this is still a problem for me, so I digged deeper. Since I'm using GNU Stow to manage my dotfiles, ~/.config/firejail is actually a symlink. Apparently firejail doesn't support following symlinks, which means many of the default profiles aren't protecting my setup at all. This is a worry. I believe firejail should be resolving the actual location and blocking that (where `blacklist ${HOME}/.config/firejail` would effectively be equivalent to `blacklist $(readlink -f ${HOME}/.config/firejail)`. Please see this link for more information on how it could be done in C: https://stackoverflow.com/questions/7665/how-to-resolve-symbolic-links-in-a-shell-script I think this can now be re-opened, or otherwise let me know if you would prefer me to open a new issue.
Author
Owner

@ghost commented on GitHub (Aug 15, 2015):

@boltronics I currently can't reproduce this, I tried blacklisting a symlinked directory and it works fine. It follows the symlink and blocks what it points to. We'd need to know what you're seeing on your machine. Can you please let us know:

  1. The command you run to test whether the blocking is working
  2. The output you see from the command, that tells you firejail isn't blocking properly
  3. What you would expect to see if firejail was working correctly.
<!-- gh-comment-id:131356769 --> @ghost commented on GitHub (Aug 15, 2015): @boltronics I currently can't reproduce this, I tried blacklisting a symlinked directory and it works fine. It follows the symlink and blocks what it points to. We'd need to know what you're seeing on your machine. Can you please let us know: 1. The command you run to test whether the blocking is working 2. The output you see from the command, that tells you firejail isn't blocking properly 3. What you would expect to see if firejail was working correctly.
Author
Owner

@boltronics commented on GitHub (Aug 15, 2015):

@pmillerchip
Strange. I can't see any way to avoid it. :)

1 and 2 - commands and output:

boltron@laptop:~$ ls -ld .config/firejail
lrwxrwxrwx 1 boltron boltron 38 Aug 10 00:38 .config/firejail -> ../stow/firejail/.config/firejail
boltron@laptop:~$ cat ~/.config/firejail/bash.profile 
blacklist /home/boltron/.config/firejail
boltron@laptop:~$ firejail --profile=${HOME}/.config/firejail/bash.profile bash
Reading profile /home/boltron/.config/firejail/bash.profile
Parent pid 30569, child pid 30570
Child process initialized
[boltron@laptop ~]$ ls -l .config/firejail/bash.profile
-rw-r--r-- 1 boltron boltron 40 Aug 16 05:17 .config/firejail/bash.profile
[boltron@laptop ~]$

3 - expected output:

boltron@laptop:~$ ls -ld .config/firejail
lrwxrwxrwx 1 boltron boltron 38 Aug 10 00:38 .config/firejail -> ../stow/firejail/.config/firejail
boltron@laptop:~$ cat ~/.config/firejail/bash.profile 
blacklist /home/boltron/.config/firejail
boltron@laptop:~$ firejail --profile=${HOME}/.config/firejail/bash.profile bash
Reading profile /home/boltron/.config/firejail/bash.profile
Parent pid 30569, child pid 30570
Child process initialized
[boltron@laptop ~]$ ls -l .config/firejail/bash.profile
ls: cannot access .config/firejail/bash.profile: Permission denied
[boltron@laptop ~]$
<!-- gh-comment-id:131431643 --> @boltronics commented on GitHub (Aug 15, 2015): @pmillerchip Strange. I can't see any way to avoid it. :) 1 and 2 - commands and output: ``` boltron@laptop:~$ ls -ld .config/firejail lrwxrwxrwx 1 boltron boltron 38 Aug 10 00:38 .config/firejail -> ../stow/firejail/.config/firejail boltron@laptop:~$ cat ~/.config/firejail/bash.profile blacklist /home/boltron/.config/firejail boltron@laptop:~$ firejail --profile=${HOME}/.config/firejail/bash.profile bash Reading profile /home/boltron/.config/firejail/bash.profile Parent pid 30569, child pid 30570 Child process initialized [boltron@laptop ~]$ ls -l .config/firejail/bash.profile -rw-r--r-- 1 boltron boltron 40 Aug 16 05:17 .config/firejail/bash.profile [boltron@laptop ~]$ ``` 3 - expected output: ``` boltron@laptop:~$ ls -ld .config/firejail lrwxrwxrwx 1 boltron boltron 38 Aug 10 00:38 .config/firejail -> ../stow/firejail/.config/firejail boltron@laptop:~$ cat ~/.config/firejail/bash.profile blacklist /home/boltron/.config/firejail boltron@laptop:~$ firejail --profile=${HOME}/.config/firejail/bash.profile bash Reading profile /home/boltron/.config/firejail/bash.profile Parent pid 30569, child pid 30570 Child process initialized [boltron@laptop ~]$ ls -l .config/firejail/bash.profile ls: cannot access .config/firejail/bash.profile: Permission denied [boltron@laptop ~]$ ```
Author
Owner

@ghost commented on GitHub (Aug 15, 2015):

OK I found (and fixed) the problem! @boltronics had a relative symlink (i.e. it started with ../) and firejail wasn't handling that right.

@netblue30 : I've made a pull request to fix this, it just calls the realpath standard library function to do all the hard work for us, and it fixes the problem.

@boltronics : Please compile firejail from the symlink-bug branch of my firejail repo here: https://github.com/pmillerchip/firejail.git ...and let me know if it fixes it for you.

<!-- gh-comment-id:131447062 --> @ghost commented on GitHub (Aug 15, 2015): OK I found (and fixed) the problem! @boltronics had a relative symlink (i.e. it started with `../`) and firejail wasn't handling that right. @netblue30 : I've made a pull request to fix this, it just calls the `realpath` standard library function to do all the hard work for us, and it fixes the problem. @boltronics : Please compile firejail from the `symlink-bug` branch of my firejail repo here: https://github.com/pmillerchip/firejail.git ...and let me know if it fixes it for you.
Author
Owner

@boltronics commented on GitHub (Aug 16, 2015):

@pmillerchip Thanks for the quick patch! It's definitely making a difference, but not the right kind of difference. :)

Edit:
Sorry. I clearly looked at this too early in the morning, and made a mistake. The patch works fine. :)

<!-- gh-comment-id:131490456 --> @boltronics commented on GitHub (Aug 16, 2015): @pmillerchip Thanks for the quick patch! It's definitely making a difference, but not the right kind of difference. :) Edit: Sorry. I clearly looked at this too early in the morning, and made a mistake. The patch works fine. :)
Author
Owner

@ghost commented on GitHub (Aug 16, 2015):

That's great news, glad it works for you. The pull request is up, so hopefully @netblue30 will merge it soon.

<!-- gh-comment-id:131520774 --> @ghost commented on GitHub (Aug 16, 2015): That's great news, glad it works for you. The pull request is up, so hopefully @netblue30 will merge it soon.
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#5
No description provided.