codexbar-gnome icon indicating copy to clipboard operation
codexbar-gnome copied to clipboard

cookie_importer.py may import garbage or fail when multiple Chromium Safe Storage keys exist

Open ChrisLauinger77 opened this issue 6 months ago • 0 comments

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-secretstorage
    • python3-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_header only 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 Storage
    • Application key for org.chromium.Chromium
  • Rejecting invalid PKCS#7 padding.
  • Validating cookie values against RFC6265-style cookie characters.
  • Reading plaintext value when present before encrypted_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.

ChrisLauinger77 avatar May 30 '26 12:05 ChrisLauinger77