-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add Polkit Quick Unlock mechanism #8983
Add Polkit Quick Unlock mechanism #8983
Conversation
d703d6e
to
acdfa1f
Compare
Not sure how to go about adding the |
df99937
to
c17e6fb
Compare
That's on our end we'll take care of that
You are my hero thank you |
68c0cc0
to
92998d0
Compare
Haven't touched this in a bit, but now that the vulnerability in 1Password that I discovered has been fixed I feel it's appropriate to discuss it here as it has direct implications on the use of PolKit. The vulnerability boils down to being able to redirect D-Bus calls from the password manager to polkit into your own service. This happens by adjusting the DBUS_SYSTEM_BUS_ADDRESS environment variable when the application is started. I didn't investigate the exact way 1Password fixed this, but there are two ways which I foresee fixing this for KeePassXC
I'm leaning more towards a separate process, but there is a large inconvenience of having to install a system service for this. Any opinions @droidmonkey |
We won't install a system service on our end. This boils down to a Linux environment vulnerability not an application vulnerability. Choice 1 is something either polkit or the desktop env should implement for the benefit of everyone. Choice 2 is a workaround because of a lack of choice 1. Let's just capture the value of the environment variable on startup and/or ignore the actual value. |
Hi! Can we get a status update on this one? Is polkit excluded due to the dbus redirect issue? Saving the env var value on startup and ignoring its actual value during runtime seems to be a valid option to me. However I'm not sure whether storing it for just this purpose would be a nice solution, rather than a hacky one. On the other hand I cannot see a valid purpose why the dbus address would need to be changed during runtime. |
Hi, Sorry been really busy. I am thinking as a way to combat the environment variable making it easy to set, we compile in a list of allowed paths for the dbus system bus. |
A hardcoded path whitelist sounds good to me. If the path doesn't match, I'm in favor of both disabling QuickUnlock and showing a warning similar to what the Secret Service component does when there's another Secret Service provider (such as Gnome keyring) already running. keepassxc/src/fdosecrets/dbus/DBusMgr.cpp Line 412 in bb37cf3
|
New changes implement a single fixed path to access DBus from, which should contain polkit. Changes also implement a I'll try get to these merge conflicts tomorrow, but in the mean time any feedback is much appreciated. |
96f92a0
to
555fd09
Compare
It's basically ready we have a queue of merges to make |
Package maintainers eagerly await. |
And done |
Appreciation for your efforts. I can't manage it to work. I've reinstalled it through
|
Polkit quick unlock won't be available until 2.8.0 is released |
Do we have a rough date on when 2.8.0 will be released? |
I'm hoping for shortly after the new year, we have some important changes in the pipeline right now |
Hello @HexF and @droidmonkey, I have a question regarding this PR, @HexF, you wrote the following:
I would like to consider an Evil maid attack scenario. Let's suppose I have KeepassXC on my computer, my computer is locked but I'm not around. Is the Polkit Quick Unlock is as secure as typing the full password on Linux? If an attacker manage to dump the entire memory while I have left my device unattended, will he be capable to decipher the KeepassXC database if Quick Unlock is enabled even if my database is locked? I have installed KeepassXC Git with Polkit integration, and it works great 🎉. I had the feeling at first that using this PR could increase both the security (since I can increase the password size and lock my database very quickly) and facilitate the ease of use. However, now I'm unsure about the security side. While reading this PR I had the feeling that the Quick Unlock using Polkit could allow an attacker to access the database even if it's locked by "simply" dumping the RAM of the device. In any case, I'm glad this PR has been merged. I love using my fingerprint to decipher my Keepass database 😅. So thank you! Kind regards, |
If you lose physical access to the machine such that a RAM dump can be accomplished, then not much can protect you. Also known as "its my computer now". |
What about encrypting that key (using the fingerprint data as the key for this) in user-space before adding it to the keyring, would this be possible? |
Fingerprint sensors, by design, don't release their template data (the scan and representation of your fingerprint) outside of the scanner for security. OSes only get back a yes/no with some replay protection (depending what protocol its using). |
Also fingerprints are FAR from random and would make terrible keys for encryption. The way polkit integration is implemented now is as secure as possible given the lack of kernel owned keyspace on Linux (i.e., the Linux kernel offers no way to handle sensitive data for user land). Other operating systems like macOS handle encryption keys on the kernel side (and via a hardware key store) to protect data from user land. |
Okay, thanks for the reply! In my setup I have a bash command that automatically lock all my databases when I press Meta+L before starting my locker. Could a command be designed to remove the temporary key in Polkit to avoid such attack? I'm refering to this key: keepassxc/src/quickunlock/Polkit.cpp Line 190 in a8cfefe
|
The key which is stored with the kernel is only one part in decoding the database master key, which is derived from more data stored in user-space. |
Actually, I was thinking that a dbus function could be created. Like the ones described in the wiki. I would love to be able to do a: $ qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.resetQuickUnlock But even if KeepassXC doesn't have a Dbus function for that, I'm worried about the "kill the app" solution. The encryptedMasterKeys stored in the user space are only scrubbed once here in keepassxc/src/quickunlock/Polkit.cpp Line 225 in a8cfefe
I really think the encryptedMasterKeys should be scrubed in the two Click to see the links of the `Polkit::reset(...)` methods I'm refering tohttps://github.com/keepassxreboot/keepassxc/blob/a8cfefe6c8a4c10f4a215a003a98148b56840474/src/quickunlock/Polkit.cpp#L99 https://github.com/keepassxreboot/keepassxc/blob/a8cfefe6c8a4c10f4a215a003a98148b56840474/src/quickunlock/Polkit.cpp#L84And finally, I think the destructor |
We scrub all memory upon free. |
That's great, sorry, I didn't know that. I just read the operator overload of delete, it's very neat :)
|
The reset quick unlock dbus command is super specific to your use case / desires. I personally don't see purpose in something like that and truly defeats the purpose of quick unlock in the first place. It seems like you want to, but not really, use quick unlock. Those memory scrubs are overkill, but sometimes qt can be a little clingy to containers like QString and QByteArray so it doesn't hurt to explicitly clear the buffer while you have hold of it. |
Okay thanks! I think you are right. My request is too specific and can be handled by a simple script (at least for my case since KeepassXC always start in background). I just needed to call a small script before calling my Locker. If that script interest some people, here it is: #!/usr/bin/env bash
function back() {
nohup $@ > /dev/null 2>&1 &
}
KEEPASSXC_DBUS_STR="org.keepassxc.KeePassXC.MainWindow"
if timeout 5 qdbus ${KEEPASSXC_DBUS_STR} /keepassxc lockAllDatabases ; then
# exit keepassxc and restart it to reset the QuickUnlock keys
# see: https://github.com/keepassxreboot/keepassxc/pull/8983#issuecomment-1876248571
qdbus ${KEEPASSXC_DBUS_STR} /keepassxc appExit && back keepassxc
else
echo "Warning: Cannot Lock KeepassXC database"
fi |
Someone from the maintainer team knows if an early release including this feature is possible? I am seeing a lot of still open backlog items for 2.8.0. This feature seems to be very awaited by the Linux users. PS: I am aware of the possibility to build it by myself 😉 |
Ahh yes, this is important: nixutils: failed to parse "/proc/3/stat" Can you share the contents of that file? It's the process information for keepassxc. |
I am seeing the same on manjaro linux.
content of the file
|
I found the error! #10350 |
Awesome I look forward to the snapshot build |
@droidmonkey still not working with the latest snapshot build. Getting the same error
content of the file
|
It's not merged yet..... |
true story - totally missed that |
This pull request closes 2 issues relating to the Quick Unlock feature (commonly referred to as fingerprint support) - #5991 and #3337.
The changes made implement quick unlocking via Polkit on Linux, which provides support for fingerprint authentication, giving Linux feature parity with macOS with its TouchID and Windows with Windows Hello.
Additionally, polkit will fall back to a password if no fingerprint sensor is found, as shown in the screenshots below.
The Polkit mechanism works similar to the existing TouchID implementation, by where the database key is encrypted using a random key which is stored in secure storage, in this case the kernel-space keyring.
As far as I am aware, Linux does not provide a kernel-level mechanism for releasing keys when appropriate credentials such as a password or fingerprint have been provided, so the check is done entirely in the KeepassXC process.
This pull request also makes changes to both the TouchID and Windows Hello implementations of Quick Unlocking, bringing them on to a common interface which should allow for easy development of further Quick Unlock mechanisms - one that comes to mind is using TOTP/one time passwords to unlock the database (#798). The polkit implementation also uses this interface.
Screenshots
(please excuse the polkit action having the wrong wording in the above screenshot - it is surprisingly hard to add polkit actions on nixos without installing anything!)
Testing strategy
Local testing has been carried out through the following steps:
Type of change