cookie_importer.py may import garbage or fail when multiple Chromium Safe Storage keys exist
Summary
cookie_importer.py can fail to import valid Chromium ChatGPT cookies, or return a cookie_header containing garbage decrypted values when the wrong keyring secret is selected.
This happens on Linux/Chromium when Secret Service contains multiple matching entries such as Chromium Safe Storage, Chrome Safe Storage, or Application key for org.chromium.Chromium.
Environment
- Browser: Chromium
- Cookie DB:
~/.config/chromium/Default/Cookies - Python deps installed:
python3-secretstoragepython3-cryptography
- ChatGPT cookies existed, including:
__Secure-next-auth.session-token.0__Secure-next-auth.session-token.1
Actual behavior
The importer initially returned a cookie_header, but values contained invalid cookie characters such as spaces, quotes, commas, semicolons, and random punctuation.
After adding stricter validation locally, the script correctly returned SESSION_NOT_FOUND instead of accepting garbage. This showed the old script was accepting wrong-key decrypted bytes.
Expected behavior
- Reject wrong-key decryption output.
- Try all plausible matching keyring secrets, not only the first label match.
- Return
cookie_headeronly when session-token values are syntactically plausible. - Never emit garbage cookie values as success.
Fix direction tested locally
A local patch fixed this by:
- Trying all matching keyring secrets.
- Including Chromium labels:
Chromium Safe StorageApplication key for org.chromium.Chromium
- Rejecting invalid PKCS#7 padding.
- Validating cookie values against RFC6265-style cookie characters.
- Reading plaintext
valuewhen present beforeencrypted_value.
After this, the importer returned a valid-looking cookie_header with chunked session-token values.
Security note
Please avoid printing cookie values in debug logs or issue reports. These are live auth secrets.