Skip to content

Add Linux v11 gnome-keyring/libsecret cookie and token decryption#56

Open
IvoryKir wants to merge 2 commits intodevxoul:mainfrom
IvoryKir:feat/linux-v11-keyring-decryption
Open

Add Linux v11 gnome-keyring/libsecret cookie and token decryption#56
IvoryKir wants to merge 2 commits intodevxoul:mainfrom
IvoryKir:feat/linux-v11-keyring-decryption

Conversation

@IvoryKir
Copy link

@IvoryKir IvoryKir commented Mar 13, 2026

Summary

This PR fixes two separate auth extraction failures on Linux:

Fix 1 — Linux v11 gnome-keyring/libsecret cookie and token decryption

On modern Linux desktops with gnome-keyring, Chromium-based apps (Slack, Discord) encrypt cookies/tokens with a v11 version prefix using a password stored in the system keyring via libsecret. The existing v10 code path (PR #35) uses a hardcoded 'peanuts' password, but v11-prefixed data was never handled — it fell through to return null, causing auth extraction to fail on most GNOME desktops.

Changes:

  • Slack token-extractor.ts: decryptV11CookieLinux() looks up the keyring password via secret-tool lookup xdg:schema chrome_libsecret_os_crypt_password_v2 application <AppName> for app names ['Slack', 'slack']. Same PBKDF2(password, 'saltysalt', 1, 16, sha1) + AES-128-CBC as v10. Falls back to peanuts if keyring is unavailable.
  • Discord token-extractor.ts: decryptV11LinuxToken() with the same pattern for ['discord', 'Discord']. decryptLinuxToken() now checks the v11 prefix first.
  • Both share a private getLinuxKeyringPassword(appName) helper (testable via spyOn).

Fix 2 — TOKEN_REGEX widened to support newer Discord user IDs

Discord user IDs created ~2023+ produce base64-encoded first token segments longer than 24 characters. Example:

  • User ID 1295726388820709399 → base64 MTI5NTcyNjM4ODgyMDcwOTM5OQ = 26 chars

The previous regex [\w-]{24} (exactly 24) matched starting 2 chars late, returning a truncated token that fails API validation with 401. Fixed by changing {24}{24,}.

Tests

4 new tests across both platforms:

  • Slack v11: decrypts when keyring available + fallback to peanuts
  • Discord v11: decrypts when keyring available + fallback to peanuts
  • Discord TOKEN_REGEX: validates tokens with >24 char first segments

All 904 tests pass, bun typecheck and bun lint clean.

Related

Builds on #35 which added v10 Linux support.

On modern Linux desktops with gnome-keyring, Chromium-based apps encrypt
cookies/tokens with a v11 prefix using a password stored in the keyring
via libsecret. The v10 code path only handles the hardcoded 'peanuts'
password, causing auth extraction to fail on most GNOME desktops.

- Slack: add decryptV11CookieLinux() that looks up the keyring password
  via secret-tool for app names ['Slack', 'slack'], derives the AES key
  with PBKDF2(password, 'saltysalt', 1, 16, sha1), and falls back to the
  v10 peanuts key if the keyring is unavailable
- Discord: add decryptV11LinuxToken() with the same pattern for app names
  ['discord', 'Discord'], extracted into decryptLinuxToken() which now
  checks the v11 prefix before falling back to peanuts
- Both methods share a private getLinuxKeyringPassword() helper to make
  the keyring lookup easily testable via spyOn
- Tests cover: keyring-available decryption and peanuts fallback path

Builds on PR devxoul#35 which added v10 Linux support.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@vercel
Copy link

vercel bot commented Mar 13, 2026

@IvoryKir is attempting to deploy a commit to the devxoul Team on Vercel.

A member of the Team first needs to authorize it.

…h >24 char base64 segments

Discord user IDs created ~2023+ produce base64-encoded first segments
longer than 24 characters (e.g. user ID 1295726388820709399 encodes to
'MTI5NTcyNjM4ODgyMDcwOTM5OQ' = 26 chars). The previous regex {24} matched
exactly 24 chars, causing the match to start 2 chars late and return a
truncated token that fails API auth with 401.

Change {24} to {24,} so the regex greedily matches the full first segment
regardless of length. Also add a test covering the >24 char case.
@IvoryKir IvoryKir closed this Mar 13, 2026
@IvoryKir IvoryKir reopened this Mar 13, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

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.

1 participant