Skip to content

fix(auth,atoms): required CALENDSO_ENCRYPTION_KEY and remove Stripe secrets screenshot - #76

Merged
JOY (JOY) merged 2 commits into
devfrom
fix/secrets-hygiene-md30-lo04-lo05
Sep 17, 2026
Merged

JOY (JOY) merged 2 commits into
devfrom
fix/secrets-hygiene-md30-lo04-lo05

Conversation

@JOY

Copy link
Copy Markdown

What

Closes audit findings MD-30, LO-04 and LO-05:

  • LO-04 / LO-05 - three sites used a missing CALENDSO_ENCRYPTION_KEY silently: signJwt and the login getServerSideProps JWT verify encoded it to a zero-length secret (jose happily signs/verifies HS256 with a 0-byte key), and verifyCodeUnAuthenticated degraded its seed to a pure function of the victim email (|| ""). All three now throw, matching the required-env pattern already in next.config.ts. Production containers already refuse to boot without the key (scripts/start.sh), so only misconfigured local setups see the new error.
  • MD-30 - removed the 590KB packages/platform/atoms/static/Stripe secrets.png (test-mode API-keys screenshot with a fully visible Stripe account ID, upstream-inherited). Nothing references the file.

Evidence

  • 84/84 auth feature tests pass locally (yarn test packages/features/auth).
  • biome lint on the changed files: warnings/infos only, same set that already exists on dev (CI lint gate stays green).
  • The seed hash algorithm is intentionally unchanged; switching md5 to HKDF would invalidate already-issued verification codes and is out of scope.

Note for JOY

The test-mode Stripe keys visible in the removed screenshot should still be rotated on the Stripe dashboard (deleting the file does not un-publish the account ID from git history).

🤖 Generated by ZCode

JOY added 2 commits September 17, 2026 18:22
An unset key silently encoded to a zero-length secret in signJwt and
the login getServerSideProps JWT verify (jose signs and verifies HS256
with a 0-byte key successfully), and degraded the email verification
seed to a pure function of the victim email in
verifyCodeUnAuthenticated (audit LO-04/LO-05). All three sites now
throw, matching the required-env pattern already used in
next.config.ts. Production containers already refuse to boot without
the key (scripts/start.sh), so only misconfigured local setups see the
new error.
…nt ID

The 590KB upstream-inherited screenshot of a Stripe test-mode API keys
page shipped partially legible key fragments and a fully visible
account ID (audit MD-30). Nothing references the file. The test-mode
keys shown should still be rotated on the Stripe dashboard.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: f9dc7603-8b7c-4e45-b4bd-15a0449b3faf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces explicit checks for the CALENDSO_ENCRYPTION_KEY environment variable across JWT verification, signing, and unauthenticated code verification to prevent security degradation or silent failures when the key is missing. The reviewer pointed out that in getServerSideProps.tsx, the check is placed inside a try-catch block, which would catch the thrown error and silently redirect the user instead of failing loudly as intended. It is recommended to move this check outside the try-catch block to properly surface the configuration issue.

const verifyJwt = (jwt: string) => {
// A missing key would encode to a zero-length secret, which jose happily
// verifies against - fail loudly instead (same pattern as next.config.ts).
if (!process.env.CALENDSO_ENCRYPTION_KEY) throw new Error("Please set CALENDSO_ENCRYPTION_KEY");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The check for CALENDSO_ENCRYPTION_KEY is placed inside verifyJwt, which is executed within a try-catch block inside getServerSideProps (lines 31-50). If the key is missing, the thrown error will be caught by the catch block and the user will be silently redirected to /auth/error?error=Invalid%20JWT%3A%20Please%20try%20again. This prevents the application from failing loudly as intended and masks a critical configuration issue as a user-facing authentication error.\n\nTo ensure the application fails loudly on misconfiguration, this check should be moved to the top of getServerSideProps (outside of the try-catch block).

@JOY
JOY (JOY) merged commit 8aaf7fa into dev Sep 17, 2026
11 checks passed
@JOY
JOY (JOY) deleted the fix/secrets-hygiene-md30-lo04-lo05 branch September 17, 2026 11:31
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.

1 participant