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

Added support for Argon2id KDF #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Davek145
Copy link

Support for Argon2 KDF added in Bitwarden 2023.2.0. It is utilizing argon2-cffi library.

Copy link
Owner

@GurpreetKang GurpreetKang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add argon2 to requirements.txt.

Copy link
Owner

@GurpreetKang GurpreetKang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move import argon2 to its own try: / except ModuleNotFoundError: block with an updated exception message.

@Davek145
Copy link
Author

Feel free to take the code over if you are interested and modify as you wish. Unfortunatelly, I do not have time to make it 100%.

@GurpreetKang
Copy link
Owner

So far I'm only seeing 2 tiny changes needed.

@Davek145
Copy link
Author

Davek145 commented Feb 26, 2023

I have corrected these two points and tested that. In the requirements I added version of the library I'm able to confirm to be working. It will probably work already from version 16.3.0, but I cannot verify that.

@GurpreetKang GurpreetKang self-assigned this Feb 27, 2023
@GurpreetKang GurpreetKang linked an issue Feb 27, 2023 that may be closed by this pull request
@ataraxia937
Copy link

I'm curious, where does this PR stand? I see the requested changes were made. Can this be merged?

@ataraxia937
Copy link

Oh, I see it's not actually working. I can't decrypt my export with this.

@Davek145
Copy link
Author

Davek145 commented Jun 8, 2023 via email

@ataraxia937
Copy link

I have a password-protected export with fields like this:

  "encrypted": true,
  "passwordProtected": true,
  "salt": <normal stuff>,
  "kdfType": 1,
  "kdfIterations": 2,
  "kdfMemory": 256,
  "kdfParallelism": 4,
  "encKeyValidation_DO_NOT_EDIT": <normal stuff>
  "data": <normal stuff>
}

When I try to decrypt it:

$ python3 BitwardenDecrypt.py bitwarden_encrypted_export_20230608111639.json

Enter Password (EncryptedJSON):
ERROR: MAC did not match. Protected Symmetric Key was not decrypted. (Password may be wrong)

I am on OpenBSD and I installed the needed python modules from OpenBSD's repository.

@ataraxia937
Copy link

I just tested the same on Ubuntu 22.04 and it didn't work there either.

@GurpreetKang
Copy link
Owner

I'm curious, where does this PR stand? I see the requested changes were made. Can this be merged?

Sorry @ataraxia937 I haven't had time to get back this. Will try to finish I the next 2 weeks. There was some refactor and other changes I wanted to make before merging into main.

@Davek145
Copy link
Author

Davek145 commented Jun 8, 2023

I have just tested the code on my Ubuntu 20.04 and it is working OK for me both for data.json synced via CLI as well as password protected export.
However, I use Vaultvarden. It shall have the same format of the file as the official Bitwarden as the Webvault is the same (I'm now on verion 2023.3.0), but I cannot test it.
What looks strange to me is, that you claim to test it on password protected export, but he your file has kdfType = 1, so argon2. If I make password protected export, it always uses pbkdf2. Argon2 is only used for directcly synced data.json file from my server.
If you try it on official Bitwarden server, may be they have changed something with the password protected export that Vaultwarden is not yet using. Try it also on synced data.json that is having data in better format and also including organization entries.

@ataraxia937
Copy link

ataraxia937 commented Jun 8, 2023 via email

@zackslash
Copy link

zackslash commented Sep 4, 2023

This branch is working well for me using Argon2 in official Bitwarden. @ataraxia937 the name of the file you are attempting to decrypt (bitwarden_encrypted_export_20230608111639.json) indicates it is likely a bitwarden export file, decrypting exports is not something supported by this project anyway (according to the readme) and is most likely the reason for it not working for you, you need to instead use the data.json file (from the Desktop App).

Note: BitwardenDecrypt does not work with Bitwarden Encrypted JSON Exports.
These exports lack the Protected Symmetric Key needed to decrypt entries.

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

Successfully merging this pull request may close these issues.

Add support for Argon2 KDF
4 participants