Skip to content

ref(security): Read signing and encryption secrets in one module - #3141

Merged
dcramer merged 1 commit into
mainfrom
ref/secret-env-module
Nov 11, 2026
Merged

dcramer merged 1 commit into
mainfrom
ref/secret-env-module

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

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 feat(credentials)!: Encrypt stored credentials at rest #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.

via @dcramer.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 11, 2026 12:58am UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

11 screenshot changes — 11 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Event Log Virtual · Desktop
Conversation Event Log Virtual · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Question Picks And Text · Desktop
Conversation Question Picks And Text · Desktop
Changed
Conversation Question Stepper · Desktop
Conversation Question Stepper · Desktop
Changed
Conversation Text Attachment · Desktop
Conversation Text Attachment · Desktop
Changed
Show 5 more changed screenshots
Conversations Sections Collapsed · Desktop
Conversations Sections Collapsed · Desktop
Changed
Memories · Mobile
Memories · Mobile
Changed
Push Notifications Tip · Desktop
Push Notifications Tip · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed
Settings Notifications · Desktop
Settings Notifications · Desktop
Changed

@dcramer
dcramer merged commit 8f4be5b into main Nov 11, 2026
45 checks passed
@dcramer
dcramer deleted the ref/secret-env-module branch November 11, 2026 01:23
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>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — ade511c8 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant