FireJail - Linux sandbox

Discussion in 'all things UNIX' started by Gitmo East, Oct 16, 2014.

  1. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    An even more powerful sandbox for Firefox, use the --seccomp switch:

    Code:
    firejail --seccomp --profile=/etc/firejail/firefox.profile --private.keep=.mozilla,Firefox_Temp firefox
     
  2. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    An example using the --debug switch to show the effects of sandboxing Chromium browser this way:

    I can't explain the warnings near the end but there are no noticeable issues using the browser this way.
     
  3. Amanda

    Amanda Registered Member

    Joined:
    Aug 8, 2013
    Posts:
    2,115
    Location:
    Brasil
    Can I use Firejail to sandbox an app that is not installed?
     
  4. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    Sorry, I don't know if that's possible or not :doubt:
     
  5. Firebytes

    Firebytes Registered Member

    Joined:
    May 29, 2007
    Posts:
    917
    @ wat0114

    Thanks for all the helpful information. It's nice to have instructions.

    Being as I'm mostly used to Windows, it sure would be nice if the GUI included more options for setting things up. Maybe the author will continue to develop it.
     
  6. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    You're welcome, Firebytes. Firejail has so many options, most of which I've never used, so it looks like like one can tailor it to their needs in so many different ways.
     
  7. Amanda

    Amanda Registered Member

    Joined:
    Aug 8, 2013
    Posts:
    2,115
    Location:
    Brasil
    Is there any performance loss while using FJ?
     
  8. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    Nothing appreciable in my experience:

    24065 root 20 0 3.4m 1.5m 0.0 0.1 0:00.00 S `- firejail
     
  9. UnknownK

    UnknownK Registered Member

    Joined:
    Nov 3, 2012
    Posts:
    160
    Location:
    Unknown
    Why are you giving full paths to firejail application profiles, there is no need to. A simple $ firejail firefox or $ firejail --private.keep=.mozilla firefox should suffice. What happens is that if there is a profile for the application in /etc/firejail or ~/.config/firejail, firejail automatically loads that profile.

    And there is no need to use the seccomp flag manually, it's already there in default firefox profile.

    I would suggest those starting with firejail to avoid the gui tool, and instead create launchers for easier access. Give it a name, application with firejail ( application can be firefox, chromium and any other app you want) and in the command field write the appropriate command.
     
  10. UnknownK

    UnknownK Registered Member

    Joined:
    Nov 3, 2012
    Posts:
    160
    Location:
    Unknown
    What do you mean by this? What is the app that you need to sandbox which is not installed?:confused:
     
  11. Amanda

    Amanda Registered Member

    Joined:
    Aug 8, 2013
    Posts:
    2,115
    Location:
    Brasil
    @UnknownK For example, one can extract the .deb package of Steam on the home folder and execute it from there. It will not install anything outside of the /home folder, it will create it's own set of directories :)

    There are other examples such as X-Plane's installer for Linux, or this helicopter for X-Plane that requires one to execute the installer. None of these two require root priviledges, they execute directly from the folder you extracted them.
     
    Last edited: Aug 9, 2015
  12. UnknownK

    UnknownK Registered Member

    Joined:
    Nov 3, 2012
    Posts:
    160
    Location:
    Unknown
    Yes, now I understand. You can sandbox them. I sandbox my TBB bundle which is not installed in the system. Just create a profile for it in ~/.config/firejail and name it after the executing script. Go to directory where the script is located and start firejail with $ firejail ./this-is-the-script-to-start-application-x-which-is-not-installed. For this you need to have this-is-the-script-to-start-application-x-which-is-not-installed.profile in ~/.config/firejail.
     
    Last edited: Aug 9, 2015
  13. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    With your first command "firejail firefox" changes I make in the browser persist. The second one does seem to work, though, so thanks for that I'm not an expert on this application, just experimenting, trying to figure it out. Also, I didn't take a look at the Firefox profile, not knowing the seccomp switch was in it.
     
  14. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    It looks like for chromium the command is simply:
    Code:
    $ firejail --private.keep=.config/chromium/ chromium 
    ...that at least seems to work and of course similar idea for Firefox. Thanks for the clarification, Unknown. Still, $firejail firefox doesn't seem to discard changes made.
     
  15. UnknownK

    UnknownK Registered Member

    Joined:
    Nov 3, 2012
    Posts:
    160
    Location:
    Unknown
    $ firejail firefox will persist the changes and is the default behaviour. $ firejail --private.keep=.mozilla firefox will mount a temporary file system on top of /home and will just copy the contents of ~/.mozilla to the temp fs. The changes will be discared after you close firefox.

    For semi-persistence there is another method. Just create a new folder named firefox_fj_home or whatever you may wish in your home directory. Start $ firejail --private=firefox_fj_home firefox. Whatever you download in that firefox instance, whatever addons you installed, whatever bookmarks you marked will stay in that folder even after you close that instance of firefox. In short, firefox_fj_home will behave like your actual home. You can remove firefox_fj_home afterwards if you don't want persistence.
     
    Last edited: Aug 9, 2015
  16. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    Very good, thanks again!I will try the semi-persistence approach.
     
  17. AutoCascade

    AutoCascade Registered Member

    Joined:
    Feb 16, 2014
    Posts:
    741
    Location:
    United States
    I can see right now where for Firefox this is a great security method since their own sandbox is still not running by default but for Chrome/Chromium does this provide any further protection than it's own built in sandbox?
     
  18. UnknownK

    UnknownK Registered Member

    Joined:
    Nov 3, 2012
    Posts:
    160
    Location:
    Unknown
    Firejail does offer further protection. You can prevent the browser, and in turn the attacker gaining control of the browser, from accessing sensitive user files and directories storing passwords, encryption keys and certificates, etc. You can block whatever files/directories you want. An attacker gaining control of the browser will have no access to them. Not possible with the default chrome/chromium sandbox.

    The ability to completely/selectively discard any changes to the system is another plus.
     
    Last edited: Aug 10, 2015
  19. J_L

    J_L Registered Member

    Joined:
    Nov 6, 2009
    Posts:
    8,738
    Weird that no comparisons to Docker were made yet... Maybe this is just so obviously superior?
     
  20. AutoCascade

    AutoCascade Registered Member

    Joined:
    Feb 16, 2014
    Posts:
    741
    Location:
    United States
    It seems Chrome has since dropped using the SUID sandbox.

    Sandbox Status

    SUID Sandbox No
    Namespace Sandbox Yes
    PID namespaces Yes
    Network namespaces Yes
    Seccomp-BPF sandbox Yes
    Seccomp-BPF sandbox supports TSYNC Yes
    Yama LSM enforcing Yes
    You are adequately sandboxed.
     
  21. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    Running ver 44.0.2403.130 Chromium and SUID is still active.
     
  22. AutoCascade

    AutoCascade Registered Member

    Joined:
    Feb 16, 2014
    Posts:
    741
    Location:
    United States
    What kernel are you running?

    “The namespace sandbox aims to replace the setuid sandbox. It has the advantage of not requiring a setuid binary. It's based on (unprivileged) user namespaces in the Linux kernel. It generally requires a kernel >= 3.10, although it may work with 3.8 if certain patches are backported.

    Starting with M-43, if the kernel supports it, unprivileged namespaces are used instead of the setuid sandbox. Starting with M-44, certain processes run in their own PID namespace, which isolates them better.”
     
  23. deBoetie

    deBoetie Registered Member

    Joined:
    Aug 7, 2013
    Posts:
    1,832
    Location:
    UK
    0.9.28 has been released in the last week:
    https://l3net.wordpress.com/projects/firejail/firejail-release-notes/
    Apart from the ability to set up an extensive sandboxed network environment, the things that caught my eye were also support for a common directory blacklist definition, noroot option in profiles with noroot as defautl; and inclusion of the package in the Debian repositories. More to like.

    The comparison with Docker is interesting, in that they obviously use many similar techniques and kernel functionality. I think the key point is that Firejail works with uncooperative applications - in other words, pretty much all of them, plus gives you as user some control over the way it's configured, rather than having that defined as part of the package. What's truly shocking is the feeble extent to which applications use standard kernel functions to improve security in the first place, but then that doesn't bring in the cash and it's hard.
     
  24. wat0114

    wat0114 Registered Member

    Joined:
    Aug 5, 2012
    Posts:
    4,096
    Location:
    Canada
    $ uname -r 4.1.4-1-ARCH

    Only the namespace sandbox is unavailable:

    SUID Sandbox Yes
    Namespace Sandbox No
    PID namespaces Yes
    Network namespaces Yes
    Seccomp-BPF sandbox Yes
    Seccomp-BPF sandbox supports TSYNC Yes
    Yama LSM enforcing Yes
     
  25. AutoCascade

    AutoCascade Registered Member

    Joined:
    Feb 16, 2014
    Posts:
    741
    Location:
    United States
    https://goo.gl/4qdyck

    Compatibility
    Containers or plain chroots can throw a wrench into the ease of using TPE, as each one has a local /etc/group. A group with the same id in the container will still work as a whitelist, but this will be broken if the container makes use of user namespaces (not yet supported by Arch kernels).
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.