mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #2149] Firefox cannot use profiles under /media with the default profile regardless of whitelisting. #1458
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#1458
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 @crass on GitHub (Oct 9, 2018).
Original GitHub issue: https://github.com/netblue30/firejail/issues/2149
The reason for this is because of
disable-mntin the default profile. However, whitelisting should work as expected. The solution is not to disabledisable-mntbecause that's overly permissive.This is related to #2148 in the case where firejail is installed on
/mediasuch that they should be able to benefit from the same solution.@reinerh commented on GitHub (Oct 9, 2018):
I think having profiles in /media is a non-standard use case. Most users won't have their configurations there.
In my opinion it's better to harden the profiles for the most expected cases, and users with different setups can modify their firejail configuration.
@crass commented on GitHub (Oct 9, 2018):
I think you misunderstand... This is not a matter of modifying profiles. I specifically say that we do not want to disable
disable-mnt. The issue requires a change in the code in how firejail deals withdisable-mntandwhitelist. Technicallydisable-mntis a blacklisting of/mnt,/media,/run/mount, and//run/media, which happens right before any whitelisting occurs.I think a possible solution is to not
blacklistthose directories, but instead mount some tinytmpfsfilesystems. This will have the effect that subdirectories of those directories will still not be accessible, but permission will not be denied when accessing them.@reinerh commented on GitHub (Oct 9, 2018):
Okay, if I understand you correctly, you want to be able to override an existing
disable-mnt.What I meant was removing disable-mnt from the default profile and adding it where necessary.
But having the flexibility to override it would of course be better.
@crass commented on GitHub (Oct 9, 2018):
Yeah, actually, I want to only override a subtree of any of the disabled mounts. I'd consider only being able to whitelist one of the disabled mounts in its entirety to be insufficiently granular.
@Vincent43 commented on GitHub (Oct 9, 2018):
You can pass
ignore=disable-mntto override it. There is no need to alter its behavior. As you will pass your own whitelist rules anyway I think there nothing to do on our side.@crass commented on GitHub (Oct 9, 2018):
As I said above, I do not want to disable
disable-mnt. Let's say I do what you suggest and support my/mediahas/media/super-secret-usband/media/buggy-firefox-profile... What set ofwhitelistrules will protect me? Now I could pass--blacklist=/media/super-secret-usband that works for this simple example. But suppose/mediahas lots of directories that I want all blacklisted.... now its starts becoming a pain. What I'm suggesting is a less error-prone and more flexible solution.@Vincent43 commented on GitHub (Oct 9, 2018):
Use whitelist, not blacklist. If whitelist isn't supported for
/media(I'm not sure) then this is indeed something to implement.disable-mntis for blacklisting whole media and it's appropriate for most users so we shoulsn't change it.EDIT: whitelist does support
/media, so I don't see the problem here.@crass commented on GitHub (Oct 9, 2018):
@Vincent43, why don't you read an understand my comment before posting. You're not making yourself look like someone whose comments should be valued. In fact, why don't you read the code as I have?
Once you can explain to me why
blacklistis appropriate where I mentioned it above, then you might get a better understanding of the issue.@Vincent43 commented on GitHub (Oct 9, 2018):
I read your comments several times but not understand. You don't want to blacklist all /media, blacklist specific dir in /media or whitelist specific dirs in /media. What do you wan then?
@reinerh commented on GitHub (Oct 9, 2018):
As I understand it, he wants to whitelist a specific directory without whitelisting all other directories in the same mount point and without having to blacklist all non-allowed directories.
Edit: not "in the same mount point", but in any other mount points.
@Vincent43 commented on GitHub (Oct 9, 2018):
I'm still not getting it. Why
--whitelist=/media/buggy-firefox-profiledoesn't work?@reinerh commented on GitHub (Oct 9, 2018):
I didn't check, but as far as I understand him,
disable-mntprevents that.@SkewedZeppelin commented on GitHub (Oct 9, 2018):
I just checked and it does.
So basically the title should be:
Allow whitelisting paths disabled by disable-mnt.
Either whitelist needs to be changed to work with disable-mnt eg.
whitelist /mnt/xor
disable-mnt needs to support whitelisting itself eg.
disable-mnt !/mnt/x@Vincent43 commented on GitHub (Oct 9, 2018):
But that's what
disable-mntis supposed to do:--blacklist=/media. If user can pass his own whitelist rules then they can passignore=disable-mntas well.It's the same as someone would want to use
--blacklist=~/foo --whitelist=~/foo/barWhitelisting blacklisted dirs aren't supported in firejail in general
@SkewedZeppelin commented on GitHub (Oct 9, 2018):
There is a use case where this is useful:
end result is your expectations when using that profile are broken
This is definitely an edge case and not something most users will encounter.
I mean we only really add
disable-mntto profiles that actually don't need it or are too high-risk to go without it (browsers).@Vincent43 commented on GitHub (Oct 9, 2018):
Is this different than creating
/home/user/super-secretand forgetting to update the profiles to blacklist it?@SkewedZeppelin commented on GitHub (Oct 9, 2018):
I guess you have a point. Like I said it is an edge case.
And going back and rereading, it seems what I said isn't even what @crass wants anyway.
@chiraag-nataraj commented on GitHub (Oct 9, 2018):
Hold on. So @crass, I think there are a couple of things going on here.
That's literally how
whitelistworks...You want (if I understand you correctly) to enable selective access to mounted devices without exposing other directories in
/mnt. Passing--ignore=disable-mnt --whitelist=/mnt/<directory>should do the trick, shouldn't it? I just tested this usingfirejail --ignore=disable-mnt --whitelist=/media/camera, and as expected, only/media/cameraexisted inside the jail (there are several other folders in there in the real/media).All
disable-mntis doing (as you said) is blacklisting certain files and directories. If you want to enable selective access, you should be usingwhitelistinstead ofblacklist(the two aren't generally compatible). Disablingdisable-mntisn't some spooky, super insecure thing as long as you also usewhitelistto restrict access. For example, I useignore private-devand usewhitelist /dev/<x>all the time when I have a very specific requirement for the device files I need available in the jail.One side-effect, which we should fix, is that both
/mediaand/mntare treated with the samedisable-mntdirective, which means forgetting to blacklist the other one could result in exposure. We should split it off into two different directives,disable-mntanddisable-media, to fix that.@chiraag-nataraj commented on GitHub (Oct 9, 2018):
You're not required to whitelist the entire mount though. You can do something like
--whitelist=/media/mnt1/very/deep/subdir...@smitsohu commented on GitHub (Oct 9, 2018):
Maybe
--disable-mntcould be just a front-end to theblacklistcommand (profile_add)? Then it would be possible to override withnoblacklistjust a single component (say /media) when this is necessary, while keeping everything else (/mnt, etc). On top of that you then could whitelist in /media, as outlined by @chiraag-nataraj.Still not sure if this would help @crass.
@chiraag-nataraj commented on GitHub (Oct 9, 2018):
@smitsohu I like that! More flexibility = good 🙂
@Vincent43 commented on GitHub (Oct 13, 2018):
@crass does
36281ef60bfix your issue?@crass commented on GitHub (Oct 13, 2018):
@chiraag-nataraj @Vincent43
That is exactly what I'd like to do! Yep, and you're correct about the workings of
--whitelistwrt to doing what I proposed. So this change does allow me to work around my issue. The one problem left is that you need to specify the--noblacklist=/media. This should be automatically done internally in firejail when it detects a whitelist with a path prefix of/media. Otherwise, it could still be confusing to the user (ie "I whitelisted my dir, why doesn't it work?").@Vincent43 commented on GitHub (Oct 14, 2018):
@crass
As I presented in https://github.com/netblue30/firejail/issues/2149#issuecomment-428174319 this is generic firejail behavior. Changing it only for
/mediawould be inconsistent and add more confusion. If we decide that--whitelistshould automatically overcome--blacklistthen it should be done for all cases.@crass commented on GitHub (Oct 14, 2018):
@Vincent43 you would be correct if the option was
--blacklist=/media, but its not. There has already been demonstrated confusion around this (see #2188 ). The issue about why its confusing was already stated in my previous comment and by the user in #2188. Even in the documentation its not clear that--disable-mntis equivalent to blacklisting. Contrary to your belief that what I proposed would be inconsistent,--disable-mntis already a special case and thus any solution would be inconsistent/consistent because there's nothing for it to be consistent with. I understand your position, and it doesn't need to be repeated. However from a user perspective its wrong and causes the confusion that you admittedly want to avoid. So I maintain that this issue is not completely fixed.I've been looking into a satisfactory solution, and hope to have a pq soon.
@Vincent43 commented on GitHub (Oct 14, 2018):
@crass
After recent changes the only special case in
--disable-mntis its name. Internally it works as as common--blacklistoption. We could replace every instance of it with:include /etc/firejail/disable-media.incThat would be consistent. Changing firejail internals to treat path with
/mediadifferently than/foowould be NOT consistent.How you would explain to someone that they can overcome
--blacklistwith--whitelist=/media/user/fooinmediadir but they need to pass--noblacklist=/home/user/fooand--whitelist=/home/user/fooinhomedir?@crass commented on GitHub (Oct 16, 2018):
@Vincent43 I know how it works, I've read the changeset that changed it. And in fact you are not completely correct about it. It does not work as you describe when
disable-mntis set to set toyesinfirejail.config. You also missed that/run/mountis also blacklisted. Also, keep in mind that your idea of consistency is based on an (inaccurate) understanding of the code. A normal user should not be assumed to have this. What the doc says isDisable /mnt, /media, /run/mount and /run/media access.Does that meanblacklist? It certainly does not whendisable-mntis set to set toyesinfirejail.config. I agree that consistency is a thing to be strived for, but your way isn't any more consistent from a user perspective.Think about it from a user's perspective. Lets say is the
firefoxprofile and executable with a profile in/media/firefox/.... The user will first try to run something likefirejail firefox --profile /media/firefox/.... This will fail with firefox saying the profile could not be found. The next thing they'll want to do is--whitelistthe path to see if that will just work. Unfortunately it won't. Then they'll look into the profiles and see nothing that disables/mediaspecifically. They'll look more and read some docs, and discover thatdisable-mntdisables/media. At this point they'll be at a loss unless they somehow think that disable means blacklist and think to do--noblacklist. If you want firejail to be painless to expand adoption, why do you want them to jump through unnecessary hurdles when a simple solution already exists?In fact, I'll reiterate, we've already seen confusion with the current behavior, so your theoretical consistency confusion is trumped by real world examples to the contrary. At a minimum the docs should be changed to cover the current behavior better. However, the user just wants things to be intuitive and work.
I propose that if
--disable-mntis specified on the command line or in a profile and is set tonoinfirejail.config, then allow the whitelisting of paths in/mediaand otherdisable-mntpaths. This might only be odd if you specify--blacklist=/mediain addition to--disable-mnt. But then you're talking about an uncommon case... who actually wants to do that?When I run firejail with
--whitelist=${HOME}/Pictures, the sandbox gets access to thePicturessubdirectory of the users$HOMEwithout needing to do a--noblacklist. This works as expected and seemingly contrary to the example you provided above. Consistency?@Vincent43 commented on GitHub (Oct 16, 2018):
Yes
/run/mountis also blacklisted which doesn't change my point at all. What is inaccurate here?Changing docs isn't hard thing to do.
I'm thinking from user perspective all the time otherwise I wouldn't care about this at all. The simple solution indeed exist and was presented by me above. Inconsistent internal changes are unnecessary hurdles.
Yes, we have opened issue which you linked before and the user proposed exactly same thing as me.
Agree.
Is that consistent enough for you?
I think that we both agree about the problem but not about the solution.
IMO the best solution is either (or both):
disable-mntin favor of/etc/firejail/disable-media.inc(All other disable-* options are handled this way,
disable-mntwas an unicorn. This will add consistency and remove confusion. We will do global changes to all profiles anyway in couple of pending PRs)whitelistto overcomeblacklistglobally (not only for/media)(Are there any downsides of doing this?)
@smitsohu commented on GitHub (Oct 16, 2018):
Well, in general it seems that users don't have problems understanding what
blacklistandwhitelistis, and that they are two different things and they have to take care of both.If you mix them new problems (and feature requests) will be coming up, like: I whitelisted (blacklisted) ~.config/super, why can't I also access (blacklisted) ~/.config/super/useful?
Or conversely: I whitelisted ~/.config/super, it is nice I can see (blacklisted) ~/config/super/useful as well, but how do I block access to ~/.config/super/secret? To me this looks rather more confusing.
I vote for better documentation of
disable-mnt. We could also add a comment to the profiles that in few words describes what it does. Similar to thewritable-run-useroption. People who care to adapt their sandboxes or conceive new ones learn by looking at the stock profiles. I think this is really a documentation issue, if anything.Also consider that deprecating options that are widely used causes a lot of transition pain. Expect it to break most custom profiles out there (obtained by modifying the default ones). It would be disruptive and annoying.
@chiraag-nataraj commented on GitHub (Oct 16, 2018):
I agreed with @smitsohu that allowing
whitelistto overrideblacklistglobally brings up a lot of hairy issues that imo are not worth it. The current behavior (that they're not compatible) is fine and (at this point) seems to be Expected Behavior™. If we solve the uniqueness ofdisable-mnt(which has been solved in a recent PR/commit), it should solve this issue. I don't think this is a productive discussion at this point as the original problem seems to have been resolved, at least in master, so I'm going to close this for now.@Vincent43 commented on GitHub (Oct 16, 2018):
Depreciation would mean that this option still works but isn't used in official profiles.
@Vincent43 commented on GitHub (Oct 16, 2018):
I updated
disable-mntdocumentation.70b227d582016faf8e5b