Repository navigation
feat(credentials)!: Encrypt stored credentials at rest - #3109
Merged
Merged
Conversation
Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: David Cramer <[email protected]>
Contributor
|
214 screenshot changes — 0 changed · 214 added · 0 removed |
…edentials Co-Authored-By: David Cramer <[email protected]>
This comment has been minimized.
This comment has been minimized.
…ample build Co-Authored-By: David Cramer <[email protected]>
dcramer
approved these changes
Nov 10, 2026
dcramer
left a comment
Member
There was a problem hiding this comment.
if no encryption key is present it should hard refuse to build or something? and we should set a default in test envs
whatever way we make it safe right now, we wanna enforce generating this
Contributor
Author
|
Yes, it now refuses to build without a key. Changed in 198d10c.
|
…as missing Co-Authored-By: David Cramer <[email protected]>
dcramer
added a commit
that referenced
this pull request
Nov 11, 2026
Review summaries got no 👀. David's review bodies on #3111, #3109, and #3091 have no reaction, but his conversation comment on #3108 does. **Root cause:** `pullRequestFeedbackTarget` marked only `pull_request.comment.created` and `pull_request.review_comment.created`. Review events set no `commentId` or `commentKind`. GitHub also has no REST reactions endpoint for a review body. **Fix:** every comment on a pull request now gets the same behavior: conversation comments, inline review comments, and review bodies. - A submitted review with a non-blank body sets `commentId` (the review id) and `commentKind: "review_body"` on its event data. - The webhook marks the first pull request event that has a feedback target. An approval with a body is also sent as `review.commented`, and it gets one reaction. For `review_body`, the webhook reads the review's `node_id` and sends GraphQL `addReaction` (`EYES`). - All comment events share one feedback guidance: call `github_updatePullRequestFeedback` with `repo`, `pull_request`, `comment_id`, and `comment_kind` from Verified details. - `github_updatePullRequestFeedback` requires `pull_request` for every kind. It checks that the bot authored that pull request and that the comment is on it, then replaces Junior's state reaction. Review bodies use GraphQL `reactionGroups.viewerHasReacted`, `removeReaction`, and `addReaction`. `reaction_id` is now optional, because GraphQL gives no id for a reaction that already exists. - The egress policy allows `AddReviewReaction` and `RemoveReviewReaction` only for the host operation `github.pull.review-reaction.update:<repo>`. **Remaining risk:** the GraphQL calls are tested only against fakes. `viewerHasReacted` depends on the installation credential that the egress read grant picks today. The webhook adds one REST read for each review with a body. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A0f0c2da6c27982200b4d351cdb09043e --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A0f0c2da6c27982200b4d351cdb09043e) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A0f0c2da6c27982200b4d351cdb09043e/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3d886b1. Configure here.
dcramer
added a commit
that referenced
this pull request
Nov 11, 2026
Moves every read of Junior's signing secrets into `packages/junior/src/chat/secrets.ts`, and adds an ast-grep rule (`no-secret-env-reads-outside-secrets-module`) that rejects reads anywhere else in `packages/junior/src`. To find out what code can touch keys, you now only have to read one file. That backs the blast-radius rule in #3137. The rule covers `JUNIOR_SECRET`, `BETTER_AUTH_SECRET`, `JUNIOR_SCHEDULER_SECRET`, `CRON_SECRET`, and `JUNIOR_WEB_PUSH_PRIVATE_KEY`. Each caller keeps its own error message and its own behavior when a secret is missing. The sign-in fallback still uses `??` on the raw values. Out of scope: - `JUNIOR_ENCRYPTION_KEYS` / `JUNIOR_ENCRYPTION_KEY_ID` aren't on main yet. Whichever of this PR and #3109 merges second should add them to the module and the rule. - Plugin webhook secrets (`LINEAR_`, `SENTRY_`, `VERCEL_WEBHOOK_SECRET`) and `GOOGLE_CLIENT_SECRET` belong to plugins or provider OAuth config. - Test configs and `cli/env.ts` set these variables for local runs. The rule only checks reads of `process.env` in non-test source. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A0972f6eada08f9c48a19ff20324ffbe0 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A0972f6eada08f9c48a19ff20324ffbe0) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A0972f6eada08f9c48a19ff20324ffbe0/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
dcramer
pushed a commit
that referenced
this pull request
Nov 11, 2026
#3141 and #3109 both merged. #3141 confines secret env reads to `chat/secrets.ts`. #3109 adds `JUNIOR_ENCRYPTION_KEYS` and `JUNIOR_ENCRYPTION_KEY_ID`, which the rule does not cover yet. The rule now covers both keys. No code reads them from `process.env` directly. `chat/config.ts` passes the startup env to `readEncryptionKeyring` once, and `chat/encryption/keyring.ts` parses them. The comment in `secrets.ts` names that path, so it stays the one documented exception and does not drift into a second place that reads keys. Moving the keyring read into `secrets.ts` would change the env-injection contract of `readChatConfig`, which tests depend on. This PR does not do that. <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1794357294.209209 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1794357294.209209) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1794357294.209209/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
23 tasks done
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.

Until now, provider credentials in Redis were stored as plaintext JSON. This change encrypts them at rest with a dedicated keyring that supports rotation.
Keys (
chat/encryption/keyring.ts)JUNIOR_ENCRYPTION_KEYS: comma-separated<id>:<key>entries. Each key is 32 random bytes in base64 or base64url.JUNIOR_ENCRYPTION_KEY_ID: the key used for new writes. Optional when there is only one key.JUNIOR_SECRET, so signing and encryption rotate independently.nitro buildboth fail without one. The error includes the command that generates a key. Tests, dashboard e2e, and the CI example build use fixed test-only keys.Encryption (
chat/encryption/secret.ts,state.ts)jenc:v1:<keyId>:<iv>.<ciphertext>.<tag>.createEncryptedState(stateAdapter)wrapsset/get.readEncryptedStatealso reportsstale, meaning the value is plaintext from before this change or was encrypted with a key that is no longer active.Records now encrypted: user OAuth tokens, MCP OAuth credentials, MCP OAuth sign-in attempts (which hold the PKCE verifier), MCP service-account credentials and their pending sign-ins, and sandbox egress leases.
Rotation (documented in config-and-env)
The two deploys mean every instance can decrypt the new key before anything writes with it.
What happens to stale values
encryption.secret_unreadable, so the user gets the normal connect prompt. That covers a key id that isn't configured and a malformed or altered envelope.TODO(dcramer)).Deploy note:
JUNIOR_ENCRYPTION_KEYSis required. It must be set in every environment before this ships, or the app will not start.Follow-ups:
via @dcramer.
--
View Session [Sentry]