Skip to content
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

[JS] - Enhancement to add jose decodeJWT to js/jwt-missing-verification #147

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions javascript/CWE-347/MissingJWTKeyVerification.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @name JWT missing secret or public key verification
* @description The application does not verify the JWT payload with a cryptographic secret or public key.
* @kind problem
* @problem.severity warning
* @security-severity 7.0
* @precision high
* @id js/jwt-missing-verification
* @tags security
* external/cwe/cwe-347
*/

import javascript
import DataFlow
import semmle.javascript.RestrictedLocations

from DataFlow::CallNode call, Node node, string msg
where
(call = DataFlow::moduleMember("jsonwebtoken", "verify").getACall() and
call.getArgument(1).analyze().getTheBooleanValue() = false
and node = call.getArgument(1)
and msg = "This argument disables the integrity enforcement of the token verification.")
or
(call = DataFlow::moduleMember("jose", "decodeJwt").getACall()
Copy link
Contributor Author

@felickz felickz May 19, 2023

Choose a reason for hiding this comment

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

Calling jose.decodeJwt method alone is not a fool proof detection as there is potential that the token is validated in another scenario ( jose.jwtVerify ). On that note should we consider dropping this into codeql repo or keep in this field pack?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Keep in Field for now. Have you checked this against MRVA to see what % FPs this leads to? If it's significant it can't be hard to add "and not jose.jwtVerify used", right?

and node = call
and msg = "This does not validate the JWS Signature..")
select node, msg