Skip to content

Move GitHub access tokens from plaintext SQLite to OS keychain#15

Open
Ghvstcode wants to merge 1 commit intomainfrom
sustn/move-github-access-tokens-from-plaintext-sqlite-to-os-keycha
Open

Move GitHub access tokens from plaintext SQLite to OS keychain#15
Ghvstcode wants to merge 1 commit intomainfrom
sustn/move-github-access-tokens-from-plaintext-sqlite-to-os-keycha

Conversation

@Ghvstcode
Copy link
Copy Markdown
Owner

SUSTN Auto-PR

The auth flow stores GitHub OAuth access tokens in plaintext in the local SQLite database (auth table in src/core/db/auth.ts). Anyone or any process with file-system read access to the app's data directory can extract a user's GitHub token with full repo read:user user:email scopes.

The keyring crate is not currently in Cargo.toml but Tauri's tauri-plugin-store is already available. However, the most secure approach is to use the OS-level credential store (macOS Keychain). Since this is a single-user desktop app, the migration is straightforward:

  1. Add a Rust command that writes/reads the token via the keyring crate (already identified as a dependency option in project memory) or use security CLI on macOS.
  2. On app start, check if a plaintext token exists in SQLite's auth table — if so, migrate it to the keychain and delete the SQLite row's access_token column value.
  3. Update src/core/db/auth.ts getAuth() / saveAuth() to call the Rust command instead of storing the token in SQL.
  4. Update src/core/services/metrics.ts and any other consumers that read the token via getAuth().

This is the single highest-impact security fix. The token grants write access to all of the user's GitHub repositories (the repo scope), making it an extremely valuable target. Even local-only SQLite files can be exfiltrated by malware or accidentally committed/synced.

Files: src/core/db/auth.ts, src-tauri/src/auth.rs, src-tauri/Cargo.toml, server/src/routes/auth.ts (callback sends token via deep link — consider if that's safe too).

Branch: sustn/move-github-access-tokens-from-plaintext-sqlite-to-os-keycha

…S keychain

The auth flow previously stored GitHub OAuth access tokens in plaintext
in the local SQLite database. Anyone with file-system read access to
the app's data directory could extract the token, which has full `repo
read:user user:email` scopes — granting write access to all of the
user's GitHub repositories.

This moves token storage to the OS-level credential store (macOS
Keychain, Windows Credential Manager, Linux Secret Service) via the
`keyring` crate, which is the most secure option for a desktop app.

- Add `keyring` v3 crate with native backend features
- Add three Tauri commands: keychain_set_token, keychain_get_token,
  keychain_delete_token in src-tauri/src/auth.rs
- Register new commands in src-tauri/src/lib.rs
- Update src/core/db/auth.ts getAuth() to auto-migrate existing
  plaintext tokens to the keychain on first read, then clear the
  SQLite column
- Update saveAuth() to store token in keychain, write empty string
  to SQLite column
- Update clearAuth() to delete the keychain entry alongside the
  SQLite row

Existing consumers (metrics.ts, useFeedback.ts) require no changes
since they call getAuth() which now transparently reads from the
keychain.

SUSTN-Task: d4696627-28bc-40fd-a721-2804dee0f24a
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sustn Ready Ready Preview, Comment Apr 12, 2026 3:23pm

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