mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #2205] Program in X11 sandbox can kill host X session #1478
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#1478
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 @iskunk on GitHub (Oct 18, 2018).
Original GitHub issue: https://github.com/netblue30/firejail/issues/2205
In testing Firejail with Openbox, I found a rather dismaying issue. (I have verified that this occurs with Git
d0a8395d, the current revision as of this writing.)Start up Openbox in an X11 sandbox like so:
Right-click to bring up the WM menu, select "Exit", and confirm.
Not only does the Openbox-in-Xephyr session go away, the entire host X session [in which you started up Firejail in the first place] goes away. (I obtained this result with the Xfce desktop running on Ubuntu 18.04/bionic.)
And if a sandboxed Openbox can kill your login session, then any sandboxed (X11) program can kill your login session.
For what it's worth, this does not occur if you use
whitelistorprivate.@reinerh commented on GitHub (Oct 19, 2018):
I can't reproduce it. I started
firejail --x11=xephyr openboxinside awesome-wm, and exited openbox via its right-click menu, but my outer X session stayed active.@iskunk commented on GitHub (Oct 19, 2018):
It probably has to do with how the host WM/desktop manages its session, which is why I mentioned that this occurred with Xfce. Openbox is probably sending some sort of semi-standard "end session" message, which Xfce interpreted, but perhaps awesome-wm does not.
@rusty-snake commented on GitHub (May 14, 2019):
@iskunk maybe
firejail --nodbus --x11=xephyr openboxworks.@chiraag-nataraj commented on GitHub (May 21, 2019):
@iskunk Is this still an issue?
@chiraag-nataraj commented on GitHub (May 23, 2019):
I'll go ahead and close this for now. @iskunk, please feel free to re-open if you still have this issue or have further questions.
@iskunk commented on GitHub (May 23, 2019):
Hi @chiraag-nataraj, apologies for the delay; I had to rebuild a test environment for this bug.
I tried this again, using firejail
0.9.60~rc2(Git43cbc6d5), and have verified that the issue still exists. The host X session remains vulnerable to a sandboxed X11 program.I also tested with
--nodbus, as @rusty-snake suggested. Unfortunately, this option did not improve matters.(I cannot re-open this bug.)
@chiraag-nataraj commented on GitHub (May 23, 2019):
Reopening!
@rusty-snake commented on GitHub (May 23, 2019):
@iskunk can you try
firejail --net=none --nonewprivs --nodbus --private --ipc-namespace --nogroups --shell=none --private-tmp --private-bin=openbox --private-etc=none --x11=xephyr openbox. If one (or more) of this args break openbox to start, try without this one.@iskunk commented on GitHub (May 23, 2019):
@rusty-snake, I had to drop
--private-binand--private-etcfor Openbox to start, but with the remaining options, the session was not killed.I then proceeded to remove options (except for
--x11, of course) until I observed the host X session killed as originally reported.The
--privateoption appears to be significant. That one prevents the problem behavior. (Specifically,firejail --private --x11=xephyr openboxis good.)That is not the only one, however. After further testing, I confirmed that
firejail --net=none --private-tmp --x11=xephyr openboxdoes not exhibit the problem either. But if I remove either the--netor the--private-tmp, the problem returns.Note that my test environment is an Xfce (Xubuntu) host X session with a default Openbox session in the sandbox, running on a VM. This issue should not be difficult to reproduce.
@rusty-snake commented on GitHub (Jun 24, 2019):
@iskunk sorry for later responding, but now I have found a solution:
firejail --blacklist=${HOME}/.ICEauthority --x11=xephyr openbox@iskunk commented on GitHub (Jun 24, 2019):
@rusty-snake: Confirmed that blacklisting
~/.ICEauthorityprevents the issue.The various
--x11modes should probably include that one in their blacklisting, yes? The issue of a sandboxed environment killing the host X session is surely unexpected.@rusty-snake commented on GitHub (Jun 25, 2019):
Because it must be added to the openbox profile, but only when --x11 is present, I see three options:
--x11impliedsblacklist ${HOME}/.ICEauthority@iskunk commented on GitHub (Jun 25, 2019):
I would think #3 is the best option, for the following reasons:
--x11already blacklists relevant files like~/.Xauthority; this would only be adding to that, rather than being an entirely new behavior@rusty-snake commented on GitHub (Jun 25, 2019):
With
#3you link to an issue 😁I also think that the 3. option the best solution is, if you hate the necessary C knowledge, you are welcome to open a PR, I can' t (yet) write C 😢 .
@iskunk commented on GitHub (Jun 26, 2019):
Oh, nuts, didn't notice that :-]
I looked in the code. I can find where to add blacklisting for
--x11=none, but the other cases are a bit less straightforward. There's a lot of special handling for~/.Xauthority, for example.I did figure that the
/tmp/.ICE-unix/socket directory should probably also be blocked by default in a sandboxed session. (I can't find a ready-made frontend program that demonstrates this, but it is theoretically possible that a misbehaving non-X program could make use of libICE to send an unwanted "end session" message.)@rusty-snake commented on GitHub (Jun 27, 2019):
private-tmpprenvents access to/tmp/.ICE-unix, but if a profile not has it …@iskunk commented on GitHub (Jun 28, 2019):
Yeah, that explains why
--private-tmpmade the issue go away (as well as--privatewith~/.ICEauthority).This does seem somewhat urgent as the authentication needed to mess with the X session is separate from
XAUTHORITY; i.e. blocking that one does not protect the session.Should we pull in netblue30? I don't think a fix for this should be complicated; it's mainly knowing where the blocking bits need to go...
@chiraag-nataraj commented on GitHub (Sep 16, 2019):
@netblue30 and others, we should put this fix in...
@smitsohu commented on GitHub (Oct 2, 2019):
I tend to agree. I would suggest to mount a tmpfs on this directory, so that just in case a program wants to talk to other programs in the same sandbox using whatever ICE based protocol, it is still able to do so.
But there is one problem, maybe two. First, in the case of session managers the sockets often seem to be no real files but in the abstract namespace (same as the sockets in /tmp/.X11-unix). This means a tmpfs (or a blacklist) is not effective in all cases, we need one of the
netoptions to always and reliably shut down the access. So one "solution" might be to indeed align this feature with thex11options (thematically).Second, I'm a little bit worried if programs both inside and outside sandboxes all write to the same cookie database (aka ~/.ICEauthority). The sockets in /tmp/.ICE-unix are named after the pid of the process that created them, so if there are two or many pid namespaces, there could be a risk of file name collisions. Maybe Firejail should take care each sandbox has their own .ICEauthority file by setting an ICEAUTHORITY environment variable accordingly?
Is this overkill? Other ideas?
@smitsohu commented on GitHub (Oct 2, 2019):
On the other hand, people are provoking similar situations with
private-tmpalready now, and there seem to be no reported problems.@iskunk commented on GitHub (Oct 3, 2019):
My experience to date with
private-tmpis that programs sometimes complain with a message like "cannot connect to session manager." This would likewise happen if ICE is blocked.It's not a showstopper for most X11 applications, and unless people are running e.g. full GNOME desktops within Firejail and complaining that they can't save their sessions properly, I don't think there's a pressing need to provide a separate instance of ICE et al. within an X11 sandbox.
@smitsohu commented on GitHub (Oct 4, 2019):
Or maybe this is too complicated thinking. Should we just add a
blacklist ${HOME}/.ICEauthorityto disable-common.inc?@smitsohu commented on GitHub (Oct 7, 2019):
Alright, proposing a new
?HAS_X11conditional, and putting the blacklist in disable-common.inc. Will put a fix in the next few days.@smitsohu commented on GitHub (Oct 8, 2019):
Oops.
x11 xorgis not covered by the conditional, I'll have to add that option, too.@rusty-snake commented on GitHub (Oct 8, 2019):
for more flexibility in the future something like that would be helpful
@smitsohu commented on GitHub (Oct 9, 2019):
How about something like
?HAS_NET?It tends to have influence on various other options...
That doesn't exclude e.g.
?HAS_NETNONEof course.@rusty-snake commented on GitHub (Oct 9, 2019):
Sure,
HAS_NETor similar isn't bad, but my idea was more about conditions by line match (likeignore).@smitsohu commented on GitHub (Nov 11, 2019):
I'll add
HAS_NETfor the moment as it is useful and a particularly low hanging fruit :)@matu3ba commented on GitHub (Sep 9, 2020):
@smitsohu What is the status on this? Closing?