mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #3184] access to the system DBus #1992
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#1992
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 @rusty-snake on GitHub (Jan 25, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3184
Thanks @jonleivent for bringing #3078 up.
Current situation:
Profiles with
nodbushave no access to/run/dbus/system_bus_socket, profiles withoutnodbushave access. The must profiles withoutnodbusdidn't have it because they need access to the session-bus.Proposed change (soft):
Adding a
nodbus.systemoption. If only this option is specified, the program can access the session-bus but not the system-bus.Proposed change (hard):
Firejail blocks system-bus access by default, unless an allow-system-dbus-access option is specified.
@Vincent43 commented on GitHub (Jan 25, 2020):
I wonder if we could bring in xdg-dbus-proxy integration for fine grained dbus access control instead of all or nothing.
@rusty-snake commented on GitHub (Jan 25, 2020):
Sure we should. However this is a lot more work and blocking the system-bus works for almost all programs and prevents them from doing "privileged" actions.
@jonleivent commented on GitHub (Jan 28, 2020):
Would it be possible to enclose a session bus within a jail with other applications, so that they can use it without interfering with applications and session busses outside the jail?
@jonleivent commented on GitHub (Jan 28, 2020):
I did some experimenting, and it is possible with some additional firejail protections on /run and setting XDG_RUNTIME_DIR to launch dbus-launch --exit-with-session icewm-session into a x11=xephyr firejail container. Some testing shows that the session dbus inside the jail works. Anyone seen this configuration before?
Tested a bit with dbus-monitor --session, and it does seem that the session dbus in the jail and the one outside are separate and keeping their distance, with apps that would normally fail in a nodbus jail now working. Cool!
@rusty-snake commented on GitHub (Jan 28, 2020):
untested:
firejail --noprofile --nodbus --private dbus-run-session APP@ned64 commented on GitHub (Feb 22, 2020):
I have experimented with
dbus-run-sessionbut needed to add a new/etcand/tmpfor that to work and isolate properly. Perhaps this could be integrated as--new-dbus-session?@jonleivent commented on GitHub (Feb 22, 2020):
@ned64
What in particular did you need to do to /etc and /tmp?
@kris7t commented on GitHub (Feb 22, 2020):
@Vincent43 Provided we had a convenient way to run
xdg-dbus-proxy, what kind of policies would we want to enforce? I imagine usual suspects would be allowing notifications, and perhaps MPRIS or idle inhibition, depending on the app.I am tempted to implement
xdg-dbus-proxysupport. It seems to have a straightforward format for filters (\0-separated options read from a given fd), but we will probably need something a bit more composable for profiles.@rusty-snake commented on GitHub (Feb 22, 2020):
@kris7t if we implement it compatible to flatpak we will be able to add restricted dbus to the most commonly used program-profiles by using the permissions from flathub. I could write a script to automate this.
@ned64 commented on GitHub (Feb 22, 2020):
@jonleivent
I created a new machine id as well as password and group files so that
dbus-sessionwould start:then bind
"${tmpdir}"to/tmp/dbus-dataand setXDG_RUNTIME_DIRto/tmp/dbus-data- or, use those files in a private/etc.@ned64 commented on GitHub (Feb 22, 2020):
It would be perfect to have a dbus proxy. I would use a whitelist approach so that all (and new) services are blocked by default.
evincewould be able to open a new instance if it could only see itself on the dbus, nothing else needed. Same forlofficeand others.These simple things could also be done with
--join-or-startand a per-group dbus session/instance but more complex ones would fail. Here a proxy with pre-made config files (a strength offirejail) would be great.@jonleivent commented on GitHub (Feb 22, 2020):
@ned64
I didn't have to do any of that to get dbus-run-session to work. Even the XDG_RUNTIME_DIR I thought I needed isn't needed, as long as XDG_RUNTIME_DIR is unset either by the profile or before, so that the default /tmp setting is used. I did use a --private-etc and --private-tmp. I have two profiles - one with network access and one without. The --private-etc settings in the one without are:
the with-network one has (mostly tested with firefox):
@Vincent43 commented on GitHub (Feb 23, 2020):
Ideally apps would own their namespace + portal access and the rest would be granted per profile. Maybe more relaxed
dbus-common.incwith things you mentioned will be needed though. As it was said flathub is good place to see what apps need.@kris7t commented on GitHub (Feb 23, 2020):
@Vincent43
Speaking in terms of concrete syntax, I am thinking along the lines of
dbus allow|filter|noneanddbus.system allow|filter|noneto completely disable, filter with proxy, and completely allow access to the the session and system buses, respectively (nodbusbeing a synonym ofdbus none,dbus.system nonefor compatibility).Then, building on the same infrastructure as
whitelist, we could have profile entriesdbus.talk <name>,dbus.own <name>,dbus.see <name>and maybedbus.call <rule>anddbus.broadcast <rule>for each rule, which generate the equivalent flags for thexdg-dbus-proxyinstance (as well asdbus.system.talk, etc. for the instance on the system bus). We probably also needdbus.notalk, etc. pairs (similarly towhitelist/nowhitelist).So the basic configuration would be something like
while each application with bus access least contributes a
dbus.own namespace.of.the.application.*line.The system above has an advantage of being compatible both with existing profiles, and Flatpak premissions (
--talk-name,--own-name,--system-talk-name, and--system-own-namemap todbus.talk,dbus.own,dbus.system.talk, anddbus.system.own, respectively), while supporting the#includemechanism of profile.Of course, a much simpler approach, like
dbus.talkbeing a comma-separated list of names (taking a hint from theseccompcommand), would be sufficient, but the lack of simple#includesupport would be painful.So one plan of action would be
xdg-dbus-proxyin addition to the current blocking behavior.xdg-dbus-proxyinstances.dbus-common.incand enhance profiles with dbus filters converted from Flatpak manifests.1, 2, and 3 looks fun enough (although I unfortunately cannot give an ETA, should I find the time to work on them), while 4 may require extensive testing before it can be released.
@ned64 commented on GitHub (Feb 23, 2020):
I personally needed to add
alternativestoprivate-etc, otherwiseviand many other programs will not work.You are whitelisting
machine-idwhich is quite possibly globally unique - better to generate a new one like I did above.dbus-run-sessiondoes not generate one, I tried. No id would be available if the machine-id is simply removed/inaccessible which might lead to problems for some programs.Anyway, I didn't manage to run
icecatwith these switches. Is/usr/localmountednoexec? I couldn't see that mount:Whitelisting
~/Downloadfailed here, too. Tested by opening a shell (still within new dbus session) instead of icecat.@rusty-snake commented on GitHub (Feb 23, 2020):
Maybe we want
dbus-user.talk,dbus-system.talkand so on to clarify thatdbusmeans only user.@ned64 commented on GitHub (Feb 23, 2020):
Sounds good. How can I help?
@kris7t commented on GitHub (Feb 24, 2020):
I started working on DBus proxying in my fork: https://github.com/kris7t/firejail/tree/dbus-proxy
For now, the user and system buses can be blocked separately by
--dbus-user=blockand--dbus-system=block, and--dbus-user=filterand--dbus-system=filtercan be used to run a very restrictive (nothing exceptorg.freedesktop.DBusis visible) filter. Filter rules--dbus-user.talk,--dbus-user.own,--dbus-system.talk, and--dbus-system.ownare supported. Documentation is still to go.