Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Manager Sandboxing #1261

Closed
SkewedZeppelin opened this issue May 3, 2017 · 5 comments
Closed

File Manager Sandboxing #1261

SkewedZeppelin opened this issue May 3, 2017 · 5 comments
Labels
enhancement New feature request

Comments

@SkewedZeppelin
Copy link
Collaborator

SkewedZeppelin commented May 3, 2017

Symlinks for the common file managers are installed in /usr/local/bin by firecfg. File managers are usually started by default at login time, and will be sandboxed. Clicking on a file in the file manager will start the corresponding program in the same sandbox as the file manager. For example, clicking on a video file will start a sandboxed VLC running the video.

Does that not defeat the purpose of Firejail? Any sandboxed program spawned under an already existing sandbox will not have its profile set, correct? So then won't that give programs more permissions then they'd normally have? And at the same time falsely leading users to believe that their apps are sandboxed?

For example gedit has 'net none', but if you open up a txt file from within Thunar, it'll end up with networking access. This issue becomes even worse when you end up spawning an application with a whitelist only profile which then ends up with full access to your files. Demonstration here: https://gist.github.com/SpotComms/55c8372cef381439cd9a90476e175f93

This point was clearly brought up in #1178 so I don't understand how this happened.

@cryzed
Copy link

cryzed commented May 3, 2017

That is correct, see also #1256, the last 2 comments especially. To quote @netblue30:

Unfortunately that's not possible, the first sandbox will not allow the second sandbox to rise privileges and set up the profile.

If you are really motivated there is a way to work around it: Have one "firejail-launcher" process listening on a socket unsandboxed for incoming requests. Then from within the Sandbox that you want to start, you can configure the opener (xdg-open and variants) using desktop files or using your file manager's file association settings, to instead open the text file using something like: firejail-launcher run gedit. When you then attempt to edit the text file, the firejail-launcher process instead contacts the instance running outside the sandbox and launches gedit with the correct profile and arguments.

I did something like this, but I haven't used it much since, see here (I have since switched to using whitelist in my profiles, so the features related to updating home-prefixes are outdated and need to be removed, in case you are curious). So this Python script has a daemon command (starts the firejail-launcher outside the sandbox) and a run command, which is used from within the sandbox. To contact the daemon, XMLRPC is used. There's also a whitelist feature, so not every process in a firejail sandbox can launch every other process using the launcher -- however this is still incomplete: there's currently no easy way to create specific whitelists for specific sandboxes.

The reason why I haven't actually used it much is, because I don't sandbox my file manager. If I can't trust my file manager, I'd rather be using a different desktop environment, and I reduced potential exploit vectors by disabling file thumbnails completely. Very unlikely that magic is in some way exploitable, since it just reads the first 1024 bytes of a file or so to determine the MIME-type. I also usually have some kind of "bridge" folder in my file system, usually ~/Downloads where most data is shared between my other processes, and they all have access t it.

So I feel your concerns are valid, but they can be worked around if you are motivated enough/willing to put up with some work. I still would like if there was something like the launcher idea directly integrated into firejail -- however I'm also not sure if this is the perfect way to do it, just the one I came up with.

@SkewedZeppelin
Copy link
Collaborator Author

Yes, but shouldn't file managers be removed from firecfg for now to at least prevent this escalation? That was my original point, to simply remove them.

@cryzed
Copy link

cryzed commented May 3, 2017

Oh huh right, I completely missed that. Sorry for going off on a tangent then. Also I agree that firecfg should not create "weak" profile symlinks then.

@netblue30
Copy link
Owner

Thanks, I removed caja (MATE), nemo (Cinnamon) and thunar (XFCE) from firecfg.config.

In my testing on Debian stable, pcmanfm (LXDE) uses a full path and will not pick up the symbolic link in /usr/local/bin - I am still looking into it.

Dolphin (KDE) has a different architecture, and will always pick up the symbolic link even when dolphin is sandboxed. This means we can bring in a very restrictive setup for Dolphin.

I cannot figure out Gnome. I cannot get even basic functionality like clicking on a pdf file and opening it in a sandbox, regardless what the sandbox profile is. I am on Ubuntu Gnome 17.04, nautilus is there but is not run when the file manager starts.

@SpotComms : the two most important lines in a profile file are "seccomp" and "include /etc/firejail/disable-common.inc". I would say they bring in about 80% of all the security possible. In most cases this is better than nothing.

@cryzed : we try to stay away for bringing in a new daemons. Such a daemon would be very difficult to secure, more difficult than gedit or some other regular program we try to secure in the first place.

I'll keep this open, if you run into problems let me know.

@netblue30 netblue30 added the enhancement New feature request label May 3, 2017
@netblue30
Copy link
Owner

all set, I have support for LXDE and LXQT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature request
Projects
None yet
Development

No branches or pull requests

3 participants