mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #1720] Dropping Firejail privileges with services not running as root? #1159
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#1159
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 @curiosity-seeker on GitHub (Jan 9, 2018).
Original GitHub issue: https://github.com/netblue30/firejail/issues/1720
@netblue30 once wrote:
I'm not a programmer but I guess it's done as shown here. It's evident that dropping root privileges is important to reduce the attack surface.
However, that's not done when sandboxing services like unbound. The thing is that unbound runs (at least on my Fedora system) by default under an unprivileged user
unbound, and dnsmasq and dnscrpyt-proxy can be configured to run under, e.g., the usernobody. Hence, those services do not run with root permissions - but Firejail does if used to sandbox those services.So the question is: Is Firejail running as root increasing the attack surface in those cases? And would it be somehow possible for Firejail to drop its privileges according to the unprivileged user used by the sandboxed service? If not - would it make sense to sandbox those services with systemd instead?
@Ferroin commented on GitHub (Jan 9, 2018):
From a practical perspective, firejail running as root is probably not significantly increasing the attack surface (disclaimer: I am not a systems security expert, just a guy who has some experience dealing with securing systems). The only thing firejail not continuing to run as root could theoretically get you is the ability to have a user namespace with no UID=0, but that's already not possible because of how the setup is handled.
As far as why it does this, the programs you mentioned expect to be started as root and handle the process of dropping privileges themselves because they have things they need to do on startup that require root privileges (or more often particular capabilities, usually CAP_NET_BIND_SERVICE so that they can bind to ports below 1024). Trying to start them as a non-root user without firejail involved won't work in almost all cases, so they can't be started as a non-root user inside the firejail instance either. In theory, firejail could probably drop at least some privileges once it's started the program, but that may be more effort than it's worth.
As far as sandboxing with systemd as an alternative, you have the same issues there to varying degrees, it's just a different component that handles them (because systemd does socket activation, it can open the listening socket and hand that off to the program, but the program has to support this properly).
@curiosity-seeker commented on GitHub (Jan 10, 2018):
@Ferroin : Thanks a lot - your answer is very helpful and instructive as always!
Perhaps @netblue30 wants to add something before closing this issue.
@netblue30 commented on GitHub (Jan 13, 2018):
@curiosity-seeker
For a server, the process exposed to the outside world runs as an unprivileged user (unbound or nobody). The process is started by a separate process running as root (as explained by @Ferroin above). The starting process is never exposed to outside.
The same is true for Firejail. By the time the unprivileged server process starts, Firejail is already sleeping.
Systemd is a generic starter, with no interaction to outside world. It is more a convenience than anything else. You can use it instead of the regular starter packaged with your server, is not going to make any difference.
@curiosity-seeker commented on GitHub (Jan 13, 2018):
Thanks again to both of you!