Skip to content

Add security rules for JWT verification and RSA key length validation #74

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 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
44 changes: 44 additions & 0 deletions rules/javascript/security/jwt-simple-noverify-javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
id: jwt-simple-noverify-javascript
language: JavaScript
severity: warning
message: >-
"Detected the decoding of a JWT token without a verify step. JWT tokens
must be verified before use, otherwise the token's integrity is unknown.
This means a malicious actor could forge a JWT token with any claims. Set
'verify' to `true` before using the token."
note: >-
[CWE-287] Improper Authentication
[CWE-345] Insufficient Verification of Data Authenticity
[CWE-347] Improper Verification of Cryptographic Signature
[REFERENCES]
- https://www.npmjs.com/package/jwt-simple
- https://cwe.mitre.org/data/definitions/287
- https://cwe.mitre.org/data/definitions/345
- https://cwe.mitre.org/data/definitions/347
rule:
kind: call_expression
any:
- pattern: $JWT.decode($TOKEN, $SECRET, true $$$)
- pattern: $JWT.decode($TOKEN, $SECRET, "$$$" $$$)
- pattern: $JWT.decode($TOKEN, $SECRET, '$$$' $$$)
- pattern: $JWT.decode($TOKEN, $SECRET, `$$$` $$$)
inside:
stopBy: end
follows:
stopBy: end
any:
- kind: lexical_declaration
all:
- has:
stopBy: end
kind: identifier
pattern: $JWT
- has:
stopBy: end
kind: call_expression
pattern: require('jwt-simple')
- kind: expression_statement
has:
stopBy: end
kind: assignment_expression
pattern: $JWT = require('jwt-simple')
Loading