mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #3329] keepassxc: please provide more options or more guidance #2091
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#2091
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BillDietrich on GitHub (Apr 8, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3329
Expected behavior
There are several ways or desired ways of using KeePassXC:
Please provide comments in the KeePassXC profile, or additional profiles, to support each of these choices. For example, I would like to run the app without browser extension, without update-checking, with secret service, with SSH agent, with auto-type. I think that means I could run with all network access disabled, but dbus has to be enabled ? Not sure. I want to lock down KeePassXC as tightly as possible given these choices. Please provide more commented sections in the profile, or more profiles, or something, to aid in this. Thanks.
Desktop:
Additional context
KeePassXC 2.5.3
@ghost commented on GitHub (Apr 8, 2020):
Network access is already disabled via
net noneandprotocol unix,netlink. What happens when you try withnodbus? Does that give you the desired setup? We can add comments later, no problem. But IMO it would create more confusion if we offered individual keepassxc profiles that accomodated all permutations you mention. But let's try to find your favo setup first okay?@BillDietrich commented on GitHub (Apr 8, 2020):
In the default configuration (nodbus commented out), neither clicking on an URL in KeePassXC nor auto-type using ctrl+shift+U works. I want them to work. So maybe my focus on dbus is wrong, something else needs to be changed or commented to change.
@BillDietrich commented on GitHub (Apr 8, 2020):
You're right, in the default configuration, update-checking fails saying update error. So maybe add a comment saying "change this if you want update-checking to work".
@rusty-snake commented on GitHub (Apr 9, 2020):
FYI: #3314
The issue here is, how to select the profile. IMHO we have two options
.incs (like feh)Almost all profiles do not support updates, because updates are usually install via apt, dnf, ….
You will need to allow firefox to
if you use chrome or something else it are the same point.
@BillDietrich commented on GitHub (Apr 9, 2020):
I guess updates and update-checking are separate. Maybe add a comment to the profile saying "if you want update-checking to work, un-comment the following:"
@BillDietrich commented on GitHub (Apr 9, 2020):
I am not running the browser (Firefox) under Firejail. If I run KeePassXC without Firejail, clicking URLs and auto-typing work. If I run KeePassXC under Firejail, they fail. So I think the issue is with the KeePassXC profile.
@rusty-snake commented on GitHub (Apr 9, 2020):
Yes, it is. KPXC will start your default handler for e.g.
https://which is firefox. But is has no access to is (private-bin) and firefox then has no access to its profiles (blacklist ${HOME}/.mozilla). The things I descripted above needs to be added to the keepassxc.profile.@rusty-snake commented on GitHub (Apr 9, 2020):
Try this keepassxc.local
@BillDietrich commented on GitHub (Apr 9, 2020):
I added those lines in keepassxc.local, and with KeePasseXC running in Firejail:
if I click an URL in KeePassXC, after 5+ seconds I get a dialog "Your Firefox profile cannot be loaded. It may be missing or inaccessible."
if I auto-type in KeePassXC (ctrl+shift+U on an entry), I get the same error.
So do I have to run Firefox inside Firejail for this to work ? I'm running Firefox without Firejail.
@rusty-snake commented on GitHub (Apr 9, 2020):
Is firefox running in at this time? are there any other modification on the keepassxc profile/local?
@BillDietrich commented on GitHub (Apr 9, 2020):
Yes, FF is running. No, nothing else but comments in keepassxc.local
A year ago I was messing with my keepassxc.profile, but I think by now it's been overwritten by latest standard version. ls says it's 1383 bytes, Dec 30 2019 20:40 keepassxc.profile
@BillDietrich commented on GitHub (Apr 9, 2020):
What does "be present in the sandbox: private-bin firefox" in a previous comment mean ? I'm not running FF inside Firejail.
@rusty-snake commented on GitHub (Apr 9, 2020):
keepassxc will call
/usr/bin/firefox <URL>(or where ever firefox is in $PATH). firefox will then detect that it is already running and use D-Bus (firefox-wayland) or something else (direct IPC?) to tell the running firefox to open .firejail's
private-binoptions restricts the content of /bin, /usr/bin, … to the listed programs. (If you just add firefox to the list, keep in mind that /usr/bin/firefox is often a shell script).@MrFrank17 commented on GitHub (Nov 6, 2020):
Comment about the ssh-agent issue.
Proposed in the linked issue above were these changes:
noblacklist ${HOME}/.ssh# Other things to go.# ignore machine-id# ignore private-tmp# noblacklist /tmp/ssh-*# read-write ${HOME}/.ssh/authorized_keysFor me the first line was not enough, I had to comment in all lines (haven't checked if a subset might be enough, though).
@BillDietrich commented on GitHub (Jun 14, 2021):
Trying again. Now I'm in Fedora 34 KDE with X. I did the keepassxc.local changes you gave. I run "firejail --debug keepassxc DBNAME", open database, click on a link, get this on CLI:
Now I'm using KeePassXC 2.6.4 with Firejail 0.9.64.4. KeePassXC and Firefox are natively installed; no appimage, snap, flatpak. KP works fine if Firejail is not used. I also filed https://github.com/keepassxreboot/keepassxc/issues/6637
@rusty-snake commented on GitHub (Jun 14, 2021):
If
firejail --noprofile keepassxcworks, it's a firejail issue.Good to know, that xdg-open is used. xdg-open is a shell-script, try
@rusty-snake commented on GitHub (Jun 14, 2021):
FWIW there as been done some more on "open-links-from-firejailed-applications" since 9 Apr 2020. #3919 and #3471 and #3881.
systemd-run(https://github.com/netblue30/firejail/issues/3881#issuecomment-805760626)@BillDietrich commented on GitHub (Jun 14, 2021):
KP works fine with --noprofile.
I changed keepassxc.local to be:
And KP fails differently now. When I click on a link, instead of an error on the CLI, I get an error dialog from "KIO Client" saying "unknown host: THEURL host name not found" or words to that effect.
@rusty-snake commented on GitHub (Jun 14, 2021):
Looks like KIO is involved in some way (inside the sandbox) and wants internet access:
@BillDietrich commented on GitHub (Jun 14, 2021):
Okay, now keepassxc.local is:
and when I click on a link, I get a dialog saying "Your Firefox profile could not be loaded, it may be missing or inaccessible". But I have an instance of FF running in the background. Without Firejail on KeePassXC, links will open in FF just fine.
@rusty-snake commented on GitHub (Jun 14, 2021):
If
firejail --profile=keepassxc ls ~/.mozillaworks fine, we need to focus on dbus? seccomp? ...?. If it does not work we need to focus on filesystem commands ((no)blacklist,whitelist(should be all commented),read-only, ...).@BillDietrich commented on GitHub (Jun 14, 2021):
works, it lists the dir. I guess I'll try commenting out all dbus stuff in keepassxc.profile ?
@BillDietrich commented on GitHub (Jun 14, 2021):
It's something in disable-programs.inc that's doing it. If I comment out the include for that, KP works. Have to get back to a clean state and make just that change, re-verify.
@BillDietrich commented on GitHub (Jun 14, 2021):
Okay, so it's working with stock keepassxc.profile BUT with disable-programs.inc commented out, AND with keepassxc.local containing:
@rusty-snake commented on GitHub (Jun 14, 2021):
Then you can fiddle around with
--build,--trace,--tracelogor do a binary search in disable-programs.inc (I guess this is caused by the KIO stuff that wants internet).@BillDietrich commented on GitHub (Jun 14, 2021):
Running with --trace shows a suspicious message "20:keepassxc:mkdir /run/user/1000:-1". 1000 is my userid. How can I allow access to that dir ? Or maybe that's the wrong idea.
The lines from --trace when I click a link are:
@rusty-snake commented on GitHub (Jun 14, 2021):
It's very very very likely accessible from inside the sandbox. This line just says that
mkdir("/run/user/1000", ...)returned-1(likely withEEXISTbut for that you need to runfirejail --allow-debuggers --maybe-something-else --profile=keepassxc strace --strace-args /usr/bin/keepassxc).@BillDietrich commented on GitHub (Jun 14, 2021):
There is a sizable (5-second ?) pause between the trace line "xdg-open" and the line "Cannot open trace log file". I wonder if some kind of mime-type or protocol-handler lookup is failing. But I don't see anything named "xdg*" or "kio*" or other relevant names in disable-programs.inc
@rusty-snake commented on GitHub (Jun 14, 2021):
If a program crashes, the last (to all) lines of
--traceare missing so my guess is that it's not flushed on every write.@BillDietrich commented on GitHub (Jun 14, 2021):
Okay, I'm confused about something. disable-programs.inc is full of "blacklist" statements. I copied it to disable-programs.local and changed every "blacklist" to "noblacklist". I thought that would negate every line in disable-programs.inc, but it didn't (KP still doesn't work). How do I negate a "blacklist" line ?
@rusty-snake commented on GitHub (Jun 14, 2021):
Assuming disable-programs.local is included (no typo or so, check top of
--debug) it's maybe IDK I don't think there's a hardcoded limit of noblacklists and globbing should work too. 😕 You can try toignore blacklist PATHinstead.@BillDietrich commented on GitHub (Jun 14, 2021):
Okay, here's a good one:
--trace fails
--debug works
--trace=xxx.txt works
@BillDietrich commented on GitHub (Jun 14, 2021):
Okay, looks like Firefox is being launched inside the KP firejail, so adding this to keepassxc.local made it work:
@rusty-snake commented on GitHub (Jun 14, 2021):
That's true, but if firefox is already running (in it's own sandbox) it usually communicates to this instance to open a new tab/window. At least until now this worked without access to it's cache. ... anyway
@BillDietrich commented on GitHub (Jun 14, 2021):
Didn't mean to close the issue; can it be re-opened, please ?
@BillDietrich commented on GitHub (Jun 14, 2021):
Confirmed that noblacklist of .cache is needed if an instance of FF is running already. Will check case where FF is not already running.
@rusty-snake commented on GitHub (Jun 14, 2021):
Then FF will start in the KPXC sandbox and totally fail becaus of seccomp, tracelog, blacklist /usr/libexec, ...
@BillDietrich commented on GitHub (Jun 14, 2021):
Yes, checked case where FF is not already running, and it dies horribly. Browser window opens but never loads the page, underneath it seems to be copying my FF profile, and then FF crashes. Is this a known limitation of Firejail or something ?
@BillDietrich commented on GitHub (Jun 15, 2021):
So, I have it working if FF is default browser and an instance is running and click on a link in KP. But can't do same with either Brave browser or ungoogled-chromium. I tried noblacklist of all their config stuff, but still they're failing silently if they're default browser and a browser instance is running and then I click on a link in KP.
@rusty-snake commented on GitHub (Jun 15, 2021):
For chrom* you need to
noblacklisttheir paths and at least I guess@rusty-snake commented on GitHub (Jun 15, 2021):
Without workarounds (https://github.com/netblue30/firejail/issues/3329#issuecomment-860897740), firefox is started in the keepassxc sandbox. If there is a running firefox instance, firefox just does early startup tasks (parse commandline, find profile, ...) and communicates to the running instance. If not, it does a full startup inside the kpxc sandbox. Starting program A in the sandbox made for program B will fail if A requires a permission that is blocked (because B does need it).
@BillDietrich commented on GitHub (Jun 15, 2021):
Okay, the chrom* statements you gave me sort-of worked. If Brave or ungoogled-chromium is default browser and an instance is running, clicking on a link in KP opens another instance of the browser (should use existing instance) and shows some error messages about unable to read profile and want to restore session, but does open the right page. I think if no instance is running and click on a link, instance is launched and page loaded with no error dialogs.
@BillDietrich commented on GitHub (Jun 15, 2021):
Yes, this seems to be a key lack in Firejail. There should be some directive to say "launch-outside-sandbox xdg-open" or something. So whenever KeePassXC or anything launches xdg-open, xdg-open is run outside sandbox, and browser ends up getting launched outside.
@rusty-snake commented on GitHub (Jun 15, 2021):
You can use
systemd-runfor that (see workarounds above) but Why do you want to use a sandbox with escape feature? I would call this sandbox anymore.Related: #3785
See xdg-open.c or firejail-handler-http workarounds above.
@BillDietrich commented on GitHub (Jun 15, 2021):
Would that mean changing the source code of KeePassXC to do that ? I'm a user, not the dev.
The "escape" would be limited to "send this URL out to be opened in whatever app is supposed to be able to open it".
@rusty-snake commented on GitHub (Jun 15, 2021):
One option, however we can not add such firejail support in every app. Therefore it needs to be somewhere else. And
systemd-runallows you to start everything outside of the sandbox.👍 That already possible with xdg-open.c or firejail-handler-http.
@WhyNotHugo commented on GitHub (Jun 15, 2022):
Support is being worked on upstream. KeePassXC already has the changes is
master, but pending release:
https://github.com/keepassxreboot/keepassxc/pull/8030
You also need a proxy with these changes:
https://github.com/varjolintu/keepassxc-proxy-rust/pull/10
This seems really out-of-scope for a password manager, and requires giving it
network access. Why not simply rely on your distribution's update mechanisms?
Regarding opening URLs in the browser, we have a few options:
Allow running Firefox inside the sandbox. If an instance is already running,
it will talk to it over dbus and open the window. However, if no instance is
running, this will run Firefox inside KeePassXC's sandbox. This approach
seems risky.
We could place a tiny script in the sandbox's $PATH that uses the D-Bus
OpenURL portal: https://github.com/flatpak/xdg-desktop-portal/pull/741
Regrettably, the portal is broken and won't work with non-flakpak
sandboxes. This is really an ideal approach for sandboxed applications, but
the PR is simply stalled.
Ideally, KeePassXC could use the above mentioned portal API to open URLs.
Again, the portal will reject the request due to the same issue above, so
this is not viable either.
Perhaps an alternative implementation of the xdg-desktop-portal would help us
fix this, but given its monolithic design, we'd need to re-implement ALL of it