Skip to content

Commit 1ccaa1d

Browse files
ESS-ENNSakshis
authored andcommitted
Add YAML rules and tests for insecure JWT usage detection (#182)
* removed missing-secure-java * httponly-false-csharp * use-of-md5-digest-utils-java * removing use-of-md5-digest-utils and httponly-false-csharp * jwt-scala-hardcode-scala * jwt-go-none-algorithm-go * changing folder location for jwt-go-none-algorithm-go * jwt-hardcode-kotlin * scala-jwt-hardcoded-secret-scala --------- Co-authored-by: Sakshis <sakshil@abc.com>
1 parent f045379 commit 1ccaa1d

12 files changed

+1841
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
id: jwt-go-none-algorithm-go
2+
language: go
3+
severity: warning
4+
message: >-
5+
Detected use of the 'none' algorithm in a JWT token. The 'none'
6+
algorithm assumes the integrity of the token has already been verified.
7+
This would allow a malicious actor to forge a JWT token that will
8+
automatically be verified. Do not explicitly use the 'none' algorithm.
9+
Instead, use an algorithm such as 'HS256'.
10+
note: >-
11+
[CWE-327]: Use of a Broken or Risky Cryptographic Algorithm
12+
[OWASP A03:2017]: Sensitive Data Exposure
13+
[OWASP A02:2021]: Cryptographic Failures
14+
[REFERENCES]
15+
https://owasp.org/Top10/A02_2021-Cryptographic_Failures
16+
17+
ast-grep-essentials: true
18+
19+
utils:
20+
after_declaration:
21+
inside:
22+
stopBy: end
23+
follows:
24+
stopBy: end
25+
kind: import_declaration
26+
has:
27+
stopBy: end
28+
kind: import_spec
29+
has:
30+
kind: interpreted_string_literal
31+
has:
32+
kind: interpreted_string_literal_content
33+
regex: ^(github.com/dgrijalva/jwt-go|github.com/golang-jwt/jwt)$
34+
35+
rule:
36+
kind: selector_expression
37+
all:
38+
- pattern: $JWT_FUNC
39+
- matches: after_declaration
40+
41+
constraints:
42+
JWT_FUNC:
43+
regex: (jwt.SigningMethodNone|jwt.UnsafeAllowNoneSignatureType)

0 commit comments

Comments
 (0)