mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #2031] [feature request] Allow all directories, not just top-level for --private-home #1371
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#1371
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 @rieje on GitHub (Jul 5, 2018).
Original GitHub issue: https://github.com/netblue30/firejail/issues/2031
Not exactly sure why the limitation for
--private-homerequiring top-level directories only exists, but it would be great if directories didn't need to be top-level. As a specific example, addons are installed in theextensions/directory within the firefox profile directory. Being able to use this directory for--private-homemeans I can run a new and temporary instance of Firefox with these addons pre-installed. If the top-level directory~/.mozillais used instead, then any sensitive footprint-related data are also used in the instance of Firefox and that's a privacy concern (since~/.mozillacontains data regarding your Firefox profile).@chiraag-nataraj commented on GitHub (Jul 8, 2018):
Side note: if you use
~/.mozilla/firefox/<profile>/extensionsas the home directory, wouldn't the profile not load those extensions? Or are you talking about a scenario where you would install those extensions manually after it created the (temporary) profile?@rieje commented on GitHub (Jul 9, 2018):
Damn, you're right. I have a simple script that creates multiple profiles of the same name called
mainwith each sandboxed like this:~/.firejail/firefox-<profile-name>/.mozilla/firefox/main/. so in my script I can refer to it e.g.~/.firejail/firefox-${1}/.mozilla/firefox/main. This consistent naming scheme means I cancpthe addons to each profile. Problem with this is it requires the profiles to be persistent even though it is sandboxed, and persistent profiles are more susceptible to browser tracking footprints.Do you see any way in which firejail can support this natively and also support temporary instances (more ideal)?
@chiraag-nataraj commented on GitHub (Jul 9, 2018):
One way is to do something like this:
It's kind of hacky, but I think it should work (off to test!).
[Edit] It works! You may also want to copy some other directories (which contain extension preferences) as well as set some profile preferences by way of prefs.js.
@chiraag-nataraj commented on GitHub (Jul 11, 2018):
If you want multiple temporary Firefox profiles, you can do something like this:
You should only have to modify
$SRCPROFDIRand$TOCOPY. Everything else should Just Work™. This is also a much cleaner script because it usesmktempto safely create a temporary directory, doesn't re-use the existing profile (so every time you run it you will get a new profile and a new firefox instance), and actually uses variables. tl; dr: don't use the previous script and use this one instead xDAlso, thanks for getting me to think about this and hack up the script - I might actually use it! 😀
@chiraag-nataraj commented on GitHub (Jul 11, 2018):
I'll still mark this as an enhancement though, since this may be useful for other usecases.
@chiraag-nataraj commented on GitHub (Jul 14, 2018):
By the way, I actually use this script now as a general-purpose way to launch my firefox profiles:
firefox.common:gen_libraries:To use, you'd invoke
firefox.commonas something like this:~/scripts/firefox.common ~/.mozilla/firefox/5rupfy34.dev-edition-default-1518356819076 0 0 $*The first argument is the path to the profile. The second argument is whether you want this to be a private (temporary) profile. The third argument is whether you want to copy anything to the temporary profile. So in this case, it's just loading a regular firefox profile.
If you want to invoke the script to setup a private profile, you'd run it like this:
~/scripts/firefox.common ~/.mozilla/firefox/050wncor.FailSafe 1 1 $*In this case, the first argument gives the profile to copy information from. The second argument tells the script to create a temporary profile. The third argument tells the script to copy the files in
$TOCOPYfrom the first argument to the temporary profile (edit$TOCOPYto your desire).In addition to what the previous script did, this script also sets up a
private-libfilter by dynamically resolving the specific libraries needed in your version of firefox (unlike thefirejailversion, this one will usefindto locate all executables within a directory and runlddon them if provided a directory as the first argument - it makes generating the filter a lot less tedious). The second argument tocompile_listis the list of extra libraries needed (you may need to play with that, sorry...or just disable theprivate-libstuff if you don't care). Oh, and it usessystemd-runso that the service can be managed bysystemd(and it gives the service a nice name and stuff 😀).I hope you find it useful (and I promise I'll stop spamming this issue now xD).
(Updated version in my repo https://github.com/chiraag-nataraj/firejail-profiles/)
@rieje commented on GitHub (Aug 15, 2018):
You shared so much, so you're begging for some noob questions (sorry). So is the systemd and/or
gen_librariessuppose to replace firejail entirely or just resolve specific libraries for a particularly version of firefox? Based on the script, it seems like it's the latter, but here it says you don't use firejail (at all?) and usegen_librariesinstead (or am I entirely misunderstanding? What are non-system processes since you've said you use systemd for all system ones?).Similarly, is systemd sandbox capabilities that you're using a full replacement to firejail or an addition to it?
Will
gen_librariesit be implemented by firejail in the future or is it just something different that is supposed to be more "strict" than firejail? If the latter, why not?You say you use systemd anyway so it make sense to use "sandboxing capabilities of systemd itself". Is this script an example of this? It looks like it's just running systemd service which calls firejail and uses a list of libraries generated by
gen_libraries.Whatever sandboxing capabilities systemd offers aside, why do you run processes like firefox as a systemd service? Advantages/disadvantages? Do you do this with as many applications as possible or only those that are somehow more suitable to be run as services?
Lastly, are you looking to incorporate any part of that script (or what it does) to firejail?
Appreciate it, will be using your script and glad someone shares my usecase.
@chiraag-nataraj commented on GitHub (Aug 15, 2018):
All good questions!
It's a generic way to resolve libraries. Notably, the way it differs from the way
firejaildeals withprivate-libis thatprivate-libwill only resolve the libraries of binaries specified withprivate-bin(as well as any you list manually), whilegen_librarieswill find all ELF binaries (and shared libraries) and resolve all of their dependencies if passed a directory as an argument. It's a replacement/enhancement forprivate-lib, not forfirejailorsystemd. I only use it on things likefirefoxanddropbox, where there are binaries other than the ones listed inprivate-bin.I will flesh this out in more detail below, but basically,
systemdhas two different modes - system mode (i.e. theinitpart) and user mode (started when you log in). I usesystemddirectives to sandbox system services, while I usefirejailto sandbox user services. To explore further, you can look in/lib/systemd/systemand/lib/systemd/userand the output ofsystemctl statusandsystemctl --user statusto get an idea of which services run as what.Unknown. You can see #1920 for a discussion of what led me to create the script in the first place. I don't think
private-libwill be as powerful as this script without rewriting a bunch of things and possibly introducing new directives (e.g.private-lib-extra-dirsor something for directories to scan in addition to dealing with the binaries inprivate-bin). It's not supposed to be more "strict" or "loose" - as I mentioned above, it's more an extension ofprivate-libwhich helps when dealing with larger programs and/or programs that dynamically read dependencies (e.g.firefox).No, this script only deals with generating the library list that one can pass to
--private-libon the command line when launchingfirejail. So this script is useful, but doesn't do anything on its own (which is why it just defines a bash function!). In order to use it, you can look at thefirefox.commonscript (or various others now in my repo). They all follow a similar pattern - use the function fromgen_librariesto compile the list of libraries and then launch the program withsystemd-run(so that it's launched as a systemd user service - something I happen to prefer).The only way
systemdfigures in here is for service management. I'm not using any ofsystemd's sandboxing stuff in my user services (the ones I'm spawning with e.g.firefox.common).I do this with most longer-running processes. I just happen to prefer it - it's not essential (which is why the later versions of my
firefox.commonscript allow you to disable thesystemdintegration). One thing that is easier is checking if a program is running in the user session without having to usepgreporpidof. This helps because if you usehidepid=2(which I do), anything launched byfirejailwill not appear in "your" processes - that is, to your regular user, those processes are invisible. Hence, in that case,systemdis useful to keep track of what is running.I'd like to see its functionality somehow incorporated, but I'm not quite sure how exactly we'd do it. I also don't really trust my C enough to rewrite that much code... 😜
Glad to hear it! 🙂
@topimiettinen commented on GitHub (Aug 16, 2018):
I think Firejail and systemd provide roughly the same level of sandboxing features, for example for seccomp and networking. Firejail has
private-liband similar features and lots of tuning (or even hacks) to help specific user applications, while systemd has other features that firejail does not have (but they might be mostly interesting to system services). Perhaps the best is to use both as you have.About the
gen_libraries, I think your idea ofprivate-lib-extra-dirswould cater for most (if not all) needs. A more flexible way could be to run program specific scripts before the program is launched and to cleanup after it exits (like/etc/firejail/pre-start.d/firefox.sh). Those scripts could copy additional material to the sandbox, remove unused files or do other setup.@mindstormer12 commented on GitHub (Aug 28, 2018):
I don't know much about dynamic dependencies and I guess static ones. So
gen_librariesonly searches for dynamic ones and static ones still need to be specified (i.e. hardcoded)? Otherwise, wouldn'tgen_librariesbe more strict in the sense that it's more comprehensive than whatprivate-liboffers (which usesprivate-binand manually specified ones)?As a noob, how can I find whether I should use
gen_libraries? I guess I'll start off with whatever*.commonscripts you have in your repo and everything else uses defaultprivate-lib? Just curious the process of figuring out how to secure apps where possible when using the script. Also, whether you use systemd for system services or firejail for user services, this has nothing to do with whether you use *.common scripts andgen_libraries, right?Thanks.