mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #903] mkdir in profile does not respect --private=<directory> #611
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#611
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 @pyamsoft on GitHub (Nov 9, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/903
Latest stable firejail: 0.9.44
The command line option
--private=<directory>states that firejail uses the given directory as a new home.This works fine, and all whitelist and blacklist commands work as expected with respect to the private directory. However, using mkdir in a profile incorrectly creates the directory in the real home.
You can observe this in the shipped Dropbox profile for example, which makes calls to mkdir in its profile:
You can observe similar errors in the shipped firefox profile.
You will see that a Dropbox folder will be created in the actual home directory, instead of the private home at ~/dropboxtesting. You will also see the firefox directories like ~/.mozilla being created in the real home. I would expect that mkdir will respect the private home directory just as whitelist and blacklist do, so I believe this behavior to be a bug.
@valoq commented on GitHub (Nov 9, 2016):
I can confirm the behaviour. Seems like a bug to me.
@netblue30 commented on GitHub (Nov 10, 2016):
Fixed, thanks for the bug.
@okcomputerik commented on GitHub (Mar 4, 2017):
Although marked as fixed, I see the same behavior running firejail 0.9.44.8 with the dropbox profile. Am I missing something here? Thanks!
@netblue30 commented on GitHub (Mar 5, 2017):
I'll look into it, thanks.
@sunho0301 commented on GitHub (Apr 10, 2017):
Are there any updates on this issue?? I'm having the same problem.
Thanks!
@chiraag-nataraj commented on GitHub (Jul 15, 2018):
Is this still an issue? If so, let's figure out what's going on :)
@chiraag-nataraj commented on GitHub (Jul 30, 2018):
Yes, this is still an issue. The question becomes the following:
If we write
mkdir ${HOME}/<somedir>, do we mean the real${HOME}or what the sandbox will see as${HOME}?@chiraag-nataraj commented on GitHub (Aug 1, 2018):
@netblue30 Is this intended behavior? If we use
${HOME}in, say,mkdir, do we want${HOME}to be resolved after things like--privatehave been resolved or do we want to resolve it before those predicates? That will change the behavior as I understand it, and either one is fine as long as we document it.@chiraag-nataraj commented on GitHub (May 21, 2019):
Sorry to dredge up so many old issues, but @netblue30, is this intended behavior? If so, we can close. Otherwise, we should fix this.
@matu3ba commented on GitHub (Apr 9, 2020):
@rusty-snake @chiraag-nataraj
If the folder does not exist, firejail prompts
Error: invalid private directoryand exists. If nesting of firejails is forbidden, the error could maybe be simplified toError: folder not usable as private directory. However I am not sure about this.Otherwise suggestion to close this.
@rusty-snake commented on GitHub (Apr 9, 2020):
@matu3ba it's not about the private directory does not work. The mkdir does not respect it. Like this:
@vinc17fr commented on GitHub (Oct 19, 2021):
In fact,
mkdircreates a directory in both the real home directory and the sandbox. Andmkfilehas the same issue:@smitsohu commented on GitHub (Oct 19, 2021):
To illustrate what probably was the reasoning behind this design, let's take Firefox. The profile uses
whitelistin user home, so if the program is never run outside of Firejail, all application files and directories (~/.mozilla,~/.cache/mozilla, ...) are ever created only in the tmpfs, and are always discarded when the sandbox shuts down. There will never be any persistence, which is not howwhitelistis supposed to work, and is closer to whatprivateis supposed to do.One possible solution is to create needed files and directories beforehand as the user in the real file system, so that
whitelistcan properly bind mount them in the sandbox.The downside is that some profiles create quite a clutter in the file system, which is also not so nice. As a workaround you can add
to
/etc/firejail/globals.localand create files manually, or run applications once outside Firejail, which is usually sufficient to get all required directories and files.@rusty-snake commented on GitHub (Oct 19, 2021):
FTR: #4285
@smitsohu commented on GitHub (Oct 19, 2021):
Maybe we could postpone
mkdirandmkfileuntil after private option processing, but handle them beforewhitelist.@colons commented on GitHub (Dec 20, 2023):
hi. i don't know that this issue has any actual security consequences, but it is extremely disconcerting to see your home directory littered with directories related to something you launched with the promise that it'd be contained to a directory you specified. if nothing else, it's a violation of what
--privatesays it'll do, and it requires active tidying up after it has its effect@spikethehobbitmage commented on GitHub (Jan 4, 2025):
This is exactly what needs to happen.
overlayoptions should* also be processed beforemk*since they also discard jailed changes.*This may already be the case but
overlayis disabled on my system so I can't test it.@giddie commented on GitHub (Jul 7, 2025):
This is disconcerting, and I'm trying to understand the scope of the issue. If I do this:
So it actually seems to be working correctly. How do we reproduce the bug?
@tanriol commented on GitHub (Jul 7, 2025):
firejail --private=~/jail --mkdir=~/another bash -c "true"This looks kinda stupid when both are specified on the command line - why do we need
mkdirin a private profile - but when one ismkdirinsteam.profile(dozens of them are there) and the other is--private=${HOME}/steam-jailin the script used to launch Steam, the fact that it still creates dirs in real home like${HOME}/Zomboid(not even a hidden one!) feels plain wrong.@giddie commented on GitHub (Jul 7, 2025):
Aaaaah! 💡 This is a lot less concerning than the manpage suggests. When it says "some commands such as mkdir ...", what I understood was that
mkdirinside the container was broken. OK, this is not such a huge deal. But the bug warning could maybe better communicate that it's just referring to firejail command-line arguments or commands in profiles.