Skip to content

Is firejail "safe"? If not, what options are better?

I just answered another post in regards to firejail and I decided to create my own post about it.

I know a couple of years ago people were advicing against using firejail due to it's attack surface, but this was as I said a few years back and since then it seems the security concerns has either been resolved or forgotten.

I did some quick digging and I couldn't find any information that pointed to the security issues beeing resolved, all I found was a few sources stating the issues, but all of these are at least 2 years old.

Here are a couple of the sources I've found:

https://www.openwall.com/lists/oss-security/2017/01/05/4

https://www.reddit.com/r/linux/comments/79mmzk/sandbox_your_applications_with_firejail/

I also had a look at the arch wiki page for firejail where I coudn't find anything about these issues and at the firejail github where I also fell short of answeres.

The closest I came to finding anything of relevance there was this link:

https://github.com/netblue30/firejail/issues/510

So, is firejail safe? If not, can it be made safer? Does the benefits still outweigh the security issues? Are there better alternatives to sandboxing than firejail?

Thanks.

48 points38 comments
Open on Reddit
About this post
Posted
Archived
Score
48 · 100% up
Kind
Text
ID
eemvea

Author

3
posts
26
comments
0
media
View profile

42 comments

I don't know if Firejail is truly safe, having use it in the past together with Apparmor it wasn't always the best solution and it has it's up and downs:

  • Not every application was able to run correctly under Firejail without editing profiles.

  • You need to create symlinks and edit your profile(s).

  • It didn't feel like I was more secured against alternatives like standalone Apparmor or SELinux and the frustration of testing every app is working fine with Firejail (e.g. something can't be accessed) is just terrible.

I haven't tested alternatives implementations like appimage that also seem to provide Firejail support, just remember every security tool can be defeated by it's own user and configuration is key.

The Arch Wiki provides more and better examples to harden your setup.

10 points

Not every application was able to run correctly under Firejail without editing profiles.

I've noticed this as well, like it not being able to handle dbus correctly, but without reading up on it myself I suspect it may have something to do with the fact that I have additional security in place as well. I suspect hidepid and firejail probably won't play nice together.

It didn't feel like I was more secured against alternatives like standalone Apparmor or SELinux and the frustration of testing every app is working fine with Firejail (e.g. something can't be accessed) is just terrible.

Testing apps is okay by me, but I do agree that I do not "feel" more secured. Although, I suspect this is because of the fact that I in fact have read that firejail might be "insecure" and because of the fact that I also have come across a few bugs (which may or may not have been caused by me). Hence, the reason for this post. :)

1 points

Hidepid shouldn't be used together with Firejail, the Arch Wiki should have a note about this.

I don't know if the comments questioning Firejail's implementation in your OP have been changed/fixed over the years. I simple don't bother to setup Firejail anymore and try to use Apparmor with a good sense of security awareness: check package sources, use as much official provided packages as possible and harden services (like webservers, etc.) instead. Remember systemd also implemented a lot of recent changes that should benefit the user and systeem like protecting it's home or tmp folders.

Just try to remember the user is always the weakest link.

1 points

I did some quick digging and I couldn't find any information that pointed to the security issues beeing resolved, all I found was a few sources stating the issues, but all of these are at least 2 years old.

Known exploits have been fixed when found but the fact its still an overly large suid binary have not been resolved.

Depending on your needs flatpak is an alternative. It provides unprivileged sandboxing, DBus access filtering, and is just all around less complex to configure correctly (secure by default); However it does lack X11 sandboxing if you need that.

4 points

Known exploits have been fixed when found but the fact its still an overly large suid binary have not been resolved.

Yeah, I tried mitigating that by creating an apparmor profile for firejail itself, but seeing as it' needs access to a lot (and I do mean a lot!) it's almost impossible creating a sane profile for it...

Depending on your needs flatpak is an alternative. It provides unprivileged sandboxing, DBus access filtering, and is just all around less complex to configure correctly (secure by default); However it does lack X11 sandboxing if you need that.

I never tried flatpak. Will look into this as well. I mainly sandbox applications like browsers, thunderbird, irc-clients etc. Would you say flatpak is a good fit for that?

1 points

I mainly sandbox applications like browsers, thunderbird, irc-clients etc. Would you say flatpak is a good fit for that?

There is already a Thunderbird flatpak but I believe its a complicated application to sandbox. A few IRC clients are also already flatpaked like HexChat. Browsers are complicated because they already sandbox themselves so like Chromium doesn't quite work yet (will very soon) and honestly its good enough in its own sandbox. A few Firefox flatpaks exist but none are that well supported but they can work well with a bit of love.

3 points

Firejails attack surface is significantly larger than that of Bubblewrap, which in turn is significantly larger than something like Apparmor with unprivileged user namespaces disabled.

If local privilege escalation vulnerabilities are a primary concern, I would always opt for the latter. Not without reason does the kernel restrict comprehensive sandbox configuration to the root user. It is possible to give these powers to ordinary users, which is what both Firejail and Bubblewrap do, but it is not possible to do so without increasing the system attack surface in one way or the other.

Just to put the content of your links somewhat into perspective. Anyways, I'm not really sure how relevant all this is for ordinary desktop users. On a usual desktop, the game is over long before an attacker starts looking for broken SETUID binaries... because user data is the real trophy, and to defend this data you need to get the sandbox configuration right. I'm slightly surprised this discussion got this far without a reference to the relevant xkcd:

https://imgs.xkcd.com/comics/authorization.png

Turns out, for many users it does not matter that much which tool they are choosing. But depending on your specs, some tools may indeed fit better than others.

2 points

Just to put the content of your links somewhat into perspective. Anyways, I'm not really sure how relevant all this is for ordinary desktop users. On a usual desktop, the game is over long before an attacker starts looking for broken SETUID binaries... because user data is the real trophy, and to defend this data you need to get the sandbox configuration right.

What do you suggest for sandboxing user data? E.g. chromium from seeing ~/notes.

1 points

What do you suggest for sandboxing user data? E.g. chromium from seeing ~/notes.

There are a plethora of different user space tools (Bubblewrap, MiniJail, Firejail, ...), but under the hood they all do more or less the same thing. From the perspective of a malware that is trapped inside the sandbox, it doesn't really matter much which tool was used to configure the sandbox. The only question is what is still possible/allowed and what is not.

So what I really want to say is: Use whatever tool you like most. But if you insist on a suggestion, it would be based on attack surface considerations again, because that's where we actually have some differences: With a default Arch kernel and unprivileged user namespaces enabled, I would then recommend Bubblewrap or Google's MiniJail. With a linux-hardened kernel, or if you have unprivileged user namespaces disabled, the options are more limited: IIRC it is not possible use Minijail, and a few apps (Chromium unfortunately is one of them) cannot be sandboxed with Bubblewrap. In this case your only options are Firejail or AppArmor or any other LSM.

1 points

SUID binaries are always a risk.

There is unpriveledged alternative bwrap that flatpak uses.

I am actually working wrapper for bwrap that allows it to function like firejail with pre-defined rules for applications.

1 points

SUID binaries are always a risk.

Please correct me if I'm wrong, but isn't setuid equally risky as SUID? When reading up a bit on bubblewrap vs firejail it seems that none of them have optimal "methods" as to make the binary itself safe(er), but bubblewrap could be considered the safer alternativ due to it's attack surface being smaller. This due to the fact that it is more lightweight and do not offer as much functionality as firejail, which could also be an argument that firejail actually offers more "security" on one hand, but on the other it comes with the less safe binary in terms of attack surface. Am I correct in this assumption?

If you don't take user experience/ease of use into consideration at all, wouldn't actually a solution like this be the most secure alternative when it comes to pure sandboxing: https://wiki.gentoo.org/wiki/Simple_sandbox

Or maybe systemd-nspawn could be a "safer" alternative?

Couldn't you also combine the two options I've provided above to make a an even tighter sandbox (not 100% sure that's possible though)?

In any way, I feel like it must be possible to increase the overall security without decreasing it in other aspects by relying on the use of "unsafe" binaries.

1 points

SUID and SetUID refer to the same thing. You call a binary that makes you a root (or some other user). passwd and sudo work that way.

bwrap uses something different called unprivileged namespace clone. Its a linux kernel compile feature. Arch Linux has it enabled for all kernels except linux-hardened.

With unprivileged namespace clone your process never becomes root instead it has ability to spawn an entire new namespace from user space.

1 points

In any way, I feel like it must be possible to increase the overall security without decreasing it in other aspects by relying on the use of "unsafe" binaries.

One obvious solution could be AppArmor.

1 points

I am not a security guy but you could take a look at bubblewrap for sandboxing desktop applications, it is the executable used by flatpaks and also by gnome to sandbox images and is not setuid. It allow you to use namespaces as a normal user. Also spend some time to understand how to limit syscalls with it.

1 points
unknown author17 hidden

Deleted before we saved it.

-20 points

Well, I'm running Arch on my desktop machine and a couple of laptops and I'm well aware I'm as uninteresting as they come, although, I am interested in the topic and I "like" chasing "security points", because, well... everyone needs a hobby...

15 points

Coming from someone who works in the industry: please don't give out security advice like this. Regardless of your operation scale, your machines will be targets to exploit. Taking security into consideration is important in all aspects of administration.

12 points

If your home network/device is unsecure you're making life for everyone else harder as well.

​

It's like leaving your car unlocked. Someone will take it and overrun someone else. Don't to it, pay attention to your stuff.

5 points

Thank you!

As you work in in the world of security, may I ask what your take on firejail is (and other applications like it for that matter).

I'm leaning more towards MAC like apparmor, kernel hardening etc. but I do like the idea of sandboxing, I just don't know if firejail is a good solution (or what would be a good solution for that matter).

2 points

we all love the "ask someone professional for help" answers under a clearly structured and legit question. Keep up the good work.

4 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.