GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java: CWE-321 Query to detect hardcoded JWT secret keys by luchua-bc · Pull Request #9036 · github/codeql

Conversation

@luchua-bc

@luchua-bc luchua-bc commented May 4, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

felickz reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@luchua-bc
luchua-bc requested a review from a team as a code owner May 4, 2022 22:53
@github-actions github-actions Bot added documentation Java labels May 4, 2022
@luchua-bc luchua-bc mentioned this pull request May 4, 2022
[Java]: CWE-321 - Query to detect hardcoded JWT secret keys github/securitylab#670
Closed
1 of 2 tasks
@luchua-bc
Query to detect hardcoded JWT secret keys
937ab41
@luchua-bc
luchua-bc force-pushed the java/hardcoded-jwt-key branch from 91a841c to 937ab41 Compare May 4, 2022 23:11
ghost
ghost reviewed May 4, 2022
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

github-advanced-security[bot]
github-advanced-security AI found potential problems May 9, 2022
View reviewed changes

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

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Found 2 vulnerabilities.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Fixed

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Fixed

Uh oh!

There was an error while loading. Please reload this page.

atorralba
atorralba reviewed May 9, 2022
View reviewed changes

@atorralba atorralba left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Fixed

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
Standardize the query and update qldoc
75e7148
@luchua-bc

luchua-bc commented May 9, 2022

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

atorralba
atorralba reviewed May 11, 2022
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-321/HardcodedJwtKey.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

luchua-bc and others added 2 commits May 11, 2022 10:37
@luchua-bc
Correct string source
f85c01c
@smowton
Remove URL fragment from Google search
f7e1f3e
smowton
smowton approved these changes May 11, 2022
View reviewed changes
@atorralba
atorralba merged commit 5be3020 into github:main May 11, 2022
@luchua-bc

luchua-bc commented May 11, 2022

Copy link
Copy Markdown
Contributor Author

Thank @smowton for reviewing and approving this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
luchua-bc deleted the java/hardcoded-jwt-key branch May 11, 2022 15:38
@egregius313 egregius313 mentioned this pull request Feb 17, 2023
Java: Promote Hardcoded JWT credential query #12032
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

3 more reviewers
@atorralba atorralba atorralba left review comments
@smowton smowton smowton approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

documentation Java

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@luchua-bc @smowton @atorralba @github-advanced-security
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.