Skip to content

bug: remove hardcoded JWT signing secret, load from JWT_SECRET env - #1063

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1788253616-jwt-secret-env-sfind497b
Open

devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1788253616-jwt-secret-env-sfind497b

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 1, 2026

Copy link
Copy Markdown

Remove hardcoded JWT signing secret (load from JWT_SECRET env var)

Summary

Fixes code scan finding sfind-497b4c6e962a40a1ae0ac1597d478ae8: the HS512 JWT signing secret was committed in application.properties, letting anyone with repo read access forge valid tokens for any user id (accepted by JwtTokenFilter).

  • application.properties: jwt.secret=${JWT_SECRET:} — no committed default.
  • DefaultJwtService: if the secret is empty, generates a random per-process key (with a warning); otherwise enforces ≥64 bytes for HS512. signWith pins HS512 explicitly.
  • README documents setting JWT_SECRET (e.g. openssl rand -base64 64).
  • Tests: rejects tokens signed with a different secret, rejects too-short secrets, random-key mode works per process.

Rotation required: the leaked value in git history must be considered compromised; deployments must set a fresh JWT_SECRET (owner: repo maintainers). No history rewrite performed.

Note: this duplicates the fix already open in PR #1010/#1062 (same root cause, separate finding); whichever merges first, the others can be closed.

Verification

Local Gradle build is not possible in this environment (Maven Central/plugin portal blocked); repo has no CI. The change mirrors the previously reviewed patch applied cleanly on latest master.

This PR was written by Devin.

Devin-Org: engineering


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Devin Review

Comment on lines +39 to +45
if (secret == null || secret.trim().isEmpty()) {
log.warn(
"No JWT signing secret configured (set the JWT_SECRET environment variable to at least "
+ "{} bytes). Generating a random key: tokens will be invalidated on every restart "
+ "and will not be accepted by other instances.",
MINIMUM_SECRET_BYTES);
return Keys.secretKeyFor(algorithm);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🟨 Missing secret enables unstable authentication

Without JWT_SECRET, buildSigningKey silently creates a process-local key. Restarts invalidate every session, and replicas reject each other's tokens.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

0 participants