docs(auth): explain why MCP OAuth secrets/tokens aren't app-encrypted#2968
Closed
tofikwest wants to merge 2 commits into
Closed
docs(auth): explain why MCP OAuth secrets/tokens aren't app-encrypted#2968tofikwest wants to merge 2 commits into
tofikwest wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Replaces the breaking attempt to set `storeClientSecret: 'encrypted'` (cubic P1 on PR #2956) with a warning comment. That option would have broken the Gram OAuth flow: better-auth verifies every confidential client through the same decrypt/hash path, including config `trustedClients` whose secret is the plaintext GRAM_OAUTH_CLIENT_SECRET, so verification would fail (`invalid_client`). There is also nothing to encrypt: the Gram client is config-only and DCR is disabled, so no client secrets are persisted to `oauth_application`. The `accessToken`/`refreshToken` in `oauth_access_token` are generated and looked up by raw value by better-auth, so they can't be hashed/encrypted at our layer without breaking token validation; they rely on DB encryption-at-rest + short TTLs. Net: no safe app-level fix exists; documented to prevent re-introduction. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
26054f3 to
55821f9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
My first attempt (
storeClientSecret: 'encrypted') would have broken the Gram OAuth flow — caught in review. This PR replaces it with a warning comment only (zero behavior change). The honest finding: cubic's P1 has no safe app-level fix for our setup.Why
storeClientSecretbreaks thingsVerified in the locked better-auth 1.4.22 source:
getClient()returns a configtrustedClientdirectly, withclientSecret= the plaintextGRAM_OAUTH_CLIENT_SECRET.verifyStoredClientSecret()for every confidential client — no trusted-client bypass.'encrypted', that doessymmetricDecrypt(plaintext_config_secret) === presented→ fails/throws →invalid_client.'hashed'fails identically.Why there's nothing to encrypt anyway
trustedClient(secret in env, never in the DB).oauth_applicationhas no rows. No client secrets are persisted.The access/refresh tokens (what cubic pointed at)
oauth_access_token.accessToken/refreshTokenare generated and looked up by raw value by better-auth, so they can't be hashed/encrypted at our layer without breaking token validation. They rely on DB encryption-at-rest + short access-token TTLs.What this PR does
Leaves a comment in
auth.server.tsdocumenting all of the above, so nobody (human or bot) re-introduces the breakingstoreClientSecretchange. No code behavior changes.Alternative: if a doc-only PR isn't wanted, close this — the knowledge is captured here and in the investigation.
🤖 Generated with Claude Code