How strong is the Firejail sandbox? #6466
Replies: 4 comments 32 replies
-
I read the most of the thread (I skimmed through some of the comments). I will not correct all the half-knowledge, only the selected quotes and some general clarifications. Security is not black and width, there's security and security. If we talk about user-to-root security (e.g. "firejail is suid") we talk about a different thread model than sandbox-to-user (i.e. sandbox escape). I already wrote in #4601 about that. It's three years old, but the https://xkcd.com/1200/ summary still applies.
Depends ...
If we assume a xkcd 1200 thread model (there are different ones! but it is a common one), ~50% of the profiles have a (very) weak profile.
Right, don't use bubblewrap, use a high-level tool like bubblejail or flatpak.
I have been preaching for years to people who think
seccomp is used to reduce (kernel) attack surface and not to create sandbox policies¹. You can use it to enforce sandbox policies, but you can also enforce them with different technologies. Right now I can not think of any syscall that can be used to escape the sandbox². Under one condition: you keep root out of your sandbox ( ² not counting kernel vulnerabilities or things like general IO syscalls. If you can escape by writing to a file/socket, write access to this file/socket is the problem and not the syscalls used to write.
If the author could share their knowledge how to escape "namespaces and chroots via a few syscalls" assuming an empty capability bounding set. And what syscalsl that are. I would be interested (also for my own projects). Again, access to files/sockets does not count. A weak firesystem policy does not make namespaces for itself insecure. A lot technologies used for sandboxing only work well when used together.
No https://www.kuketz-forum.de/t/erfahrungen-mit-bubblejail-gui-fuer-bubblewrap/9378/10 and "I have installed Firejail as a test and it does not actually block the FF sandbox."
See above.
The blacklist approach on seccomp used by the most tools (firejail, bubblejail, ...) is used to reduce kernel attack surface. Every blocked syscall is a win then. I have to admit that the defined syscall groups are horrible out of date for newer (5.x, 6.x) kernels.
See above.
EVER LOOKED AT THE SYSCALL FILTERS OF THE LISTED PROJECTS? firejail block a few times more syscalls that flatpak by default. Both have much space to improve their syscall filters. For crabjail I also still examine how to create good syscall filters
To some extend true. You could argument that the attacker needs to be aware of firejail i.e the "I've wrote my on OS, it's absolutely secure because there is no malware for it written yet" security. But that's not the point, if you have full code execution inside the sandbox, you can escape from I guess around 80-90% of the profiles. If you only have a limited vulnerability (e.g. arbitrary file truncation) or mass-targeting attacker (e.g. ransomware with only 1% successful entered systems) firejail can safe your ass. |
Beta Was this translation helpful? Give feedback.
-
@rusty-snake Thanks a lot for your reply! Very instructive!
According to /usr/share/doc/firejail/syscalls.txt the default-group is defined as:
Which enhancements would you suggest? |
Beta Was this translation helpful? Give feedback.
-
This is an interesting discussion and I would like to add some thoughts as well. As @rusty-snake has already pointed out much of this comes down to the threat model you have but there are some details between the different tools that should be explained in more details to allow for a better picture. When designing or adding security measures, one of the fundamental question is about how much benefit do you gain for what costs in light of your threat model. Every measure takes time and resources and this is especially true for measures done by individual administrators (unlike measures build into a system by upstream developers which are build and maintained once) Firejails use of suid and especially the way it never drops these privileges effectively #510 #3046 is one concern that lead me to stop contributing to firejail and look for alternatives years ago and it looks like it is still valid today. There have been at least The next question is what we gain for which effort and inconveniences. In my experience no manual sandbox tooling is without drawbacks as there are always compromises to make and new individual use cases that get in the way of any profile build for the average user. That may be fine though if we get some solid risk reduction in return, so lets look at the potential risks first: Threat model A) Threat model B) Ignoring the details and differences between the available tools and considering all of firejail, bubblewrap, flatpak, crabjail etc as isolation tools that are intended to address the issue depicted by xkcd 1200, they can all provide quite similar benefits while also including common drawbacks. The benefits are the isolation of userspace resources (as in user files) and IPC features that would allow sandbox escape. This leads to the conclusion that we can use these sandboxing tools to try to address Thread Model A) but it would be self deception to believe it will help anything at all against Threat Model B) While this could be the end of the discussion, there is another approach that does address both threat models and which is build into modern browsers. That is what google described a decade ago as a "broker architecture sandbox" and which is build into the protected software itself. I believe openssh was actually the first to implement this in 2003 and there is a paper about it somewhere describing it in detail. In essence it splits the application process in two parts and does all the dangerous things in a child process that does not get any access at all. Read that as in 0 syscalls and 0 file access. All the resources and communication this child process needs is handled by the broker (parent) process and while this API between the two process can still include vulnerabilities that trick the broker into passing on unwanted permissions, it has lead to significant improvements and skyrocketing exploit prices for browser exploits (a good indicator of a security measures effect I would argue). And now we need to ask again what is gained by using the above mentioned sandbox tools on applications like firefox that use this broker architecture to isolate every single browser tab and not just the entire application process. I have yet to find a detailed analysis about how relevant the reduction in process isolation is when firefox is run like this but it is obviously not good. And as I have already pointed out, the isolation provided by the sandbox tools above is not a substitute for the internal process sandbox of firefox, it is a far cry actually. And now to the last question to ask when looking at the sandbox tools above: What do we gain from running firefox in firejail/bubblewrap/etc. compared to running firefox without it. The isolation we build with these tools is what I would describe as a solid brick wall that will keep the neighbors dog at bay and certainly helps to prevent unwanted visitors. But when we run firefox inside it, there is already the internal sandbox that would be more akin to a bunkers blast doors that may protect against an indirect nuclear blast. And now we go ahead and put a brick wall behind the blast doors... Who are we kidding here? To address a xkcd 1200 thread model we can use any of the sandbox tools discussed here but there is no use case to use it with applications that already implement far superior process isolation internally. Even worse, we may end up reducing the isolation features like described in the mozilla help page above. Personally I believe that more development efforts need to be invested into building real process isolation into high risk applications, things like vlc, libreoffice and any application that would touch files from untrusted sources like the net. And we do not even need highly controversial features like linux namespaces for this as there are quite solid and easy to implement alternatives like landlock available. And for more complete process isolation like browsers use there are projects like sandboxed-api that help to build broker architecture isolation and completely isolate the kernel syscalls from dangerous parsing child processes. There is also this upcoming project that may be a good starting point to consolidate efforts for linux sandbox implementations. In the meantime there may be good reason to use the sandbox tools above to isolate some application that lack this internal privilege separation, however I am not sure why we do not use the mandatory access control features that linux has come with for decades. |
Beta Was this translation helpful? Give feedback.
-
I'm far from being an expert in this area. I agree that turning off the built-in sandbox in browsers is a very bad idea. But I'm not sure that we don't gain anything from running a browser with, e.g., Firejail. As far as I understand it, there is still the risk of a sandbox escape via IPC. And there have been corresponding weaknesses and attacks in the past (example). In my understanding a "wrapper sandbox" (as @rusty-snake calls it) would protect against such an attack. Please correct me if I'm wrong. That said, I'm using the apparmor.d project and am running Firefox with the profile from that project in combination with firejail-git with Landlock enabled. FWIW, these are my landlock rules in
|
Beta Was this translation helpful? Give feedback.
-
In a German security forum I found this discussion about Bubblejail which expanded to a discussion about Firejail as well.
One participant writes (translated with DeepL):
Comments by the developers would be highly appreciated.
@netblue30 @rusty-snake
Beta Was this translation helpful? Give feedback.
All reactions