mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #1011] Creation of blacklisted or read-only files #688
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#688
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 @SYN-cook on GitHub (Dec 28, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/1011
In the moment, firejail can blacklist files or set them read-only, if the files already exist. But if a file to be marked as read-only or as blacklisted doesn't exist yet, firejail won't prevent its creation.
This is for sure entirely unproblematic in most cases, but I see a problem in particular with the bash configuration file zoo. It is probably safe to assume that on most systems the set of bash configuration files is incomplete. In a Debian home folder, for example, there are by default only
.bashrc,.bash_logoutand.profile.Now if a program in a firejail sandbox would create a new
.bash_profileor.bash_loginfile (both read-only via disable-common.inc) or a new.bash_aliasesfile, it could basically write there anything it wanted... and have it executed on next login. I'm not familiar with other shells, but there might be similar problems, too.Thus, a nice-to-have feature would be to prevent the creation of blacklisted or read-only files.
For the issue with bash there are several easy workarounds of course: E.g. creating an empty file
~/.bash_aliasesand renaming~/.profileto~/.bash_profilesolves the problem for a default Debian desktop.#1010
@SYN-cook commented on GitHub (Dec 28, 2016):
Also, many distributions are shipped without critical folders like autostart or ~/bin... they are created as required, and as long as they don't exist, even firejailed applications can make and fill them with arbitrary data.
@netblue30 commented on GitHub (Dec 29, 2016):
Yes it's a nice feature, I'll mark it as an enhancement, although I have no idea how to do it at this moment.
@SYN-cook commented on GitHub (Apr 4, 2017):
@netblue30, just to provide a little more input :)
Do you think it could be helpful to write a warning to the syslog when a blacklisted file from disable-common.inc is freshly created (kernel provides the inotify API for such things)? From an attackers perspective, it would increase the risk of discovery to some extent....
Further in this direction - since probably only a small minority of users regularly monitor their syslogs - one could also increase the verbosity and display some kind of message whenever a file from disable-common.inc is newly created. But although I think that would be useful from the perspective of security, I acknowledge that firejail is just as much about being easy to use and not getting in the way, and I'm not sure if we want our users to have making sense of (cryptic) warning messages.
An alternative way to handle this issue would be to employ whitelisting in more profiles. Also this has its downsides (with whitelisting, everything tends to be more restrictive, which leads to an increased risk of breaking functionality in one way or another), but an extensive use of whitelisting would be more compatible with the way Firejail works right now. When going this direction, having a profile switch at hand like "whitelist everything that is not hidden (in the root of user home)" would be very helpful, I guess.
A very similar discussion about blacklisting, that inspired this comment, is/has been going on in #578.
@chiraag-nataraj commented on GitHub (Jul 22, 2018):
In profile files, you can use
which ensures the directory exists and cannot be accessed. If you want to do this for a file, use
mkfileinstead ofmkdir. Note that this solution leads to the files/directories being created if they don't exist, but if you're okay with random empty directories around the place, this seems to work as you want.