bug: load JWT signing secret from JWT_SECRET env var instead of hard-coding it - #1062
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
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); |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The HS512 key that signs and verifies every auth token was committed in
application.properties, so anyone with repo read access could forge a token for any user id andJwtTokenFilterwould authenticate it. The literal is removed; the key now comes only from the environment.application.properties:jwt.secret=${JWT_SECRET:}(no committed default).DefaultJwtService: newbuildSigningKey(secret, algorithm)Keys.secretKeyFor(HS512)(random per-process key) +log.warn, so a misconfigured deploy cannot fall back to a known key;IllegalStateException. This matters because jjwt's single-argsignWith(key)silently downgrades to HS256/HS384 for short keys; signing is also pinned viasignWith(signingKey, signatureAlgorithm).JWT_SECRET.Rotation required at source: the previously committed key must be treated as compromised and rotated in every environment that used it (owner: whoever operates the deployed instances). No git history rewrite was performed.
Not verified locally: Maven Central and the Gradle plugin portal are outside this environment's network allowlist, so
./gradlew compileJava testcannot resolve dependencies here, and the repo has no GitHub Actions CI.Devin session
Devin-Org: engineering