mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #2200] --read-only recursiveness does not cross filesystem boundaries #1471
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#1471
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 @iskunk on GitHub (Oct 17, 2018).
Original GitHub issue: https://github.com/netblue30/firejail/issues/2200
Consider a path
/foo/bar/disk/, wherediskis a mounted filesystem:My expectation would be that
--read-only=/fooprevents writing to/foo/bar/disk/, much as--blacklist=/fooprevents access to same.This relates to issue #402, but the problem as described there relates to the
/mediadirectory and has a simple solution (use a wildcard). I'd like to bring attention to a trickier scenario: auto-mounted NFS directories. The situation is similar to the example presented above, except that mounts-within-mounts are common, and the depth at which they occur is arbitrary and unpredictable.I'll share an example patterned after a real automount setup at my organization:
Not only would
--read-only=/nfsnot be sufficient,--read-only=/nfs/*also falls short. And--read-only=/nfs/*/*/*et al. is not practical.I'd like the entire NFS tree to be accessible, but in a read-only manner to prevent writing anywhere I'd normally be able to. The current implementation of
--read-onlycan't do this, and as the documentation gives the impression that it can, users may be caught unaware of the limitation.@smitsohu commented on GitHub (Oct 17, 2018):
@iskunk Thank you for the report. Can I ask with which Firejail version you tried?
@netblue30 I wonder if Firejail could walk /proc/self/mountinfo bottom-up in order to remount all the child mount points. Its not perfect, but maybe it could be a pragmatic solution to all these issues with
--noexecand--read-only.@netblue30 commented on GitHub (Oct 17, 2018):
We need to fix this. Let's walk /proc/self/mountinfo!
@iskunk commented on GitHub (Oct 17, 2018):
Hello @smitsohu, @netblue30!
I am using Firejail 0.9.52 as shipped with Ubuntu Bionic/18.04.
@smitsohu commented on GitHub (Oct 21, 2018):
Ok, so there is a proof-of-concept at smitsohu@8a7293cf76bc20976bbc97a5e6110300e51fabfb
It looks quite ugly and there is probably plenty of room for optimizations, but it seems to work for most cases out of #402, #158, #833, #2029, #1529 and #1628 (not tested everything)
I don't have an NFS at hand, so I can't say if that would work as well.
@crass commented on GitHub (Oct 25, 2018):
Should we have a
read-only-recursiveor perhapsread-only-norec? I'm not actually sure if it would be useful, but it allows for backwards compatibility if it is. Also shouldread-writealso be recursive for consistency?@smitsohu commented on GitHub (Oct 25, 2018):
Maybe the solution is to open the mount target, pick the mount id from /proc/self/fdinfo and jump right to the interesting lines in /proc/self/mountinfo. Then combine that with mount flag extraction, in order to not do unnecessary remounts. If this works it should avoid most of the problems with the current quick and dirty patch.
@smitsohu commented on GitHub (Oct 25, 2018):
I think I have something, I will send a pull request.
@smitsohu commented on GitHub (Oct 26, 2018):
The new behaviour is not without problems in case of
read-write. Take baloo_file.profile as an example. There we haveIf a user enables the last two lines, it will override the
read-only ${HOME}/.local/share/applicationsand a number of other directives from disable-common.inc. In other words, the sequence of the directives is getting more important. This is probably something to keep in mind.I'm going to update some profiles in the pull request to account for this (by moving
read-writeto the top).@smitsohu commented on GitHub (Oct 26, 2018):
Moving toEDIT: doesn't apply, as allread-writeto the top does not solve the problem if users have included it via a.localfile.read-onlydirectives are coming later whenread-writeis in the.localfile.Should
read-writekeep the old behavior? There could be a second option that does the mounts recursively.@iskunk commented on GitHub (Oct 26, 2018):
I was hoping, in #2202, that the order of options could be made less important rather than more. But I don't see a good alternative approach here.
It might be good if e.g.
read-write ${HOME}/.local/sharecauses a warning to be printed that${HOME}/.local/share/applicationswas previously marked read-only, so that at least the overrides are obvious to the user.