mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #5] Whitelist /media directory #6
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @boltronics on GitHub (Aug 9, 2015).
Original GitHub issue: https://github.com/netblue30/firejail/issues/5
Currently, it is possible to create a filesystem blacklist:
However, we cannot create a whitelist in the same way. It would be useful to support both blacklist and whitelist options in the same profile.
Use case:
Often it's easier (and safer, in the event of filesystem changes) to just specify one or two files in a directory you want to grant access to. eg.
@netblue30 commented on GitHub (Aug 10, 2015):
This is by far the most requested feature. The problem is once "blacklist /etc" is executed, the directory disappears and "whiltelist /etc/fstab" will not find /etc/fstab.
I did something similar to whitelist for home directory in --private.keep option. The man description is as follows:
I'll do the same for /etc directory in a new option --etc.keep. In the profile file it will look like:
@boltronics commented on GitHub (Aug 10, 2015):
Hmm... I understand. Would it be possible then to not have the modifications discarded?
So for example, if I wanted to run Iceweasel but only grant access to ${HOME}/.mozilla, ${HOME}/Downloads and nothing else. I could use the --private.keep=..., but then it sounds like my bookmarks and downloads would disappear.
I realise this gets a bit messy when we have multiple applications wanting .mozilla access... I'm not sure of a good solution to deal with that. Maybe recursively creating hard links for anything specified by --private.keep would work?
@ghost commented on GitHub (Aug 12, 2015):
@boltronics For Iceweasel/Firefox I just create a "firefox" directory in $HOME, then start firejail with the "--private=firefox" option. That way the browser has its own private home directory that other apps can see too. Downloads go to ~/firefox/Downloads and can be seen from outside firejail.
@boltronics commented on GitHub (Aug 12, 2015):
@pmillerchip Thanks for the tip; that actually works pretty well.
The only nitpick I have there is that the
privateargument/profile option does not create the directory automatically if it does not already exist. That means I can't just update all my firejail profiles with with the private option, commit to git and deploy everywhere - I need to keep track of a set of basically empty directories everywhere as well, or (more likely) create and commit a script to create them where required.But this approach is certainly an improvement and gets me most of where I want to be - provided the things I want to blacklist are all under ${HOME}.
@ghost commented on GitHub (Aug 12, 2015):
@boltronics Creating the directory is certainly possible, but I don't want to write that myself and submit a pull request because I'd be wary of introducing security holes. We'd have a SUID binary creating things in the filesystem on behalf of an unprivileged user using a path they supplied, so you'd have to be extremely careful writing that code. Personally I like the way firejail works at the moment, where if any tiny thing is wrong it exits immediately. As it's SUID root it makes me feel more comfortable.
@boltronics commented on GitHub (Aug 12, 2015):
@pmillerchip That's a really good point.
With that in mind, why do we have firejail set to be SUID directly? If we look at Chromium (for example),
/usr/bin/chromiumis not SUID, but rather it calls/usr/lib/chromium/chrome-sandboxfor just the part of the execution where it's strictly required. For example, I can delete that file, andchromium --versionstill works as expected.It seems firejail would probably benefit from a similar setup (and we already have a couple of executable files under
/usr/lib/firejailtoo). I imagine that would alleviate such concerns?There's probably a fair bit of code running SUID already that isn't strictly necessary, such as (I imagine) the config parser stuff.
@ghost commented on GitHub (Aug 12, 2015):
@boltronics I did some looking, it seems firejail already performs some copying in the "--private.keep" option. It forks a child process which drops all privileges and performs the copy. As there's already code for this, it could be adapted to set up the private home directory in the same way for the "--private=dir" option.
Restructuring firejail with a separate SUID part is a nice idea, but I fear it would be a lot of work for poor netblue30!
@netblue30 commented on GitHub (Aug 12, 2015):
pmillerchip is right, I'm asking for trouble creating new directories.
I ended up implementing a --private-etc option as follows:
(similar for profiles)
@boltronics commented on GitHub (Aug 12, 2015):
Thanks netblue30!
@netblue30 commented on GitHub (Aug 12, 2015):
No problem, I'll close the bug for now.
@ghost commented on GitHub (Oct 26, 2015):
Bringing this issue back up.
I have Steam games stored on another drive. I'd like for Steam to be able to access those, but not to any other folders on that drive.
E.g. something like:
Perhaps there could be a more generic --keep flag?
@netblue30 commented on GitHub (Oct 26, 2015):
I think I can build some sort of whitelisting for /media.
@ghost commented on GitHub (Oct 26, 2015):
Well on Ubuntu it's /media/user/disk. On Fedora it's /var/run/user/disk.
You can see where this starts getting a big complex.
@netblue30 commented on GitHub (Oct 27, 2015):
It is all over the place. In Debian wheezy is on /media.
The number of entries in /media is small. Blacklist whatever you don't need for now.
@netblue30 commented on GitHub (Nov 15, 2015):
Implemented!
Whitelist command now accepts user home, /dev, /media, /var, and /tmp directories.
@SkewedZeppelin commented on GitHub (Sep 13, 2016):
@netblue30 could you please make whitelist also accept /mnt? or a config option to disable that check? Thanks.
@netblue30 commented on GitHub (Sep 15, 2016):
I'll add support for it, moved here: https://github.com/netblue30/firejail/issues/781
@g4jc commented on GitHub (Nov 24, 2016):
I've found a possible solution to this problem, but for unknown reasons firejail fights it's own permissions and shuts down.
Examine the following:
/usr/bin/firejail --noprofile --seccomp --netfilter --nonewprivs --noroot --nogroups $(find /home -maxdepth 2 -type f -not -name ".Xauthority" -not -name ".icedove" -not -name ".gnupg" | awk 1 ORS=' --blacklist=' | rev | cut -c 14- | rev ) --caps.drop=all --private-etc=/etc --private-bin=gpg2 --private-tmp /usr/lib/icedove/icedoveWhat this one-liner does is nest a find command in firejail startup which creates a properly parsed "--blacklist" for everything in everyone's home folder. It also creates a whitelist via find's "not-name" command - Then it runs the program.
The problem with this method is files in your home directory will randomly fail and the script gets stuck.
Parent pid 21911, child pid 21912 Child process initialized /bin/bash: /home/user/readme.[2015-01-20].txt: Permission denied Parent is shutting down, bye...I am unsure if this is a race condition or if firejail is blocking files prior to running --black-list.
@netblue30 commented on GitHub (Nov 27, 2016):
I'll look into it, thanks.