Skip to content

fix(auth): refuse placeholder JWT signing secrets at startup - #587

Open
walsykerem wants to merge 2 commits into
kernel:mainfrom
walsykerem:default-jwt-secret-problem
Open

walsykerem wants to merge 2 commits into
kernel:mainfrom
walsykerem:default-jwt-secret-problem

Conversation

@walsykerem

@walsykerem walsykerem commented Nov 21, 2026 •

Copy link
Copy Markdown

Published JWT secret accepted at startup

Hypeman's macOS example config ships jwt_secret: dev-secret-change-me, and the matching environment example repeats the same value. The loader only checked that the secret was not empty, so a server started from the documented copy path signed every token with a key printed in the repository. Anyone could mint an admin token.

The fix adds a short list of published placeholders to the JWT verifier, exposed as IsWeakSecret, and checks it when configuration loads. A placeholder now stops startup with a clear message asking for a unique random value. An empty secret stays handled by the existing server check, so nothing else moves.

Strong secrets keep working: a 64 character hex value from openssl rand -hex 32, the exact form scripts/install.sh generates, is accepted, and JWT_SECRET still overrides the file.

Two files changed, lib/jwtauth/verifier.go and cmd/api/config/config.go. The reproduction test fails on the original tree and passes after the change. Package tests, go vet, the build, and a container run of the test are green.


Note

Medium Risk
Tightens authentication configuration validation and will refuse to start (or build a verifier) when secrets match documented placeholders; legitimate strong secrets are unchanged.

Overview
Blocks startup when JWT signing or verification keys are empty or match a fixed list of published example placeholders (e.g. dev-secret-change-me, secret, change-me), exposed as jwtauth.IsWeakSecret.

Load now rejects a non-empty weak jwt_secret with guidance to generate a real secret. Config.Validate and NewVerifier use the same check for jwt_verification_secrets, since fallback keys are tried on every token and would be forgeable if they matched repo examples. Tests cover placeholder rejection, strong secrets, and error messages that avoid echoing secret values.

Reviewed by Cursor Bugbot for commit d451d9d. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 486ce0f. Configure here.

Comment thread lib/jwtauth/verifier.go Resolved
Verification-only keys were only rejected when empty, so a placeholder
copied from the example configs stayed trusted for every token and let
anyone who read the repository mint tokens the API accepts.

Both config validation and the verifier now reject empty or published
values for verification entries, reusing the existing helper.

This branch has not been deployed

No deployments
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