mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #977] dbus filter #664
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#664
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 @valoq on GitHub (Dec 14, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/977
While looking at similar sandboxing projects like flatpak https://github.com/flatpak/flatpak/wiki/Sandbox
I found some interesting ideas how to filter for dbus communication: https://github.com/flatpak/flatpak/tree/master/dbus-proxy
Since some applications need access to the dbus socket, it would be helpful to allow for such filters to be applied.
@netblue30 commented on GitHub (Dec 14, 2016):
I am still waiting to see where they are going with it. In my opinion, you can still access the abstract Unix socket and bypass the proxy.
Ubuntu Snap people have a different approach, they use AppArmor to filter dbus. Unfortunately, AppArmor kernel module they use is not in mainstream kernel. If they manage to push their modifications upstream, this would be a much better solution.
@valoq commented on GitHub (Dec 14, 2016):
Do you have some more information about abstract unix sockets and how to use them to bypass filters?
AppArmor will not be a general solution as there are some distributions that don't work with it. Arch is one example where you won't be able to use AppArmor without compiling your own kernel.
@valoq commented on GitHub (Dec 14, 2016):
It seems some filtering of abstract sockets can be realised with network namespaces:
https://lists.linuxfoundation.org/pipermail/containers/2014-December/035487.html
@netblue30 commented on GitHub (Dec 15, 2016):
abstract sockets: you open and handle them the same way you handle regular Unix sockets. The only difference is in the name, you basically start the name with a '\0'. This is what they say in man 7 unix:
A network namespace would disable the abstract socket, but it is all or nothing. So, when you run "firejail --net=none evince", the abstract socket for dbus is gone.
@valoq commented on GitHub (Dec 15, 2016):
Can we install a network namespace that blocks (all) communication via abstract sockets but allows for normal inet connections?
That would still not allow for specific filtering but it would make blocking of socket ipc reliable.
I have observed that some applications that e.g. use the X11 socket, require either access to the socket file in /tmp/.X11... or require the absence of "net none"
That could indicate that the use of abstract sockets is optional and can be used as an alternative communication way. This is both bad and good. It means that blocking file access to sockets is not enough, but also that by blocking abstract sockets in general, it might be possible to use those dbus-proxies on the files sockets to filter requests.
@chiraag-nataraj commented on GitHub (Dec 15, 2016):
Just as a side-note, it might be possible (as is the case with both
dbusandX11) to modify the configuration files to disable abstract sockets (see #801). This is what I have done at this point since there are some cases where I need network access but don't want the program to have access to the abstract sockets.@valoq commented on GitHub (Dec 15, 2016):
@chiraag-nataraj That would require changing the configuration of application/system settings. This has been avoided so far by firejail. I'm not sure that's the way to go.
@chiraag-nataraj commented on GitHub (Dec 15, 2016):
@valoq Oh I'm not suggesting that firejail adopt this (as you say, it's modification of system files). All I'm saying is that this is an alternate route you can take in the meantime while @netblue30 figures out how to deal with abstract sockets without having to cut off all internet access.
[edit] As @netblue30 points out below, you can indeed set up a new network namespace and still retain internet access. What I meant to say is that the alternate route is useful when you're not able to create a new network namespace (e.g. you're usually on wifi).
@netblue30 commented on GitHub (Dec 17, 2016):
This is what happens when you run "firejail --net=eth0". You get internet connectivity, and dbus abstract socket is gone.
@valoq commented on GitHub (Jan 15, 2017):
On the issue of filtering abstract sockets, I think it might be possible to do that with seccomp, by filtering the arguments of getsockname, which is used to find abstract sockets by name.
That way one could specify the name of an abstract socket to be allowed, while all other abstract sockets are blocked
@talwrii commented on GitHub (Jan 30, 2017):
(Update: I got confused between socket memoray addresses and abstract sockets)
Socket memorary locations:
I don't know if accessing sockets via memory address (c.f. unnamed sockets) is another concern. I was having a look at how hard it is to guess socket memory addresses (since it looks like one can't find the addresses of sockets inside the jail (lsof finds them, and they live in
/proc/net/unix).It's not looking good...
On my machine there seems to be a 8*4 = 32 bit memory block in which these abstract socket live. These seem to be aligned to blocks of the size 2^11
( Method used:
cat /proc/net/unix | tail -n +2 | cut -d: -f 1 | pyline 'str(int(l.strip(), 16))' | sort | npcli 'map(int, np.diff(d))' | grep -v '0' | sort -n | xargs factor)This gives you 2^32 / 2^11 = 2 ^ 21 possible values. So it looks like you could brute force the dbus socket (or any socket for that matter) in seconds or minutes :/.
@talwrii commented on GitHub (Jan 30, 2017):
Hmm, on my machine (debian testing) the abstract socket for dbus has some random numbers in it's name
@/tmp/dbus-9BXXXXjuqe(cat /proc/net/unix | grep '@').