Skip to content

fix(security): treat known dev JWT secrets as placeholders - #895

Merged
fclairamb merged 5 commits into
mainfrom
fix/security-jwt-dev-placeholder
Nov 16, 2026
Merged

fclairamb merged 5 commits into
mainfrom
fix/security-jwt-dev-placeholder

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

What

Fixes finding 4 of the security review #892 (known dev JWT secret passes the placeholder check).

ensureJWTSecret auto-generated a secret only when the configured value was empty or exactly change-me-in-production, and any non-empty SP_AUTH_JWT_SECRET short-circuited it. The repo's dev docker-compose.yml sets SP_AUTH_JWT_SECRET=dev-secret-change-in-production — a publicly-known constant that passed both guards. An operator copying the dev compose into production would run with a world-readable JWT signing key → session forgery for any account. (The published docs' production compose example omits the variable, so auto-generation covers that path — this closes the copy-the-dev-file path.)

Fix

  • New config.IsPlaceholderJWTSecret(secret): true for "", DefaultJWTSecret and the new DevJWTSecret constant. One predicate shared by every guard, so a future known-unsafe constant is refused everywhere at once.
  • ensureJWTSecret: a placeholder env value no longer short-circuits — it logs a warning and falls through to the stored secret, or generates and persists a real one. A real env secret still wins over everything (unchanged). The startup overlay always runs ensureJWTSecret right after applying env/DB, so the placeholder cannot survive boot.
  • ovhsmscb.ResolveToken uses the same predicate (never derive the DLR path token from a public constant).
  • docker-compose.yml gets a DEVELOPMENT ONLY header and an inline comment on the secret line.

Tests

  • config: TestIsPlaceholderJWTSecret (placeholders vs real secrets).
  • systemconfig: TestEnsureJWTSecretKnownPlaceholders — dev constant in config reloads from DB; placeholder env (both constants) does not short-circuit; with no stored secret a real one is generated. Existing TestEnsureJWTSecret (real env short-circuit) stays green.
  • ovhsmscb: TestResolveToken loop extended to the dev constant (trimmed variants included).

go test ./internal/config/ ./internal/systemconfig/ ./internal/handlers/ovhsmscb/ green, golangci-lint 0 issues on the touched packages, go build ./... OK, compose YAML validated.

Refs #892

ensureJWTSecret only refused the exact 'change-me-in-production' default,
and any non-empty SP_AUTH_JWT_SECRET short-circuited it. The repository's
dev docker-compose.yml ships 'dev-secret-change-in-production' — a
publicly-known constant that passed both guards, so copying the dev compose
into production yielded a world-readable JWT signing key (session forgery).

Add config.IsPlaceholderJWTSecret (empty + both known public constants) and
use it in ensureJWTSecret (env included: a placeholder env value now falls
through to the stored/generated secret with a warning) and in the OVH SMS
DLR token derivation. Label the dev compose file as development-only.

Refs #892 (finding 4)
@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.71%. Comparing base (a2e2cd1) to head (42083ee).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #895      +/-   ##
==========================================
- Coverage   90.74%   90.71%   -0.04%     
==========================================
  Files        1370     1370              
  Lines      140857   140915      +58     
==========================================
+ Hits       127821   127825       +4     
- Misses      13027    13081      +54     
  Partials        9        9              
Files with missing lines Coverage Δ
server/internal/config/discord_oauth.go 100.00% <100.00%> (ø)
server/internal/handlers/ovhsmscb/handler.go 100.00% <100.00%> (ø)
server/internal/systemconfig/systemconfig.go 96.34% <100.00%> (+0.03%) ⬆️

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fclairamb
fclairamb merged commit 1cad98a into main Nov 16, 2026
38 checks passed
@fclairamb
fclairamb deleted the fix/security-jwt-dev-placeholder branch November 16, 2026 01:30
fclairamb added a commit that referenced this pull request Nov 16, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.51.0](v0.50.2...v0.51.0)
(2026-11-16)


### Features

* Pingdom check importer, insights period selector, job retry log levels
([#904](#904))
([7914164](7914164))


### Bug Fixes

* **security:** bound status page historyDays, mask config tokens in
replay, JS websocket redirect policy, docs JWT placeholders
([#903](#903))
([6b432e0](6b432e0))
* **security:** cap the pre-auth body buffer in ServiceSignature
([#894](#894))
([c4da4c5](c4da4c5)),
closes [#892](#892)
* **security:** cross-check SAML NameID namespace (GO-2026-6909)
([#896](#896))
([df0d7b6](df0d7b6))
* **security:** treat known dev JWT secrets as placeholders
([#895](#895))
([1cad98a](1cad98a)),
closes [#892](#892)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant