-
-
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
Make implementation of Challenge-Response more compatible to Keepass 2 #1060
Comments
Yikes, this is not good. Fixing this will also require backwards compat for users who are currently using KeePassXC with Yubikey with an option to "fix" their encryption for portability. |
For the record, the offending code is located here down to line 125. The main issue is challenge response keys are treated separately from normal keys in the CompositeKey::rawKey() function which is called right before the key transformation occurs. We should also be performing the challenge-response and adding that data to the rawKey() return value for use in KeePass2Reader. The best way to clean this up is to "initialize" the composite key first by issuing a challenge-response with the master seed, then using that stored result to compute the rawKey later.
Alternatively, we can leave this broken in the current KeePassReader2 and fix this when we implement KDBX4 format. @PhilippC do you support kdbx4? |
We do need to re-issue a challenge every time we save the database, no matter how we calculate the final key. Otherwise we lose any benefit we have from our implementation over the KeeChallenge implementation. The master seed changes every time, so does the challenge response. I also don't like trying the old way first. There is really no way of knowing how the key was computed and trying several methods multiplies the time it takes to decrypt a database. My database takes about a second on my fastest computer, and on my slowest (my phone) about 5-10. Trying a different method first, would make it two seconds (and 10-20) for absolutely no security gain. I'd rather suggest going the way VeraCrypt did. They have a checkbox "TrueCrypt mode" which allows me to open legacy TrueCrypt containers. We only need to do a better job at letting users know they have to check this box and not forget it every time or come here and complain their databases won't open anymore. |
Thinking about it, we could do it like that:
|
I think that's the best thing to do, but I will also consider fixing this for the KDBX4 format so every new (converted) database will use the new mode and not the legacy one |
KDBX4 is a completely new format, so there is no reason to implement legacy support for KDBX4 databases (although it would probably not even be much extra code). |
its a natural and easy way to fix this issue to only support the keepass2 method of key transform in kdbx4. |
…rently waiting for keepassxreboot/keepassxc#1060), also missing support for saving at the moment and mem-leaking PasswordActivity
Could you check out 2b6f6f5 please and give feedback if everything's alright with that implementation? |
Update: I re-implemented my fix to make it more compact and fix a few KDB(1) test issues. KeePassXC now uses the transform seed as a challenge instead of the master seed for KDBX4: eb62e7d |
glad to see the update on this! I don't have a Yubikey at hand for testing, but from the code it looks like I can make this work with Keepass2Android. Just one thing: You are testing for KDF == AES to decide how to calculate the master key. Is this actually the best way? You can have AES and still use kdbx4 (e.g. when using custom plugin data). |
This is how we determine which format to write. If the user chose AES-KDF, then we write as KDBX4, otherwise KDBX3. I wonder if that could break things if someone opened such a DB in KeePassXC and saved it. It would at least have the effect that the DB will be saved as KDBX3, possibly losing KDBX4-only features. But then, how do you actually determine which format to save in if not the KDF? Let the user choose explicitly? How does KeePass handle this? I don't see an option there either. The only selection I can make is between the two KDFs. |
AES KDF is perfectly valid in kdbx4. We may have to add an interlock to make sure we are never going backwards (ie kdbx4 -> kdbx3). The checks.for Argon2 KDF and a couple others only apply to kdbx3 to kdbx4 up conversion. |
That's not entirely true. If you select AES, then a KDBX3 is saved. And the user should have a way to go back in case they need the old format for compatibility and what not. |
I solved the problem. AES-KDF is now supported for KDBX4 and saving a KDBX4 database with AES-KDF doesn't convert it back to KDBX3 anymore. Please check out my latest commit on the KDBX4 branch. |
…xreboot#1060 * Re-implement KDBX4 challenge-response key assembly with transform seed instead of master seed
* Re-implement KDBX4 challenge-response key assembly with transform seed instead of master seed
- Add support for KDBX 4.0, Argon2 and ChaCha20 [#148, #1179, #1230, #1494] - Add SSH Agent feature [#1098, #1450, #1463] - Add preview panel with details of the selected entry [#879, #1338] - Add more and configurable columns to entry table and allow copying of values by double click [#1305] - Add KeePassXC-Browser API as a replacement for KeePassHTTP [#608] - Deprecate KeePassHTTP [#1392] - Add support for Steam one-time passwords [#1206] - Add support for multiple Auto-Type sequences for a single entry [#1390] - Adjust YubiKey HMAC-SHA1 challenge-response key generation for KDBX 4.0 [#1060] - Replace qHttp with cURL for website icon downloads [#1460] - Remove lock file [#1231] - Add option to create backup file before saving [#1385] - Ask to save a generated password before closing the entry password generator [#1499] - Resolve placeholders recursively [#1078] - Add Auto-Type button to the toolbar [#1056] - Improve window focus handling for Auto-Type dialogs [#1204, #1490] - Auto-Type dialog and password generator can now be exited with ESC [#1252, #1412] - Add optional dark tray icon [#1154] - Add new "Unsafe saving" option to work around saving problems with file sync services [#1385] - Add IBus support to AppImage and additional image formats to Windows builds [#1534, #1537] - Add diceware password generator to CLI [#1406] - Add --key-file option to CLI [#816, #824] - Add DBus interface for opening and closing KeePassXC databases [#283] - Add KDBX compression options to database settings [#1419] - Discourage use of old fixed-length key files in favor of arbitrary files [#1326, #1327] - Correct reference resolution in entry fields [#1486] - Fix window state and recent databases not being remembered on exit [#1453] - Correct history item generation when configuring TOTP for an entry [#1446] - Correct multiple TOTP bugs [#1414] - Automatic saving after every change is now a default [#279] - Allow creation of new entries during search [#1398] - Correct menu issues on macOS [#1335] - Allow compilation on OpenBSD [#1328] - Improve entry attachments view [#1139, #1298] - Fix auto lock for Gnome and Xfce [#910, #1249] - Don't remember key files in file dialogs when the setting is disabled [#1188] - Improve database merging and conflict resolution [#807, #1165] - Fix macOS pasteboard issues [#1202] - Improve startup times on some platforms [#1205] - Hide the notes field by default [#1124] - Toggle main window by clicking tray icon with the middle mouse button [#992] - Fix custom icons not copied over when databases are merged [#1008] - Allow use of DEL key to delete entries [#914] - Correct intermittent crash due to stale history items [#1527] - Sanitize newline characters in title, username and URL fields [#1502] - Reopen previously opened databases in correct order [#774] - Use system's zxcvbn library if available [#701] - Implement various i18n improvements [#690, #875, #1436]
I wanted to implement Challenge-Response in Keepass2Android finally, but unfortunately I am getting an invalid key. So I wanted to do a custom build of KeepassXC to add some debugging output for comparison of intermediate results. Unfortunately I am getting the same error as reported in
I have installed a clean MSys2 and followed the setup instructions for the build-environment. I also tried to install a few additional packages, so the output of pacman -Ss libgcrypt is now
Do you have any additional hint on how to solve this? |
Try deleting and recreating your build folder. Make sure the terminal you have opened has the Mingw64 environment, not the Mingw32 or Msys environment. If it still doesn't work, try setting CMAKE_LIBRARY_PATH to include the path to libgpg-error. You should probably also uninstall the msys/ packages, they might interfere with the mingw -w64-x86_64-* packages. You also don't need any of the mingw -w64-i686-* packages if you only want to build for 64bit. |
it turned out that cmake was selecting my Visual C++ compiler instead of gcc in msys. Build is now working. |
I'd be happy to test this integration. Has it been incorporated into PhilippC/keepass2android yet? |
Interested in testing too! I just got a yubikey neo and this is the feature who brought me to the beta tester group. |
please see PhilippC/keepass2android#4 for updates on this. Unfortunately I don't have lots of time these days to work on KP2A :-( |
@phillippc do you have a branch or PR you are using? I am an Android programmer as well and can assist in debugging if you like. |
I finally released a first version, see PhilippC/keepass2android#4 (comment) |
Hello, this issue was mentioned on the KeePassXC FAQ. Is this resolved? If so, then the warning can be removed. |
Yes, it is, but only for Keepass2Android. |
I would suggest to relax the warning stating that it works for kdbx4 databases with keepass2android. |
As the author of Keepass2Android I was looking into implementing the Challenge-Response functionality as in KeepassXC. While I like the idea of using the Master seed as "challenge", I am not so happy with the implementation of Challenge-Response. To explain why, here is a short overview of the key generation in Keepass 2 (by Dominik Reichl) which is used by Keepass2Android as well:
Keepass2:
KeepassXC, with the naming conventions from Keepass 2
In Keepass 2, it is very common for Plugins to add elements to the Composite Key. These elements are objects of
KcpCustomKey
or custom classes implementing theIUserKey
interface. The data of all these elements are concatenated and transformed. When I added support for KeeOtp or KeeChallenge in Keepass2Android, I did exactly this, which was very simple.In KeepassXC, the challengeRespose is not concatenated with password and (potentially) key file. Instead, it is prepended to the hashed and transformed key. This cannot be implemented for Keepass2 by a plugin, so the current KeepassXC implementation will not be usable for Keepass 2 users, and nobody can change this by developing a plugin. It also requires some pretty intrusive code changes if I want to implement this in Keepass2Android which I believe are not necessary if KeepassXC would offer (at least as an option or better as the default) to concat the challengeResponse to the pbAllData.
If I didn't miss any important reason to integrate the challengeResponse at this point in the processing, I suggest you make the key computation more compatible to other Keepass implementations. Please let me know what you think so I can plan further development on the feature for keepass2android.
The text was updated successfully, but these errors were encountered: