Skip to content

Java: CWE-321 Query to detect hardcoded JWT secret keys #9036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 11, 2022

Conversation

luchua-bc
Copy link
Contributor

@luchua-bc luchua-bc commented May 4, 2022

JWT (JSON Web Token) is an open standard (RFC 7519) that defines a way to provide information within a JSON object between two parties. JWT is widely used for sharing security information between two parties in web applications. Each JWT contains encoded JSON objects, including a set of claims. JWTs are signed using a cryptographic algorithm to ensure that the claims cannot be altered after the token is issued.

The most basic mistake is using hardcoded secrets for JWT generation/verification. This allows an attacker to forge the token if the source code (and JWT secret in it) is publicly exposed or leaked, which leads to authentication bypass or privilege escalation.

Auth0 implementation of JWT is the de facto library used in Java applications. This query detects insecure usage of hardcoded JWT secret keys in both signing and verification.

Please consider to merge the PR. Thanks.

@luchua-bc luchua-bc force-pushed the java/hardcoded-jwt-key branch from 91a841c to 937ab41 Compare May 4, 2022 23:11
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Found 2 vulnerabilities.

Copy link
Contributor

@atorralba atorralba left a comment

Choose a reason for hiding this comment

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

Hey @luchua-bc, thanks for your contribution. I added some inline comments.

@luchua-bc
Copy link
Contributor Author

Thank @atorralba for reviewing this PR. I've made all requested changes. Please review again when you have a chance.

@atorralba atorralba merged commit 5be3020 into github:main May 11, 2022
@luchua-bc
Copy link
Contributor Author

Thank @smowton for reviewing and approving this PR.

@luchua-bc luchua-bc deleted the java/hardcoded-jwt-key branch May 11, 2022 15:38
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.

3 participants