-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[javascript] CWE-347: JWT Missing Secret Or Public Key Verification #3751
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
Conversation
Add an experimental CodeQL query.
Add a test file for CWE-347. The HS256 algorithm is safe, but the none algorithm is unsafe.
The status of the pull request is still in progress. |
- Add help documentation - Empty qll file - rename examples
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.
This is a very simple query, but it flags something important 👍
Your CodeQL is good for a first-time contributor 🎉 just a small comment there.
The documentation is mostly fine, but I got a few more comments for that.
(Documentation is hard, it also took me quite a while to learn).
Note: jwt.verify()
is not a function, it is a function call to the verify
function.
You don't have to accept the suggestions verbatim. Treat them as what they are: suggestions.
javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.help
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.help
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.help
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.ql
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.ql
Outdated
Show resolved
Hide resolved
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
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.
@erik-krogh Thank you for your feedback.
It was very insightful and valuable.
- add valuable text to assess the query results - add an example of the output
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.
Looks better now 👍
Great to see that you took my suggestions, and used them to write some documentation that is better than my suggestions 👍
We are getting close to merge, just a few more suggestions.
javascript/ql/src/experimental/Security/CWE-347/examples/results.txt
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.ql
Outdated
Show resolved
Hide resolved
javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.ql
Outdated
Show resolved
Hide resolved
…etOrPublicKeyVerification.ql Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
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.
@erik-krogh Thanks again for your guidance. 🙌
For now, the query is in the experimental folder.
What's the requirement to move in with other Security queries?
In the end it is the JavaScript team that decides what ends up as non-experimental JavaScript queries. Among others it requires an evaluation of results to evaluate true and false positives. One thing I usually do is find a bunch of projects on GitHub that are flagged by the query (GitHub.com/search is sometimes helpful for that), and I also check that there isn't a whole bunch of false positives (false positives should not be an issue for this query, but otherwise I often run the query using this query console with 200+ projects). I don't think you should worry about whether this particular query ends up in the non-experimental folder. |
A list of pertinent projects to run the query is exactly what I was looking for days. |
You don't need to spend too much time on it. (Right now I'm waiting for the CI to finish, then I'll hopefully take one last look at your code before I press |
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.
🎉
Could this contribution be eligible for the All For One program on HackerOne? |
If you find
and follow the instructions here i.e. open an additional issue using the All For One template, then this contribution should be eligible :) |
Hello, are we ready to merge? 😇 |
Outline
The featured CodeQL query warns using of none algorithm in verify() functions imported from jsonwebtoken package developed by the auth0 organization.
Details
JavaScript applications handling JWT could be affected by a well-known misconfiguration due to the misuse of the none algorithm.
Indeed, the jsonwebtoken package developed by the Auth0 company specifies that the none algorithm doesn't enforce digital signature and It's a feature. In that scenario, providing the value false instead of a secret or a key will decode the JWT without signature verification.
A secure coding framework requires auditable and automated security measures to ensure good practices in codebases.
By running the featured CodeQL query, you ensure that calling
verify()
functions always take a secret or a key to decode JWT payloads.Resource