-
Notifications
You must be signed in to change notification settings - Fork 146
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
Broken decryption in Chrome #210
Comments
I'm just starting to sleuth around the code to find out what actually broke, and one thing I've noticed is that if one looks at what the 3 characters getting chopped off around this line of code, the error that's being encountered happens when the program finds a cookie that does not start with
.. and then immediately hit the exception .. I suspect that a new encryption scheme has been adopted, and the 'fix' will be to understand what needs to be handled differently, and to branch the logic depending on whether it's v10 vs. v20. |
Further sleuthing.. Seems that v20 prefix is indicative of 'App Bound Encryption' at least from what I can make out from a cursory look at this module in the Chromium code base (link to actual line where v20 is defined as such a prefix), and this sort of lines up with this recent announcement about Chrome beefing up its security against scripts being able to access Cookies and impersonate sessions, etc. by employing app-bound encryption (link to article). In summary, I have no answer for how to get around this, save for potentially disabling 'Application Bound Encryption' in Chrome (likely something not recommended but possible). Perhaps someone smarter than me can develop a patch, but I suspect it would be an extremely large lift to get this "fixed". |
Thanks for all the information and help. I would be up for developing such as patch, but alas, I am not that bright. I am going to switch to firefox for the the time being and might consider switching back if there are any new developments. I am going to leave this open in case someone else ends up having the same issue, or is able to do something about it. |
After I updated Chrome earlier today (128.0.6613.120) I have exactly the same problem. Unfortunately I don't have the knowledge to look more into it. |
The solution will probably be something similar to |
This happened after the latest chrome update. |
I encounter the same problem with Chrome version 128.0.6613.120: " browser_cookie3.BrowserCookieError: Unable to get key for cookie decryption". I guess the latest version Chrome change some things for cookie decryption. |
Chrome 128 Release notes: Cross-site ancestor chain bit for CookiePartitionKey of partitioned cookies Chrome 128 adds a cross-site ancestor bit to the key ring of the partitioned cookie's CookiePartitionKey. This change unifies the partition key with the partition key values used in storage partitioning and adds protection against clickjacking attacks by preventing cross-site embedded frames from having access to the top-level-site's partitioned cookies. I think this maybe lead to browser_cookie3 error in getting Chrome 128's Cookie. |
Any update on this? Is this somehow patchable or we're lacking information on what exactly changed? |
in the meantime I use
|
@9DA73860 Your solution only works with 'v10' (which is DPAPI before app bound). So your reply totally mis-point out. @timothy-miron is pointing right matters which I also found and strugling. If you feel working find with the package for specific cookies, the cookie your are accessing is not expired after created by v10. Once it expired and refreshed on newer chrome version, will be face the/this/same matter. For now, no published open source solution for app-bounded 'v20' encryption at this moment(which means all open source people screaming out all around globe including me). By the way, I found, for the app bounded encryption, there is new key for this.
With this, `
` |
Only the workaround that compatible mode as v10 legacy format for Windows I found. [Disclaimer]
[Steps]
And..please any one find the v20-app bound mode python logic for all around globe. Have a good day. |
It works! |
Yes, we can't make every user who uses the software do that. I'd like to see the solution at the development level |
Any solution for v20 yet? |
Im interested in decrypting v20 and have average experience in c++ but im not sure if its specific to the pid or the chrome application or if you can even inject into chrome and decrypt it, |
@VanhLegend @blul1ghtz A guy made some sample code for v20, try it. from |
From the chrome version '130.0.6723.59'(on 16th Oct 2024), Patch needed like below
|
For an alternative way to retrieve the cookie is using Firefox to login to the specific website. I needed the cookies to have a way to login to sites without manually logging in, and currently instead of egde or chrome i just login to the site on firefox and extract the cookie from there. |
@mic-user where exactly should this patch be applied? |
@berkinkadiroglu Usually, ppl using sample code from below two. |
It looks like @mic-user's patch would go here: diff --git a/browser_cookie3/__init__.py b/browser_cookie3/__init__.py
index 33bf364..e65a427 100644
--- a/browser_cookie3/__init__.py
+++ b/browser_cookie3/__init__.py
@@ -574,17 +574,17 @@ class ChromiumBased:
for key in keys:
cipher = AES.new(key, AES.MODE_CBC, self.iv)
# will rise Value Error: invalid padding byte if the key is wrong,
# probably we did not got the key and used peanuts
try:
decrypted = unpad(cipher.decrypt(
encrypted_value), AES.block_size)
- return decrypted.decode('utf-8')
+ return decrypted[32:].decode('utf-8')
except ValueError:
pass
raise BrowserCookieError('Unable to get key for cookie decryption')
class Chrome(ChromiumBased):
"""Class for Google Chrome"""
|
@teddywing Hey,
|
@mic-user Thanks for the backward compatibility suggestion, but I’m afraid I won’t have time to make a real patch and pull request for this fix. |
There is a way to read cookies from Chrome that does not require admin permissions. A PoC was published in thewh1teagle/rookie#81 |
I have a script that has been running fine over the last couple of years, but has suddenly stopped tonight (20240907). This is the error that I got
"""
Error message: Unable to get key for cookie decryption
Traceback (most recent call last):
File "browser_cookie3_init_.py", line 539, in decrypt
File "browser_cookie3_init.py", line 530, in decrypt_windows_chromium
File "browser_cookie3_init.py", line 89, in _crypt_unprotect_data
RuntimeError: Failed to decrypt the cipher text with DPAPI
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "browser_cookie3_init_.py", line 555, in _decrypt
File "Cryptodome\Cipher_mode_gcm.py", line 567, in decrypt_and_verify
File "Cryptodome\Cipher_mode_gcm.py", line 508, in verify
ValueError: MAC check failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 918, in
File "", line 821, in main
File "", line 256, in simulation_dependent_variables
File "browser_cookie3_init_.py", line 1160, in chrome
File "browser_cookie3_init_.py", line 515, in load
File "browser_cookie3_init_.py", line 557, in _decrypt
browser_cookie3.BrowserCookieError: Unable to get key for cookie decryption
"""
I had to previously implement the
--disable-features=LockProfileCookieDatabase
in my chrome shortcut, but other than that I have had no issues. I am currently runningbrowser-cookie3==0.19.1
in python 3.10.12. I am guessing that it's probably a chrome update that lead to this error.Thank you, and I appreciate all the help that you can provide.
The text was updated successfully, but these errors were encountered: