Repository navigation
feat(mcp): encrypt stored MCP credentials at rest - #59
Merged
Merged
Conversation
Seal mcp_server env, headers, auth_tokens and client_info with AES-256-GCM (key from CAMERON_SECRET_KEY) inside mcpServerRepository. Legacy plaintext reads through; writes always seal; a missing key throws rather than writing plaintext. `pnpm db:encrypt-secrets` seals existing rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Servers created before encryption are recreated instead. Legacy plaintext still reads through until then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
The MCP server credentials Cameron stores are now encrypted at rest, so a
pg_dump, a file inbackups/or an exposed Postgres port no longer yields usable secrets. Coversmcp_server.env,headers,auth_tokensandclient_info.src/lib/crypto/secretBox.ts: AES-256-GCM vianode:crypto, a random 12-byte IV per write, and a versioned envelope{ enc, v: 1, iv, tag, data }(base64). The row id and column name are bound as associated data, so an envelope copied to another row or column fails to open.CAMERON_SECRET_KEY(32 bytes, base64:openssl rand -base64 32). Documented in.env.exampleand passed to thewebservice incompose.yaml.mcpServerRepository. Callers still get plainMCPServerobjects.clearOAuthCredentials()(from feat(mcp): move to @langchain/mcp-adapters v2 on MCP SDK v2 #57) writes onlynull, so a credential reset can't write plaintext back.nulland{}are stored as is). Writing a real credential, or reading an envelope, without a key throwsSecretKeyError. A wrong key or an altered value throwsSecretDecryptError. Nothing falls back to writing plaintext. The/api/mcp-serversroutes return those messages instead of a generic 500.code_verifier(short-lived, cleared on connect).docs/OAUTH.md("Token Storage Security"),AGENTS.md, the README,docs/ARCHITECTURE.md, and the Connections form copy, which no longer says "stored unencrypted".Upgrading
CAMERON_SECRET_KEYto.env, and keep it out of your database backups. Losing it means re-entering those credentials.Verification
pnpm test(473 passing, including newsecretBox.test.ts: round trip, tampered ciphertext and tag, wrong key, moved envelope, plaintext passthrough, missing key) andtsc --noEmit.issuerfield.saveClientInfo), which needs a browser sign-in. It uses the same encrypt path as the token save.🤖 Generated with Claude Code