Skip to content

fix(auth): never persist social-login provider tokens (0.5.7) - #133

Merged
sh1pt-actions-fleet[bot] merged 1 commit into
mainfrom
feat/sealed-user-secrets
Oct 28, 2026
Merged

sh1pt-actions-fleet[bot] merged 1 commit into
mainfrom
feat/sealed-user-secrets

Conversation

@sh1pt-actions-fleet

Copy link
Copy Markdown
Contributor

Fleet sealed-secrets sweep, nightcell7.

Finding: accounts.access_token / refresh_token / id_token are plaintext columns that Better Auth fills on every social sign-in.

Audit:

  • Nothing reads them: no getAccessToken, no provider API calls, no code touches accounts outside Better Auth.
  • No social provider is configured (email+password, magic link, passkey).
  • Prod (nightcell7_com on dev2 shared PG): 10 accounts, all credential; access/refresh/id tokens = 0/0/0; all 10 passwords are scrypt hashes.
  • No other user-given secrets in the schema (sessions.token is a server-issued session id; passkeys.public_key is public).

Change: databaseHooks.account.create/update.before null the access, refresh and id tokens and their expiries, so adding a social provider later cannot start storing them. A feature that genuinely needs a provider token must seal it with @profullstack/sealed-secrets.

No migration and no data to NULL. Tests: 523/523 vitest, auth + api tsc, eslint clean.

🤖 Generated with Claude Code

Better Auth writes accounts.access_token / refresh_token / id_token in
plaintext on every social sign-in. Nothing in NIGHTCELL 7 calls a provider
API on a player's behalf, so add account create/update hooks that null
those fields (and their expiries) before they reach the database.

No social provider is configured today (email+password, magic link,
passkey), and prod holds 10 credential accounts with zero tokens, so no
existing rows need clearing; this keeps it that way if one is added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sh1pt-actions-fleet
sh1pt-actions-fleet Bot merged commit 5b9a538 into main Oct 28, 2026
3 of 4 checks passed
});

it("leaves a credential account (password hash) alone and adds no token keys", () => {
const account = { providerId: "credential", accountId: "u1", userId: "u1", password: "salt:hash" };
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

2 finding(s)

MEDIUM: 1 | LOW: 1

Severity Rule Location
MEDIUM js-unescaped-html-sink apps/site/app/_components/pit-footer.tsx:17
LOW secret-generic-credential packages/auth/src/server.test.ts:53

Snippets are redacted; ThreatCrush never prints matched credential material.

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.

2 participants