mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #641] Idea: Adaptive file access rights #445
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#445
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 @Unrud on GitHub (Jul 22, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/641
Problem
Most applications need access to files that can be scattered everywhere in the user's home directory or on external media. E.g. an PDF viewer needs read access (and possible write access to add annotation etc.) to the whole home directory and
/mediato work correctly. Same goes for web browsers, which should be able to read everything for uploads etc.Existing solutions
AppArmor and SELinux can mitigate this to some extent by allowing the PDF viewer to only access PDF files. In case of the web browser this doesn't help.
Probably the best solution is to have an service outside of the sandbox, which applications ask to open files and then passes file descriptions back into the sandbox. Unfortunately this requires adapting all applications.
Proposed solution
The core idea is to use a custom FUSE file system which is mounted inside the sandbox and acts as a proxy to the real file system and a simple set of rules to control file access.
Configuration directives could be something like
adaptive-home, which mounts the FUSE file system on /home and represents the real /home as a proxy or something likeadaptive ${DOCUMENTS}which does the same for custom folders.This is accompanied by a rule set that controls file access. With this rules it should be possible to control which files the application can always access and the files that can be accessed after the user was asked.
Configuration directives could be something like
adaptive-rule-read-only *.extandadaptive-rule-read-write globbing/*/pattern/**for files that are directly accessible.If the applications tries to open some file in the FUSE file system which matches the patterns from
adaptive-rule-read-only-ask *.extoradaptive-rule-read-write-ask *.exta dialog box gets shown to the user and the IO operation only succeeds if the user allows it.It would be also possible to only list files to the application that are matched by any of the rules.
The dialog boxes will annoy the user, I have thought of a few ways to keep there amount to a minimum or in some cases eliminate the need for them altogether:
firejail pdf-viewer test.pdfis started from a file explorer and the profile contains the ruleadaptive-rule-read-only-ask *.pdf. Maybe users will stop using integrated open dialogs and always open files via file explorers.firejail qpdf --linearize in.pdf out.pdfis started in a terminal.adaptive-rule-read-write-extra ${FILENAME}.lockoradaptive-rule-read-only-extra ${DIRNAME}/*.jpg(e.g. an image file is opened by an image viewer and the user wants to browse all images in the same folder).A configuration file could look like this:
What do you think of this idea? Have I overlooked some problem? Was it already proposed?
@trou commented on GitHub (Jul 23, 2016):
For information, if you're interested you might want to look into https://github.com/stemjail/stemjail :
StemJail brings to the enduser a mechanism to automatically isolate processes according to the data access pattern (usage).
@Fred-Barclay commented on GitHub (Jul 24, 2016):
This is way over my head so it's entirely possible I'm missing something. You clearly know what you're talking about while I can only pick up on little bits here and there :)
My concern is if a jail that is "adaptive" could also be manipulated, and then escaped?
@xahare commented on GitHub (Aug 13, 2016):
you can keep separate folders for your apps, just use --private=~/firejails/evince ive been doing this for awhile, and you get used to it quickly. for example, to see a pdf, move it to your evince home folder and view it from there. another bonus is separate contexts, like personal-browser, work-browser, etc
this is easy to wrap from a script, but not quite seamless. you cant just tell the browser to move the file and call your wrapper. but, you can download the file, and call your wrapper from outside firejail to spawn a new one.
@chiraag-nataraj commented on GitHub (Aug 14, 2016):
@xahare Personally, I like to dedicate one folder (like ~/Downloads) to sharing files between applications. I also find it nicer to use whitelist/blacklist since I have to either hardlink config files that are shared or use bind mounts for whole directories. Either way, that's super messy 😛 Just my personal tastes!
@xahare commented on GitHub (Aug 15, 2016):
@Fred-Barclay the dynamic mechanism, or its user, could be tricked. thats always a problem with moving parts.
dynamic / interactive file access would be a good compliment to the access control of firejail and xpra(until we get wayland). dialog boxes should show the full path to files, other hard links, and, if its not a performance hit, sym links.
is there a mechanism with less attack surface than a fuse module?
@chiraag-nataraj commented on GitHub (Jul 22, 2018):
Thinking about this again, it seems like a recipe for disaster. As soon as the jail can be modified from within (which is what you're asking for), it is only a matter of time before exploits crop up which attack that adaptability. And as soon as that happens, firejail would be pretty useless.
The thing that makes firejail so powerful is exactly the fact that the jail cannot be modified once it is entered. Adaptability sounds like a good idea at first, but allowing the user to modify the jail from within would (I think) lead to an eventual compromise of the entire jail.
@chiraag-nataraj commented on GitHub (Aug 6, 2018):
@Unrud, I'm going to go ahead and close this for now. If you have a way to address the concerns that have been brought up here, feel free to respond and re-open :)