mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #3568] How to block internet access while retain connection to host native X11 #2236
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#2236
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 @azurvii on GitHub (Aug 4, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3568
The options I explored:
--net=noneblocks both internet and host X11 connection.--net=none --x11works, but I need gpu hardware acceleration, and thus a direct host x11 connection.--netfilterworks only when--net=is used, according to the manpage.--protocol=unixworks only partially. I tested with steam, in which web pages are all broken. But somehow steam can still download games (both new game install and update downloads work).For the 3rd point, my impression is that unix sockets are local. Is it possible to use a unix socket for internet access? I found https://wiki.manjaro.org/index.php?title=Firejail#Block_an_application_from_accessing_the_internet, which seems to side with my impression (that unix socks are local), but somehow firejailed steam is not fully restricted from internet.
In case it might be helpful, how I launch steam is:
firejail --noprofile --seccomp --nonewprivs --caps.drop=all --chroot=~/chroot steam.Not sure what else I can do to achieve the result in the title. Any recommendations / suggestions are welcome.
@rusty-snake commented on GitHub (Aug 4, 2020):
Unix sockets are local and can not be used for TCP/IP. Steam likely spawns a download-worker through systemD/D-Bus .
You can bind mount the regular-X11-socket inside the chroot.
@smitsohu commented on GitHub (Aug 4, 2020):
A bit of a dirty hack is to set an environment variable
FIREJAIL_X11before starting the sandbox, then Firejail will take care of X11 mounting itself. But only do this when not using any of the--x11options.@azurvii commented on GitHub (Aug 5, 2020):
Can you expand a bit on the systemd/dbus exploit? I'm trying to relate how steam can communicate with the systemd/dbus in the chroot, but my assumption is that systemd/dbus that steam talks to is also bound by the
--protocolparameter, which should restrict their outreaching activities. Correct me if I'm wrong.This worked for me! I found some more info in #2711 and the code. Do you have any idea whether this hack would be formalized? E.g. to become a command line parameter. Also, as the solution is similar for #3484 as well, I think this should be able to be applied to pulseaudio as well (which needs to copy
/etc/machine-idand bind-mount/$XDG_RUNTIME_DIR/pulse).@azurvii commented on GitHub (Aug 5, 2020):
I just found that the bind-mounting by
FIREJAIL_X11does not expose the mount in the host (mountshows the mount in the jail but not in the host). And I assume (and hope) that this mount is umounted when firejail exits.If that is correct, this would be much cleaner than the manual mounting outside the jail (I'm scripting it for pulseaudio, and I don't have a good way yet to umount it automatically, considering a possible multiple instances situation).
@smitsohu commented on GitHub (Aug 5, 2020):
These mounts are destroyed when all processes in the sandbox mount namespace have terminated, or in other words, when Firejail exits.
I guess a simple way to formalize this would be to just use an environment variable different from
FIREJAIL_X11. And right, Firejail could do in principle the same with pulseaudio.@smitsohu commented on GitHub (Aug 5, 2020):
The problem is that the process at the other end of the socket doesn't know about our own sandbox restrictions. If you allow a sandbox access to a socket, you open up unrestricted access to the service, and what that means depends on the service alone.
What does
echo $DBUS_SESSION_BUS_ADDRESSsay? Did you maybe bind mount that path in the chroot? Is the issue fixed by adding--nodbusor--dbus-user=none --dbus-system=none(depending on Firejail version)?@azurvii commented on GitHub (Aug 6, 2020):
Do you suggest that firejail mounts the dbus in chroot by default? Not stated in the manpage at least. I was saying that with an assumption that the dbus inside is a different one, and not the dbus outside.
With
--protocol=unix:And when trying with an additional
--nodbus, steam still partially worked (same: no web pages, but downloads work).However, with
--nodbusfirejail added:Warning: An abstract unix socket for session D-BUS might still be available. Use --net or remove unix from --protocol set.I am unable to locate anything like a dbus socket in either
/run/user/1000/or/tmp/.There is a
/run/user/1000/systemdfolder in the chroot, somehow. But it seemssystemdis defunct:I'm not sure how to test dbus. What I came up with:
seems to indicate that dbus is defunct too.
I'll try to find something to figure out which process is handling the network traffic. That might help to provide more clues.
@rusty-snake commented on GitHub (Aug 6, 2020):
To find a abstract unix socket, you must use
ss/netstatorlsof.@smitsohu commented on GitHub (Aug 27, 2020):
I added environment variables
FIREJAIL_CHROOT_X11andFIREJAIL_CHROOT_PULSE, which expose X11 session and pulseaudio session in the chroot, respectively. You can give it a try!No, it doesn't do anything with D-Bus.
@azurvii commented on GitHub (Mar 19, 2021):
Sorry for a much delayed response. I finally got the latest firejail in backports channel.
I tried launching steam with both env, and it worked like a charm! However, I had to manually
mkdir -p /run/user/1000andchownit. OtherwiseFIREJAIL_CHROOT_PULSEwould complain the folder was not found. I did not need to manually copy machine-id to get pulseaudio to work.Thank you smitsohu!