mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #4845] Options to deal with open file descriptors #2793
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#2793
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 @smitsohu on GitHub (Jan 11, 2022).
Original GitHub issue: https://github.com/netblue30/firejail/issues/4845
Currently Firejail sandboxes inherit all open file descriptors from their parent process.
As far as standard streams (stdin, stdout, stderr) are concerned this is probably desired behaviour. On the other hand, passing non-standard file descriptors (> 2) into the sandbox is only rarely necessary in my experience.
IMHO Firejail should provide a mechanism to prevent accidental leakage of open file descriptors, either by default with a way to opt-out, or alternatively as an opt-in. I would like to know if there is general interest in options like
inheritfd(don't close one or more file descriptors > 2)discard-stdin(-> /dev/null)discard-stdout(-> /dev/null)discard-stderr(-> /dev/null)@ghost commented on GitHub (Jan 11, 2022):
I'd say any prevention of accidental leakage is a welcome enhancement and the proposed options sound great.
Just out of curiosity, could you provide an example of such a case?
@rusty-snake commented on GitHub (Jan 11, 2022):
Is there anything bad expect that you can read/write on that fd?
firejail --noprofile --shell=none --private-bin=gnome-2048 /proc/self/fd/5 -l /usr/bin 5</usr/bin/ls@reinerh commented on GitHub (Jan 11, 2022):
Open FDs are bad in simple chroots, as you can use them to escape with
fchdir(fd)(iffdis outside). There is probably other bad stuff you can do with open FDs to get information from outside the jail.Not sure how firejail behaves with
--chroot. It's probably best to close everything.@rusty-snake commented on GitHub (Jan 11, 2022):
Yeah, if the open fd refers to a directory you can
fchdir,openat,execveat, ... which is close to full filesystem access. But if it refers to a file? Is there something likeget_basedirfd_of_fd? If anyone knows more, I'm interested.@smitsohu commented on GitHub (Jan 11, 2022):
It depends on the file descriptor. As a rule of thumb everything that can be done with a file descriptor outside the sandbox can be done also inside the sandbox. This includes reading/writing to files or interprocess communication.
Many file descriptors (those that are obtained by actually opening a file) are bound to a mount point, and inherited file descriptors necessarily refer to mount points outside the sandbox. So a worst case scenario would be a file descriptor that allows to bypass a
blacklistorread-onlydirective, or if it refers to a directory tofchdirout of the sandbox entirely.Pythons
subprocessmodule by the way closes all non-standard file descriptors by default, or at least that is my understanding. If this is ok for a general purpose Python module, I think it should be okay'ish for Firejail as well.Hopefully not!
If it exists, most if not all of the common sandboxing tools will have a problem, because, as you say, that would be equal to full unrestricted filesystem access.
@netblue30 commented on GitHub (Jan 12, 2022):
It is rarely used, so we should prevent it by default + some command line option to opt-out.
@smitsohu commented on GitHub (Jan 17, 2022):
I used
man -wK 1 'file descriptor'for a first impression. There are only a few interesting hits, like for example in thegit,git-remote-fd,gpg,opensslortarman pages.