mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #1599] sandbox escapes with kdeinit #1067
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#1067
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 @smitsohu on GitHub (Oct 9, 2017).
Original GitHub issue: https://github.com/netblue30/firejail/issues/1599
KDE's ubiquitous KIO makes it quite easy to escape from a Firejail sandbox. Try the following:
We blacklist a pdf file which we then successfully open with kioclient from inside the jail. In a second terminal we can see that
firejail --treedoesn't list the pdf reader, it has escaped the sandbox. Also the seccomp filter is lost.Probably relevant to #1594
EDIT: looking a bit further, this is getting confusing. Not all applications escape, and behavior changes over time. For example Firefox escapes on Debian Jessie Mate, but not on Kubuntu 17.10.
@netblue30 commented on GitHub (Oct 10, 2017):
What happens if you run "sudo firecfg"?. This should set the symbolic link in /usr/local/bin, so when okular is started it will firejailed automatically.
@smitsohu commented on GitHub (Oct 10, 2017):
Yes, okular starts inside a new sandbox when a symbolic link is set in /usr/local/bin. While "sudo firecfg" cannot really solve the issue, it certainly helps to some extent.
The first idea was to address this by dbus isolation, and it works in many cases. But there is reason to doubt it works reliably. A Thunderbird jail on KDE with
net eth0andapparmor, set to use xdg-open for handling pdf attachments, still allows Okular to escape the sandbox somehow.@smitsohu commented on GitHub (Oct 11, 2017):
The real problem is kdeinit itself, which lives outside the jail and waits for requests to launch new applications. Try with the kshell command, again Okular (or any other application) escapes from the sandbox:
This can be blocked by blacklisting the kdeinit sockets.
But there is another way to access kdeinit. From documentation, how KIO slaves get started:
(it would be good to know what the communication channel between klauncher and kdeinit is)
Thus blacklisting kdeinit sockets is necessary, and isolating dbus is necessary equally. Both together are probably already sufficient.
@smitsohu commented on GitHub (Oct 15, 2017):
Issue was brought up already in #1256
@smitsohu commented on GitHub (Oct 18, 2017):
d9ba74da22causes trouble when the kdeinit process gets killed, and it is tried to start it again inside firejail (binding to the blacklisted pathname fails).This appears to be an issue mainly for kdeinit4... see #725 why it may look tempting to kill kdeinit4 (amarok is a more reliable test case than okular though).
Related note: If the kdeinit4 process runs inside a sandbox, which should be the case when all KDE apps are firejailed automatically and the desktop environment is not KDE4, sandbox escapes are also prevented. So "sudo firecfg" is indeed an alternative to blacklisting the kdeinit4 socket (except on the KDE4 desktop).
My suggestion would be then to blacklist only the kdeinit5 socket. Different opinions, better ideas?
@curiosity-seeker commented on GitHub (Oct 20, 2017):
@smitsohu : I tried to reproduce your example in the first post on Fedora 26.
Warning: an existing sandbox was detected. /usr/bin/okular will run without any additional sandboxing features... but:
So in both cases there is no sandbox escape for okular. But as you wrote there seems to be no consistent behavior. It might differ from distro to distro. It's confusing.
EDIT: FWIW, in both cases
grep Seccomp /proc/xxxx/statusgives this result for okular:Seccomp: 2@smitsohu commented on GitHub (Oct 20, 2017):
@curiosity-seeker The recipe in the first post is lacking an ingredient, because I didn't properly understand the issue first: it works only if kdeinit4 already runs outside firejail. That's why kdeinit4 is an issue primarily for the Plasma 4 desktop (and also when not all KDE apps are firejailed), and kdeinit5 is an issue primarily for the Plasma 5 desktop.
Try it instead with
kioclient5 exec /home/hank/Example.pdf. It will ask kdeinit5 for the service, which is always running unconfined in the background on Fedora 26.In order to deny access to dbus on Fedora, use
blacklist /run/user/enteryouruserid/bus.@curiosity-seeker commented on GitHub (Oct 20, 2017):
@smitsohu : Ah, yes, this makes a difference! Without blacklisting
/run/user/1000/busand with the symlink for okular in /usr/local/bin it starts sandboxed:Note that now - contrary to above example with kdeinit4 - okular does no longer run as a sub-process but as its own firejailed process.
And without the symlink okular is now unsandboxed!
But with blacklisting
/run/user/1000/busand without the symlink okular is sandboxed:It's now running as a sub-process - but okular produces an error message:
Could not open file:///home/hank/Example.pdf, and on the console I get:Same as above but with the symlink yields exactly the same result. Only difference is a different error message on the console:
Okay ... what does that tell us?
@smitsohu commented on GitHub (Oct 21, 2017):
It shows that dbus facilitates sandbox escapes (but this is no big news). A best practice, independent of the desktop environment, is to deny dbus access wherever it is possible.
On KDE it has traditionally been difficult to do this, because there used to be no KIO without dbus (like in #947).
But good news is that the situation is improving, and the ability to keep KIO while blocking dbus has already arrived in the KDE flavors of some distros.
@curiosity-seeker commented on GitHub (Oct 21, 2017):
In my understanding of above tests this sandbox escape only happens if
/run/user/1000/busis not blacklisted and there is no symlink for the helper application. Yes, that case qualifies as a sandbox escape. But as already mentioned in #1594, using xdg-open in order to execute the helper application is no sandbox escape, IMHO, as without a private-bin line in the profile anything in /usr/bin is allowed to execute including xdg-open.@smitsohu commented on GitHub (Oct 28, 2017):
A solution with obviously better confinement is to keep the kdeinit4 socket on the blacklist and to noblacklist it for a selection of apps, essentially the KDE apps.
Doing it this way should keep us supporting legacy installations (like Ubuntu 14.04, Centos 7 and so on).
EDIT: Just started it and it looks ugly. I doubt we want it. We need another solution.