-
Notifications
You must be signed in to change notification settings - Fork 17
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
Cannot connect to sandboxed (Flatpak or Snap) browser #29
Comments
In this case the problem is that you are using an isolated Firefox instance (Flatpak version). In other words, you currently must use a native (traditional) distribution package for Firefox. That is a package that is not sandboxed. Here are the limitations of the current working solution in more detail:
I have spent countless hours exploring other (more proper) ways of making all of this work, but they all end with a brick wall. The current solution is the only compromise that works at all. Other solutions may work, but requires changes to either one or all of: KeePassXC, KeePassXC-Browser, Firefox (and others) or even Flatpak. |
By the way, unfortunately your "Possible Solution" does not work. Extensions are more like mounts in the same container, making it a good fit for libraries and plugins. It won't work with executables that need to be launched from the host. In any case, Firefox still needs a way to execute it, which still is not possible from within the sandbox. For the record, way back, I did try packaging org.keepassxc.KeePassXC.Proxy both as an extension and as a regular flatpak in order to learn about this. |
What about DBUS activation? |
Would that work without allowing Firefox to talk to, or own org.keepassxc.KeePassXC? I am no D-Bus expert, but I assume not. There would likely be some sandbox issue. Anyone feel free to correct me if I am wrong. Anyhow, it currently makes no difference since the browser extension can only communicate via stdio. In a perfect world the Native Messaging API would support D-Bus too. Presumably that would make D-Bus activation feasible. You can find some very good documentation on Native Messaging here:
I imagine if it was supported, the native messaging host manifest could contain: Although an ideal solution, it may not be a realistic expectation. All browsers would have to support it and it would likely be a Linux (and BSD) specific solution. That is important to consider, since both KeePassXC and Web Browsers support Windows and MacOS as well. In that case, perhaps a portal (xdg-desktop-portal) could be implemented to act as a generic stdio-to-dbus proxy? Not sure about the details, or if it is even possible; just an initial idea. |
Anyone who searchs for a workaround: Create a wrapper script
Make the script executable with |
@varjolintu This worked, thank you! I had to make one small change though, since my Firefox config file ( |
16 days ago @AsavarTzeth committed a patch to this repo removed the ability to specify the custom proxy location with this note: org.keepassxc.KeePassXC/patch/keepassxc/0003-Support-KeePassXC-Browser-Flatpak-environments.patch Lines 26 to 28 in 7d976c9
However this seems to contradict what @varjolintu stated and @mauvm confirmed, that there is a workaround to make flatpak'ed keepassxc and flatpak'ed Firefox communicate. Were they mistaken? Interestingly, in the latest keepassxc flatpak, I do have the file
which, notably, doesn't have the |
@Ramblurr By quickly looking at the patch after line 102, it seems it could find the proxy without any further configuration. Maybe that code could be included in to the official codebase too, if it really works. |
@varjolintu Hm, interesting. Do you have a working keepassxc - firefox integration, when both are flatpaked (using this latest keepassxc flatpak release)? |
No they were not mistaken. That is an error in the commit message. Thank you for finding it! It should say:
The KeePassXC installation method does not matter, the browser installation method still does. I will make sure to correct that error in the commit message.
It doesn't because that is currently impossible. Flatpak apps can only have a single command exported as a wrapper, which is the command set in the manifest. I workaround that using this wrapper, which automatically uses This is the only way to make it work by default, without changing flatpak, or flatpak-builder itself. Here is one issue related to this: flatpak/flatpak#1638 |
That and the automatic proxy work is the main motivation for the recent reworking of the patches. The main blocker now is time and real life issues that must take precedence. |
@AsavarTzeth Thanks for the good work.
@Ramblurr Like already answered above, it will not work (for now). I've also received a lot of issues where browser is installed via snap. The same sandbox problems exists with it too. |
If you're wondering what is missing to for this particular issue to be closed I know of only two possible solutions.
I don't consider myself an expert and these ideas may be flawed. I have thought about it for a long time though. |
One year passed by. Firefox released an official Flatpak-version on Flathub, but this one is still an issue. :( |
This is a tough problem, given we have three layers of sandboxing that do not make it easy to interact. So here is how I understand the current status
workaround (tries – failed)This uses the new official Firefox flatpak from flathub.
Still did not got it to work, because just symbolic linking these files to the correct destination did not work. Also hardlinking Another workaround would be to pinch a hole in the Firefox sandbox to allow it to spawn other commands on the host, as said before, but I did not try this, given it does not really improve the security in contrast to running a native Firefox installation. Proper solutionAnyway, a proper solution could be:
That said, if that workaround mentioned before could be made possible, this would already help a lot. E.g. maybe the flatpak can get a permission to read this socket? I don't know the flatpak permissions in such a detail to know how to do this. |
Very interesting @rugk, perhaps we could do the following:
The one thing that won't be possible is having KeePassXC automatically configuring the native host manifest. Adding a permission won't work in this case because no app is ever allowed to read another ones app data (under Did I miss anything? You seem well informed of all the issues and the permission issue should be simple enough to solve. The toughest issue is perhaps getting the proxy binary shipped, but perhaps an extension will be accepted, opposed to shipping it with Firefox directly. |
|
Note! Flatpak still sets |
Okay yeah, did not thought about the last thing. Anyway, I've tried it in the other way around, i.e. keeping the file in the Rust proxy patch: https://gist.github.com/rugk/01caaf238ae1e667c67f7b53a9e782e2
Okay, by doing so, I can see the permission overwrite is not working. Firefox cannot see the other dirs other than it's own
Propbably you just cannpt specify it like this? |
Ah, but But yeaah! That worked! 🎉 (and it needs no patch for the proxy) So the issue is just it has to be installed natively, which is bad, of course. |
Aaaand… it also works with the flatpak, if you'd go With the already mentioned overwrite for FF, FF can read the socket file. 🎉 Now… we only have one problem: AFAIK |
If further investigated this issue:
|
That said, I think I've found a way to make that workaround work persistently. I'll do a full writeup later… 😃 |
@rugk Nice work! |
Early 2020's: We've got a working workaround. For those following this thread here in short the news:
Here the full workaround, posted in different places:
|
Awesome work @rugk! I can confirm that the workaround is working on Ubuntu 20.04 with Firefox flatpak and KeePassXC flatpak. |
Interesting fact. I actually managed to reproduce your workaround last week. But instead I used only Flatpaks, a patched proxy and successful overrides under However the very same day I did a reset, because I wished to try it the other way around. But since then I too have broken overrides. In fact no filesystem overrides have worked for me since. It would be interesting to ask some flatpak devs if what the intended behaviour is. In general it has been my personal experience, now and in the past, that filesystem overrides sometimes can be unreliable. Hopefully that is specific to my system. |
Okay, that is strange, that could explain why I did not seem to override directly in As I explained somewhere, I could also only get write access into the |
Any updates on this? |
Probably not a good final solution because it gives Firefox the ability to execute commands outside of its sandbox but a relatively clean, quick and reliable workaround:
Content of #!/bin/sh
exec flatpak-spawn --host flatpak run org.keepassxc.KeePassXC "$@" Content of {
"allowed_extensions": [
"[email protected]"
],
"description": "KeePassXC integration with native messaging support",
"name": "org.keepassxc.keepassxc_browser",
"path": "/home/username/.var/app/org.mozilla.firefox/data/keepassxc-helper",
"type": "stdio"
} |
@zroug Is that a complete workaround? You're right that it won't be accepted as a solution. I very much doubt browser package maintainers would allow that permission or extensions that rely on it. In Firefox's case I'm not sure if they have even added the necessary flatpak extension points that I would need. But as a workaround for savvy users it might suffice, for now. As long as they understand what it means. |
Good. I just wanted to make sure you and anyone else reading this always is informed about that fact. |
@rugk Unfortunately I think the workaround is broken now :( Firefox fails to start when $ flatpak run org.mozilla.firefox
bwrap: Can't make symlink at /run/user/1000/kpxc_server: File exists The only way to get firefox to boot is to remove that symlink. But then firefox creates its own symlink inside its container (that isn't visible on the host) and so it can never follow the host symlink even if you re-create it after starting FF.
|
Uff, thanks for the information. Feel free to comment that on the other places, where I have posted it. That's really unfortunate… |
Tried with both workarounds and none of them work, using firefox v.93.0, also tried with Librewolf without success. |
I think the |
Yes, it probably does but that totally breaks the sandbox security model. So for me at least, it's not a viable workaround. I'd rather copy and paste from KeepassXC manually |
Hi @rugk thanks for all of your work on this issue. I followed your guide found here https://discourse.flathub.org/t/how-to-run-firefox-and-keepassxc-in-a-flatpak-and-get-the-keepassxc-browser-add-on-to-work/437 and got it "working". There were 2 extra things I needed to do to get it working and 2/3 issues to resolve to get it in an acceptable phase for me personally. What I needed to do different:
Then there are 2 (really 3, but 1 I can overlook) issues I am facing:
I am 100% sure the cause is the connection between KeePassXC and Firefox because when I don't run the "systemd-tmpfiles --user --create" command to get them connected, then I can close and re-open Firefox as many times as I want.
Again thanks for all of your work on this. |
Thanks for the addendum, yeah really complicated O have to say but thanks you shared that and great you got it working in "some" way somewhat at least. |
please keepassxc team needs to look into this. I tried the https://discourse.flathub.org/t/how-to-run-firefox-and-keepassxc-in-a-flatpak-and-get-the-keepassxc-browser-add-on-to-work/437
So, I think this needs an official solution. |
Just a little addition to @zroug's solution: If keepassxc is not running in flatpak, change the content of keepassxc-helper to:
|
This is not a problem with the Flatpak, xdg-desktop-portal is coming out with Native Messaging support and reports it works with FireFox Snap Beta |
keepassxreboot/keepassxc/issues/2656
The text was updated successfully, but these errors were encountered: