From c054e6371f406cb03abcd2e08dc5b5017ae4e3ee Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 2 Nov 2026 20:26:45 -0500 Subject: [PATCH] fix: remove SMTP and Stripe secrets from tracked dev config (#236) ## What was wrong - `email-sender-job.development.env` committed a plaintext SMTP password for the Gmail sending account used by the email worker. - `storyteller-web.development.env` committed the Stripe test-mode secret key (`sk_test_...`) and webhook signing secret (`whsec_...`). Anyone with read access to the repository (or to a Docker build context or image built from it) gets these credentials. ## What changed - Removed `SMTP_PASSWORD`, `STRIPE_SECRET_KEY` and `STRIPE_SECRET_WEBHOOK_SIGNING_KEY` from the tracked development configs, with a comment pointing to the gitignored `.development-secrets.env` file. `bootstrap` already loads that file after `.development.env` (and dotenv keeps earlier values, so the lines had to be removed rather than replaced with placeholders). - Added `*-secrets.env` and `secrets/` to `.dockerignore` so local secret files never enter a build context. ## Required follow-up (cannot be done in code) - **Rotate the SMTP password** for the sending account and the **Stripe test secret key + webhook signing secret**. They remain in git history; removing them from `main` does not revoke them. - Developers running storyteller-web or email-sender-job locally must now put those three values in their `*.development-secrets.env` (or environment); startup fails with a missing-variable error otherwise, since both are read with `get_env_string_required`. ## Blast radius Development configuration only. Production config files are unchanged; production already supplies these from secrets. ## Checks - Run: reviewed bootstrap env-file load order (`crates/lib/bootstrap/src/bootstrap.rs`) to confirm the secrets file is still read in development. - Not run: no build needed (config-only change); no local startup test (needs the real secrets). Addresses CodeRabbit security findings (CWE-798). ## Summary by CodeRabbit * **Configuration** * Development settings no longer include hard-coded SMTP passwords or Stripe secret keys. These values can be provided through environment variables or local secrets files. * Files matching `*-secrets.env` and the `secrets/` directory are excluded from Docker build contexts. --- .dockerignore | 2 ++ .../config/email-sender-job.development.env | 4 ++-- .../storyteller_web/config/storyteller-web.development.env | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 0840ed1bd0..5a134643ad 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,8 @@ .dockerignore .env .env-secrets +*-secrets.env +secrets/ .git .idea/ Dockerfile diff --git a/crates/service/job/deprecated/email_sender_job/config/email-sender-job.development.env b/crates/service/job/deprecated/email_sender_job/config/email-sender-job.development.env index d16515eb90..027197c0db 100644 --- a/crates/service/job/deprecated/email_sender_job/config/email-sender-job.development.env +++ b/crates/service/job/deprecated/email_sender_job/config/email-sender-job.development.env @@ -1,10 +1,10 @@ # inference-job default .env configurations (these can be overridden with k8s) -# TODO(bt,2023-11-11): Password and account details should be a secret, but gotta go fast. SMTP_RELAY="smtp.gmail.com" # SMTP_USERNAME="noreply@storyteller.ai" SMTP_USERNAME="accounts@storyteller.ai" -SMTP_PASSWORD="FakeYouHanashi1" +# SMTP_PASSWORD is a secret. Set it in the untracked (gitignored) +# `email-sender-job.development-secrets.env` next to this file, or in the environment. # NB: To not step on storyteller-web (the main API gateway) HTTP_BIND_ADDRESS=0.0.0.0:11223 diff --git a/crates/service/web/storyteller_web/config/storyteller-web.development.env b/crates/service/web/storyteller_web/config/storyteller-web.development.env index e8b3318f5e..b18220249f 100644 --- a/crates/service/web/storyteller_web/config/storyteller-web.development.env +++ b/crates/service/web/storyteller_web/config/storyteller-web.development.env @@ -16,14 +16,14 @@ ENABLE_PAGING_FOR_500S=false AI_STREAMER_USERNAMES="PewDiePie,xQc" # Stripe configs -# All secrets are development and okay to check in +# STRIPE_SECRET_KEY and STRIPE_SECRET_WEBHOOK_SIGNING_KEY are secrets. Set them in the +# untracked (gitignored) `storyteller-web.development-secrets.env` next to this file, +# or in the environment. They must not be committed here. STRIPE_CHECKOUT_SUCCESS_URL_PATH=/checkout_success STRIPE_CHECKOUT_CANCEL_URL_PATH=/checkout_cancel STRIPE_PORTAL_RETURN_URL_PATH=/portal_success STRIPE_PORTAL_DEFAULT_CONFIG_ID=bpc_1LyPPREU5se17MekYiViZF12 STRIPE_PUBLISHABLE_KEY=pk_test_51KZvWXEU5se17Mekx6e0gw32ovDF78k2eeaGctLIs8oQVxN6DerEp1BDqh6gLMYKli4VsTZoVGHoxq5RmwKMlxtP00r59UEEad -STRIPE_SECRET_KEY=sk_test_51KZvWXEU5se17Mek11ZdnWr4frnyw7tWOPuvl3pRzL290zvkT6KqcbGUl3fcvc3hA8oH6lWXz2kGWXXUlNcCuDxB003uVT9JX0 -STRIPE_SECRET_WEBHOOK_SIGNING_KEY=whsec_40b60bd75768052532b63dbeefa7a1b163e182c3e657fb27fa906ef49a2cd59f # Development container NUM_WORKERS=16