File tree 2 files changed +91
-0
lines changed
2 files changed +91
-0
lines changed Original file line number Diff line number Diff line change
1
+ id : use-of-aes-ecb-java
2
+ language : java
3
+ severity : warning
4
+ message : >-
5
+ Use of AES with ECB mode detected. ECB doesn't provide message
6
+ confidentiality and is not semantically secure so should not be used.
7
+ Instead, use a strong, secure cipher:
8
+ Cipher.getInstance(\"AES/CBC/PKCS7PADDING\"). See
9
+ https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions
10
+ for more information.
11
+ note : >-
12
+ [CWE-327]: Use of a Broken or Risky Cryptographic Algorithm
13
+ [OWASP A03:2017]: Sensitive Data Exposure
14
+ [OWASP A02:2021]: Cryptographic Failures
15
+ [REFERENCES]
16
+ - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
17
+ - https://googleprojectzero.blogspot.com/2022/10/rc4-is-still-considered-harmful.html
18
+
19
+ ast-grep-essentials : true
20
+
21
+ utils :
22
+ match_method_invocation :
23
+ kind : method_invocation
24
+ all :
25
+ - has :
26
+ kind : identifier
27
+ field : name
28
+ regex : " ^getInstance$"
29
+ nthChild : 2
30
+ - has :
31
+ kind : argument_list
32
+ has :
33
+ kind : string_literal
34
+ has :
35
+ kind : string_fragment
36
+ regex : " AES/ECB"
37
+ matches_method_invocation_with_identifier :
38
+ kind : method_invocation
39
+ all :
40
+ - has :
41
+ kind : identifier
42
+ field : name
43
+ regex : " ^getInstance$"
44
+ nthChild : 2
45
+ - has :
46
+ kind : argument_list
47
+ has :
48
+ kind : identifier
49
+ pattern : $I
50
+ inside :
51
+ stopBy : end
52
+ follows :
53
+ stopBy : end
54
+ any :
55
+ - kind : local_variable_declaration
56
+ - kind : field_declaration
57
+ all :
58
+ - has :
59
+ kind : type_identifier
60
+ field : type
61
+ - has :
62
+ kind : variable_declarator
63
+ all :
64
+ - has :
65
+ kind : identifier
66
+ field : name
67
+ pattern : $I
68
+ - has :
69
+ kind : string_literal
70
+ has :
71
+ kind : string_fragment
72
+
73
+ rule :
74
+ any :
75
+ - matches : match_method_invocation
76
+ - matches : matches_method_invocation_with_identifier
Original file line number Diff line number Diff line change
1
+ id : use-of-aes-ecb-java
2
+ valid :
3
+ - |
4
+ Cipher.getInstance("AES/CBC/PKCS7PADDING")
5
+ invalid :
6
+ - |
7
+ Cipher.getInstance("AES/ECB/NoPadding")
8
+ - |
9
+ Cipher.getInstance("AES/ECB/PKCS5Padding")
10
+ - |
11
+ Cipher.getInstance("AES/ECB/ISO10126Padding")
12
+ - |
13
+ Cipher.getInstance("AES/ECB/PKCS7Padding")
14
+ - |
15
+ Cipher.getInstance("AES/ECB")
You can’t perform that action at this time.
0 commit comments