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

KeyError: 'encrypted' #27

Open
Siding3823 opened this issue Nov 20, 2023 · 4 comments
Open

KeyError: 'encrypted' #27

Siding3823 opened this issue Nov 20, 2023 · 4 comments

Comments

@Siding3823
Copy link

Hello. I bumped in the following error when executing BitwardenDecrypt

  File "/home/$USER/build/BitwardenDecrypt/BitwardenDecrypt.py", line 604, in <module>
    main(args)
  File "/home/$USER/build/BitwardenDecrypt/BitwardenDecrypt.py", line 585, in main
    decryptedJSON = decryptBitwardenJSON(options)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/$USER/build/BitwardenDecrypt/BitwardenDecrypt.py", line 394, in decryptBitwardenJSON
    email, kdfIterations, encKey, encPrivateKey = checkFileFormatVersion(options)
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/$USER/build/BitwardenDecrypt/BitwardenDecrypt.py", line 362, in checkFileFormatVersion
    encKey = datafile[options.account['UUID']]['keys']['cryptoSymmetricKey']['encrypted']
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'encrypted'

I start application as python3 BitwardenDecrypt.py ./data.json
My Bitwarden desktop app version: 2023.10.1
I run on linux

@iirekm
Copy link

iirekm commented Dec 14, 2023

I have the same, data.json comes from desktop app 2023.12.0

@zackslash
Copy link

It looks like in recent desktop app versions the value of encKey has moved location in the bitwarden data.json.

Potentially this repo/tool is no longer maintained but for anyone else looking for a quick fix; changing the BitwardenDecrypt.py script file in this repo from

encKey = datafile[options.account['UUID']]['keys']['cryptoSymmetricKey']['encrypted']

to

encKey = datafile[options.account['UUID']]['keys']['masterKeyEncryptedUserKey']

seems to resolve this error at the moment.

@bvwpo
Copy link

bvwpo commented May 11, 2024

In addition to the replacement provided by zackslash, I had to replace the next line after that in the same manner as well to make it work:

encPrivateKey = datafile[options.account['UUID']]['keys']['privateKey']['encrypted']

to

encPrivateKey = datafile[options.account['UUID']]['keys']['masterKeyEncryptedUserKey']

However, the above only works for my backups up until March 2023. Which is probably when I had switched to Argon. Current released version (1.6) does not support this. There is an unreleased version that supports Argon here: #23
That version works on my backups up until December 2023. After that I get the same error described by the OP. Doing the same replacements above (and another one in the same nature) fixes that, but then I get another error regarding organization keys (I don't have any organizations in my vault):

File BitwardenDecrypt.py, line 476, in decryptBitwardenJSON for uuid, value in organizationKeys.items(): ^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'items'

It looks like in recent desktop app versions the value of encKey has moved location in the bitwarden data.json.

Potentially this repo/tool is no longer maintained but for anyone else looking for a quick fix; changing the BitwardenDecrypt.py script file in this repo from

encKey = datafile[options.account['UUID']]['keys']['cryptoSymmetricKey']['encrypted']

to

encKey = datafile[options.account['UUID']]['keys']['masterKeyEncryptedUserKey']

seems to resolve this error at the moment.

@Davek145
Copy link

Hi to all.
I have reviewed changes done by Bitwarden in recent releases. They are doing quite significant changes, which are not documented and not even mentioned in release notes.

I have made small updates to the script to support structure of the data.json file up to version 2024.1.0. #30
2024.1.0 is the last version, which is not introducing larger breaking changes I have noticed in later releases. What is worse, the format changes with every release they have made from Jan till now. It does not make sense to follow them until the format stabilizes. I hope, they will revert some of these format changes as they do not make much sense to me. They are breaking the whole logic of json objects hierarchy, which is not what I would expect to be intended. Let's see, how the format stabilizes in few months. I will than look at it again.

At this moment I suggest you use version 2024.1.0 of CLI to obtain the data.json file for decryption. You can have newer version of the desktop app or server and still use 2024.1.0 CLI version. Format of the data.json created by the CLI is driven by version of the CLI executable.

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

No branches or pull requests

5 participants