mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #2114] Hiding HOME with --whitelist: cannot open directory '.' #1432
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#1432
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 @onlyjob on GitHub (Sep 14, 2018).
Original GitHub issue: https://github.com/netblue30/firejail/issues/2114
I'm trying to hide contents of HOME directory from jailed application using
--whitelistoption as described in #583:However instead of empty home with
tmp_folder in it I getls: cannot open directory '.': Permission deniedwhen I trylsin user's home directory (ls tmp_works):What is the recommended way to jail application in a fake user's home to hide certain locations that application have no business accessing?
Thanks.
@smitsohu commented on GitHub (Sep 14, 2018):
Could you please re-run this command with
--debug-whitelists?@onlyjob commented on GitHub (Sep 15, 2018):
Thank you.
/home/useris a symlink:/home/user -> /mnt/r/home/user.I think the
Mounting tmpfs on /mnt directoryin the output looks suspicious and possibly suggests a bug in the assumption that user's home is two levels deep from the root?@smitsohu commented on GitHub (Sep 15, 2018):
Hmmm. I have trouble reproducing your issue. I created a new user, let's call him tester, a symbolic link /home/tester -> /mnt/bla/tester, and two files /mnt/bla/tester/abc and xyz. This is what I get:
Are you doing something special, maybe with FUSE?
@onlyjob commented on GitHub (Sep 15, 2018):
But in my case
tmp_is a directory...Yes, users' homes are on FUSE,
/mnt/ris FUSE-mounted.@smitsohu commented on GitHub (Sep 16, 2018):
Probably this is caused by FUSE. The underlying reason is that when it comes to FUSE, even the powers of the root user are limited, and Firejail needs root for setting up the sandbox.
What you could try is mounting users' homes with
allow_otherorallow_rootoption, depending on who is doing the mount, root or regular user.For comparing there are a number of similar issues, for instance #1560, but the behavior of whitelisting has changed slightly in the meantime, so you won't be able to reproduce all examples exactly.
@onlyjob commented on GitHub (Sep 16, 2018):
I did not expect any problems with FUSE because it is mounted by root with
user_allow_other. We have all users' homes on network share and mount point already haveallow_other...@smitsohu commented on GitHub (Sep 16, 2018):
Ok, then it must be something else. Are you maybe employing NFS?
@onlyjob commented on GitHub (Sep 16, 2018):
If it were NFS I would probably had it mounted using kernel client rather than through FUSE... ;)
We are using LizardFS - distributed parallel file system. It have built-in data integrity, no single point of failure, good performance, etc.
@smitsohu commented on GitHub (Sep 17, 2018):
I see. Maybe someone else with an idea?
@rusty-snake commented on GitHub (Jun 26, 2019):
@onlyjob does
--private=~/tmp_or--private-home=tmp_work for you. Note: that they don't do exactly the same.@rusty-snake commented on GitHub (Oct 13, 2019):
I'm closing here due to inactivity, please fell free to reopen if you still have this issue.
@onlyjob commented on GitHub (Oct 13, 2019):
Sorry I could not get to this issue earlier. I have upgraded my system to Debian 10 "buster" and
firejail version 0.9.58.2.--private=~/tmp_is not what I need;--private-home=tmp_appears to behave similar to--whitelist=~/tmp_but warns:Error fcopy: size limit of 500MB reached.The original problem with
--whitelist=~/tmp_is gone.However with symlinked home directory firejail still does not work properly by default:
Note how under Firejail current working directory changed to
/mnt/r/home/userandlsstill show all files in the home directory unless Icd ~under firejail.For me the correct invocation of firejail is
to hide symlinked home so I recommend to have a special workaround for symlinked home directories by default.
P.S. I can not "reopen" the ticket. There is only "Comment" button...
@smitsohu commented on GitHub (Oct 14, 2019):
Not sure what your current Firejail version is, but as an outlook, the treatment of home directories outside of /home has changed in current master....
There should be now full support for whitelisting and everything else, with all bells and whistles and no need for workarounds. However, there is still a problem if the user's entry in the system password database (/etc/passwd usually) does not contain the resolved path to the home directory, but a path with a symbolic link.
In this case all we can do currently (in master) is ask the user/administrator to update the password database and provide a fully resolved path there. Once this is done, there should be no outstanding issues (in master).
@smitsohu commented on GitHub (Oct 14, 2019):
In current master that limit is configurable in /etc/firejail/firejail.config
@onlyjob commented on GitHub (Oct 15, 2019):
I think firejail should always normalise user's HOME path with
readlink -f. In our case use of symlinks is intentional. Basically this issue could be considered a vulnerability as without special workaround it is trivial to bypass firejail isolation by merely a symlink.I wonder is
--bindmount should be detected also?@smitsohu commented on GitHub (Oct 15, 2019):
Yeah, this was the original plan. But as user directories literally can be everywhere, there is the unlikely but not inconceivable case where a user is able to control the readlink return value (using a symbolic link to trick Firejail into thinking the user directory is somewhere else). Because of this, Firejail trusts only the raw string extracted from /etc/passwd, which is guaranteed to be under control of root.
You can continue using them. But now that you mention it, I realize Firejail does not create a full representation of the file system inside the sandbox, in that a symbolic link in /home would be absent inside the sandbox. Maybe we should detect this situation.
They tend to be less problematic from a privilege management perspective, as FUSE and friends guarantee to not increase DAC permissions, and they require CAP_SYS_ADMIN. So instead of using a symbolic link, you can always also bind-mount. Generally speaking, mounts are less problematic for Firejail than symbolic links.