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

kdbx 3 database is very slow to open #6778

Closed
atttx123 opened this issue Jul 28, 2021 · 29 comments
Closed

kdbx 3 database is very slow to open #6778

atttx123 opened this issue Jul 28, 2021 · 29 comments

Comments

@atttx123
Copy link

Overview

keepassxc-cli use 4 seconds to open a 120KB database

image

Expected Behavior

MacPass on the same machine open database less than 2 seconds

KeePassXC - 2.6.6
Revision: 386b79a

Operating system: macOS 11.4
CPU architecture: x86_64
Kernel: darwin 20.5.0

Qt 5.15.2
Debugging mode is disabled.

Enabled extensions:

  • Auto-Type
  • Browser Integration
  • SSH Agent
  • KeeShare (signed and unsigned sharing)
  • YubiKey
  • TouchID

Cryptographic libraries:

  • libgcrypt 1.9.3
@atttx123 atttx123 added the bug label Jul 28, 2021
@droidmonkey
Copy link
Member

Not sure what to do here.

@atttx123
Copy link
Author

atttx123 commented Jul 29, 2021

Not sure what to do here.

@droidmonkey YOU NEED A PERFORMANCE PROFILE!!!!!

Open a lite 120KB file on SSD use 4 seconds, is TOO SLOW.....

MacPass open the same file on the same machine less than 1 second

@phoerious
Copy link
Member

The database size is nothing to do with how long it takes to open the database. That is mostly up to how many rounds you choose for your KDF. Try saving it with a different profile.

@atttx123
Copy link
Author

The database size is nothing to do with how long it takes to open the database. That is mostly up to how many rounds you choose for your KDF. Try saving it with a different profile.

This does not explain why other programs (MacPass、Keepass) do not have such a large delay.

@droidmonkey
Copy link
Member

Do you have this delay when using the regular gui or just in the cli?

@atttx123
Copy link
Author

atttx123 commented Jul 29, 2021

Do you have this delay when using the regular gui or just in the cli?

the gui mode use 2 seconds to unlock the database, see the movie file below

Screen_Recording.mov

@droidmonkey
Copy link
Member

Can you confirm your KDF settings please? Do you have any unique features in your database? Excessive references to other entries or a huge amount of custom icons? How many entries total are in the database?

@atttx123
Copy link
Author

atttx123 commented Jul 29, 2021

Can you confirm your KDF settings please? Do you have any unique features in your database? Excessive references to other entries or a huge amount of custom icons? How many entries total are in the database?

  • no unique features, just a database created by MacPass

  • no custome icons

  • only text entry, no attachments

  • sorry , i do not know how to see the KDF settings

@droidmonkey
Copy link
Member

droidmonkey commented Jul 29, 2021

Using KeePassXC only, can you export the database to csv then import that into a new database? I want to remove the macpass aspect to see if the issue started with them. See if the unlock time remains.

To see the KDF settings go to Database -> Database Security, then choose the encryption tab. You might have to select the advanced checkbox in the lower left corner as well.

@atttx123
Copy link
Author

use the Macpss to open same database on same machine, please see the movie blow

Screen.Recording.2021-07-29.at.18.24.20.mov

@atttx123
Copy link
Author

atttx123 commented Jul 29, 2021

Using KeePassXC only, can you export the database to csv then import that into a new database? I want to remove the macpass aspect to see if the issue started with them. See if the unlock time remains.

image
reimport solved the problem, this is the macpass problem

To see the KDF settings go to Database -> Database Security, then choose the encryption tab. You might have to select the advanced checkbox in the lower left corner as well.

the advanced checkbox is unavailable.
image

@droidmonkey
Copy link
Member

droidmonkey commented Jul 29, 2021

You need to be on the security tab. Those settings are only relevant to the macpass created database.

@atttx123
Copy link
Author

KDF settings
image

@droidmonkey
Copy link
Member

droidmonkey commented Jul 29, 2021

I figured it was a kdbx 3 database (old standard). I'm surprised macpass can unlock that so fast with 13 million rounds on the kdf. Makes you wonder...

If you click the one second benchmark button what number does keepassxc give you?

Sorry for all the questions trying to narrow where the problem is and potential major security flaw in macpass. It could also be that macpass is caching the transformed key in the macos key store, which is also a security issue without explicit prompting to the user.

@atttx123
Copy link
Author

atttx123 commented Jul 29, 2021

If you click the one second benchmark button what number does keepassxc give you?

8~9 million

image

@droidmonkey
Copy link
Member

Makes sense. Ok well that is "interesting" we aren't going to pursue this any further. Seems like it's a default KDF difference with macpass and they must be caching the transformed key somewhere to get a near instant unlock speed. Was it "slow" to unlock the first time?

@atttx123
Copy link
Author

atttx123 commented Jul 29, 2021

Was it "slow" to unlock the first time?

For a kdbx 3 database:

  • 8 million round cost 2.9 seconds
  • 5 million round cost 2.1 seconds
  • 3 million round cost 1.1 seconds

I'm not sure why there is such a big difference from the benchmark value

@droidmonkey
Copy link
Member

The benchmark is calculated very strangely in v2.6.6 and below. We updated that calculation in v2.7.0 with our move to Botan crypto library.

@atttx123
Copy link
Author

atttx123 commented Jul 29, 2021

Understand, thank you for your patience, I will update the title to make the information clearer and close this issue.

Solved by upgrading the database KDF to kdbx 4
image

@atttx123 atttx123 changed the title keepassxc-cli command use 4 seconds to open a 120KB database kdbx 3 database is very slow to open Jul 29, 2021
@phoerious
Copy link
Member

900 rounds of Argon2 at 1MiB? Please use something more sensible that actually consumes some memory. With a bit more than that, 900 rounds should take forever.

@atttx123
Copy link
Author

atttx123 commented Jul 29, 2021

900 rounds of Argon2 at 1MiB? Please use something more sensible that actually consumes some memory. With a bit more than that, 900 rounds should take forever.

I don’t know the details of this algorithm, but I tested the default value kpassxc give, and its speed is a bit slow

  • 50 rounds, 64MiB, 2 threads, cost 2 seconds

@droidmonkey
Copy link
Member

Just half the rounds to get to 1 sec. Leave the memory and threads alone

@atttx123
Copy link
Author

image
cost 0.9 second

@phoerious
Copy link
Member

phoerious commented Jul 29, 2021

The slowdown is expected and a feature that enhances the security of your password file. In fact, the only reason why we use a KDF is to slow things down so an attacker cannot guess billions of different master passwords per second. What decryption time is acceptable to you depends on your personal security profile.

@atttx123
Copy link
Author

😂
You can't have your cake and eat it.
鱼与熊掌不可得兼

@phoerious
Copy link
Member

No idea what it is that you want to tell me.

@kolAflash
Copy link

I understand why delay is needed for security reasons, and this can't be changed. But I have three ideas which might nevertheless help.

 

1. Delay before Password

Are we just talking about delay after entering the password, or also about delay before entering the password?

I recognized, that even before entering the password there's also a 1-2 second delay on a modern CPU (Ryzen 3500U).
This is the time between selecting a KBDX 3.1 file to open and the password dialog being displayed.
(database compression enabled, decryption time set to 1.0 s, KeePassXC-2.6.2 by Debian-11)

I'll call this phase "database selection" to distinguish it from "database decryption".
(question: is the database already being fully read to memory/RAM before the password is being entered?)

As far as I understand encryption, "rounds" apply after entering the password, not before. But maybe this is some encryption/decryption detail I don't fully understand.

 

2. UI informing the User

Maybe something can be done to make this less irritating for the users. The first thing which comes to my mind is a progress bar. Before the password dialog, as well as after the password dialog when decrypting.

 

3. Opening multiple Databases

An additional problem is, that these times add up if multiple databases are being used.

KeePassXC-2.6.2 seems to be set to Load previously open databases on startup by default. And I actually think that's good. But it adds up the delay "database selection" delay of different databases. And the user can do nothing in KeePassXC until this delay has passed for all databases. I use 4 databases regularly, so the time already multiplies by 4.

I also use the AutoOpen feature to open the other 3 databases from the first one.

So also for selecting / decrypting multiple databases a nice progress bar would help.

Additionally it would help if the tabs for all databases open instantly at KeePassXC startup (before entering the password). And the password field is just being disabled until whatever is being done in background (most favorably in another thread) has completed. This would make the UI behave more calm, than if one database opens up after another with some delay in between each. Also the user could already use the UI and do something else like selecting a completely different database. (selecting => open database, not yet decrypting)

@phoerious
Copy link
Member

There is no delay on our side before opening the database, but Linux file pickers seem to take a while to load sometimes (which is an issue with the file picker). Maybe that's what you are experiencing.

@kolAflash
Copy link

@phoerious
The delay is also happening if I open a file from the list of recent files.

Reproduced on Debian-11 and openSUSE-15.4.

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

No branches or pull requests

4 participants