agent-security-scanner-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -0
- package/analyzer.py +119 -0
- package/index.js +269 -0
- package/package.json +48 -0
- package/rules/__init__.py +167 -0
- package/rules/dockerfile.security.yaml +291 -0
- package/rules/generic.secrets.yaml +503 -0
- package/rules/go.security.yaml +380 -0
- package/rules/java.security.yaml +453 -0
- package/rules/javascript.security.yaml +504 -0
- package/rules/python.security.yaml +602 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
rules:
|
|
2
|
+
# ============================================================================
|
|
3
|
+
# SQL INJECTION
|
|
4
|
+
# ============================================================================
|
|
5
|
+
- id: java.lang.security.audit.sqli.sql-injection-jdbc
|
|
6
|
+
languages: [java]
|
|
7
|
+
severity: ERROR
|
|
8
|
+
message: "Possible SQL injection via string concatenation. Use PreparedStatement with parameterized queries."
|
|
9
|
+
patterns:
|
|
10
|
+
- "executeQuery\\s*\\([^)]*\\+"
|
|
11
|
+
- "executeUpdate\\s*\\([^)]*\\+"
|
|
12
|
+
- "execute\\s*\\([^)]*\\+"
|
|
13
|
+
- "createStatement\\s*\\(\\s*\\)\\.execute"
|
|
14
|
+
- "\"SELECT.*\"\\s*\\+\\s*"
|
|
15
|
+
- "\"INSERT.*\"\\s*\\+\\s*"
|
|
16
|
+
- "\"UPDATE.*\"\\s*\\+\\s*"
|
|
17
|
+
- "\"DELETE.*\"\\s*\\+\\s*"
|
|
18
|
+
metadata:
|
|
19
|
+
cwe: "CWE-89"
|
|
20
|
+
owasp: "A03:2021 - Injection"
|
|
21
|
+
confidence: HIGH
|
|
22
|
+
references:
|
|
23
|
+
- https://semgrep.dev/r/java.lang.security.audit.sqli.sql-injection-jdbc
|
|
24
|
+
|
|
25
|
+
- id: java.lang.security.audit.sqli.sql-injection-hibernate
|
|
26
|
+
languages: [java]
|
|
27
|
+
severity: ERROR
|
|
28
|
+
message: "Possible SQL injection in Hibernate query. Use parameterized queries."
|
|
29
|
+
patterns:
|
|
30
|
+
- "createQuery\\s*\\([^)]*\\+"
|
|
31
|
+
- "createNativeQuery\\s*\\([^)]*\\+"
|
|
32
|
+
- "createSQLQuery\\s*\\([^)]*\\+"
|
|
33
|
+
metadata:
|
|
34
|
+
cwe: "CWE-89"
|
|
35
|
+
owasp: "A03:2021 - Injection"
|
|
36
|
+
confidence: HIGH
|
|
37
|
+
references:
|
|
38
|
+
- https://semgrep.dev/r/java.lang.security.audit.sqli.sql-injection-hibernate
|
|
39
|
+
|
|
40
|
+
# ============================================================================
|
|
41
|
+
# COMMAND INJECTION
|
|
42
|
+
# ============================================================================
|
|
43
|
+
- id: java.lang.security.audit.command-injection-runtime-exec
|
|
44
|
+
languages: [java]
|
|
45
|
+
severity: ERROR
|
|
46
|
+
message: "Possible command injection via Runtime.exec(). Validate and sanitize input."
|
|
47
|
+
patterns:
|
|
48
|
+
- "Runtime\\.getRuntime\\s*\\(\\s*\\)\\.exec\\s*\\([^)]*\\+"
|
|
49
|
+
- "Runtime\\.getRuntime\\s*\\(\\s*\\)\\.exec\\s*\\(\\s*[^\\\"\\)]*\\)"
|
|
50
|
+
metadata:
|
|
51
|
+
cwe: "CWE-78"
|
|
52
|
+
owasp: "A03:2021 - Injection"
|
|
53
|
+
confidence: HIGH
|
|
54
|
+
references:
|
|
55
|
+
- https://semgrep.dev/r/java.lang.security.audit.command-injection-runtime-exec
|
|
56
|
+
|
|
57
|
+
- id: java.lang.security.audit.command-injection-process-builder
|
|
58
|
+
languages: [java]
|
|
59
|
+
severity: ERROR
|
|
60
|
+
message: "Possible command injection via ProcessBuilder. Validate and sanitize input."
|
|
61
|
+
patterns:
|
|
62
|
+
- "new\\s+ProcessBuilder\\s*\\([^)]*\\+"
|
|
63
|
+
- "ProcessBuilder\\s*\\(\\s*[^\\\"\\)]*\\)"
|
|
64
|
+
metadata:
|
|
65
|
+
cwe: "CWE-78"
|
|
66
|
+
owasp: "A03:2021 - Injection"
|
|
67
|
+
confidence: HIGH
|
|
68
|
+
references:
|
|
69
|
+
- https://semgrep.dev/r/java.lang.security.audit.command-injection-process-builder
|
|
70
|
+
|
|
71
|
+
# ============================================================================
|
|
72
|
+
# XXE (XML EXTERNAL ENTITY)
|
|
73
|
+
# ============================================================================
|
|
74
|
+
- id: java.lang.security.xxe.xxe-saxparser
|
|
75
|
+
languages: [java]
|
|
76
|
+
severity: ERROR
|
|
77
|
+
message: "XMLParser may be vulnerable to XXE. Disable external entities."
|
|
78
|
+
patterns:
|
|
79
|
+
- "SAXParserFactory\\.newInstance\\s*\\("
|
|
80
|
+
- "XMLReaderFactory\\.createXMLReader\\s*\\("
|
|
81
|
+
- "DocumentBuilderFactory\\.newInstance\\s*\\("
|
|
82
|
+
metadata:
|
|
83
|
+
cwe: "CWE-611"
|
|
84
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
85
|
+
confidence: MEDIUM
|
|
86
|
+
references:
|
|
87
|
+
- https://semgrep.dev/r/java.lang.security.xxe.xxe-saxparser
|
|
88
|
+
|
|
89
|
+
- id: java.lang.security.xxe.xxe-xmlinputfactory
|
|
90
|
+
languages: [java]
|
|
91
|
+
severity: ERROR
|
|
92
|
+
message: "XMLInputFactory may be vulnerable to XXE. Set IS_SUPPORTING_EXTERNAL_ENTITIES to false."
|
|
93
|
+
patterns:
|
|
94
|
+
- "XMLInputFactory\\.newInstance\\s*\\("
|
|
95
|
+
- "XMLInputFactory\\.newFactory\\s*\\("
|
|
96
|
+
metadata:
|
|
97
|
+
cwe: "CWE-611"
|
|
98
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
99
|
+
confidence: MEDIUM
|
|
100
|
+
references:
|
|
101
|
+
- https://semgrep.dev/r/java.lang.security.xxe.xxe-xmlinputfactory
|
|
102
|
+
|
|
103
|
+
# ============================================================================
|
|
104
|
+
# DESERIALIZATION
|
|
105
|
+
# ============================================================================
|
|
106
|
+
- id: java.lang.security.deserialization.object-inputstream
|
|
107
|
+
languages: [java]
|
|
108
|
+
severity: ERROR
|
|
109
|
+
message: "ObjectInputStream.readObject() is vulnerable to deserialization attacks. Validate input or use safer alternatives."
|
|
110
|
+
patterns:
|
|
111
|
+
- "\\.readObject\\s*\\(\\s*\\)"
|
|
112
|
+
- "ObjectInputStream"
|
|
113
|
+
- "new\\s+ObjectInputStream\\s*\\("
|
|
114
|
+
metadata:
|
|
115
|
+
cwe: "CWE-502"
|
|
116
|
+
owasp: "A08:2021 - Software and Data Integrity Failures"
|
|
117
|
+
confidence: HIGH
|
|
118
|
+
references:
|
|
119
|
+
- https://semgrep.dev/r/java.lang.security.deserialization.object-inputstream
|
|
120
|
+
|
|
121
|
+
- id: java.lang.security.deserialization.xstream
|
|
122
|
+
languages: [java]
|
|
123
|
+
severity: ERROR
|
|
124
|
+
message: "XStream deserialization is vulnerable to RCE. Use XStream security framework."
|
|
125
|
+
patterns:
|
|
126
|
+
- "XStream\\s*\\(\\s*\\)"
|
|
127
|
+
- "xstream\\.fromXML\\s*\\("
|
|
128
|
+
metadata:
|
|
129
|
+
cwe: "CWE-502"
|
|
130
|
+
owasp: "A08:2021 - Software and Data Integrity Failures"
|
|
131
|
+
confidence: HIGH
|
|
132
|
+
references:
|
|
133
|
+
- https://semgrep.dev/r/java.lang.security.deserialization.xstream
|
|
134
|
+
|
|
135
|
+
# ============================================================================
|
|
136
|
+
# CRYPTOGRAPHY
|
|
137
|
+
# ============================================================================
|
|
138
|
+
- id: java.lang.security.crypto.weak-hash-md5
|
|
139
|
+
languages: [java]
|
|
140
|
+
severity: WARNING
|
|
141
|
+
message: "MD5 is cryptographically weak. Use SHA-256 or stronger."
|
|
142
|
+
patterns:
|
|
143
|
+
- "MessageDigest\\.getInstance\\s*\\(\\s*\"MD5\"\\s*\\)"
|
|
144
|
+
- "DigestUtils\\.md5"
|
|
145
|
+
metadata:
|
|
146
|
+
cwe: "CWE-328"
|
|
147
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
148
|
+
confidence: HIGH
|
|
149
|
+
references:
|
|
150
|
+
- https://semgrep.dev/r/java.lang.security.audit.weak-hash-md5
|
|
151
|
+
|
|
152
|
+
- id: java.lang.security.crypto.weak-hash-sha1
|
|
153
|
+
languages: [java]
|
|
154
|
+
severity: WARNING
|
|
155
|
+
message: "SHA-1 is cryptographically weak. Use SHA-256 or stronger."
|
|
156
|
+
patterns:
|
|
157
|
+
- "MessageDigest\\.getInstance\\s*\\(\\s*\"SHA-1\"\\s*\\)"
|
|
158
|
+
- "MessageDigest\\.getInstance\\s*\\(\\s*\"SHA1\"\\s*\\)"
|
|
159
|
+
- "DigestUtils\\.sha1"
|
|
160
|
+
metadata:
|
|
161
|
+
cwe: "CWE-328"
|
|
162
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
163
|
+
confidence: HIGH
|
|
164
|
+
references:
|
|
165
|
+
- https://semgrep.dev/r/java.lang.security.audit.weak-hash-sha1
|
|
166
|
+
|
|
167
|
+
- id: java.lang.security.crypto.weak-cipher-des
|
|
168
|
+
languages: [java]
|
|
169
|
+
severity: ERROR
|
|
170
|
+
message: "DES is insecure. Use AES with 256-bit keys."
|
|
171
|
+
patterns:
|
|
172
|
+
- "Cipher\\.getInstance\\s*\\(\\s*\"DES"
|
|
173
|
+
- "Cipher\\.getInstance\\s*\\(\\s*\"DESede"
|
|
174
|
+
- "DESKeySpec"
|
|
175
|
+
metadata:
|
|
176
|
+
cwe: "CWE-327"
|
|
177
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
178
|
+
confidence: HIGH
|
|
179
|
+
references:
|
|
180
|
+
- https://semgrep.dev/r/java.lang.security.audit.weak-cipher-des
|
|
181
|
+
|
|
182
|
+
- id: java.lang.security.crypto.ecb-mode
|
|
183
|
+
languages: [java]
|
|
184
|
+
severity: ERROR
|
|
185
|
+
message: "ECB mode is insecure. Use CBC or GCM mode with proper IV."
|
|
186
|
+
patterns:
|
|
187
|
+
- "Cipher\\.getInstance\\s*\\(\\s*\"[^\"]+/ECB/"
|
|
188
|
+
- "AES/ECB/"
|
|
189
|
+
metadata:
|
|
190
|
+
cwe: "CWE-327"
|
|
191
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
192
|
+
confidence: HIGH
|
|
193
|
+
references:
|
|
194
|
+
- https://semgrep.dev/r/java.lang.security.audit.ecb-mode
|
|
195
|
+
|
|
196
|
+
- id: java.lang.security.crypto.insecure-random
|
|
197
|
+
languages: [java]
|
|
198
|
+
severity: WARNING
|
|
199
|
+
message: "java.util.Random is not cryptographically secure. Use SecureRandom."
|
|
200
|
+
patterns:
|
|
201
|
+
- "new\\s+Random\\s*\\("
|
|
202
|
+
- "java\\.util\\.Random"
|
|
203
|
+
metadata:
|
|
204
|
+
cwe: "CWE-330"
|
|
205
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
206
|
+
confidence: MEDIUM
|
|
207
|
+
references:
|
|
208
|
+
- https://semgrep.dev/r/java.lang.security.audit.insecure-random
|
|
209
|
+
|
|
210
|
+
# ============================================================================
|
|
211
|
+
# PATH TRAVERSAL
|
|
212
|
+
# ============================================================================
|
|
213
|
+
- id: java.lang.security.audit.path-traversal-file
|
|
214
|
+
languages: [java]
|
|
215
|
+
severity: WARNING
|
|
216
|
+
message: "Possible path traversal vulnerability. Validate and sanitize file paths."
|
|
217
|
+
patterns:
|
|
218
|
+
- "new\\s+File\\s*\\([^)]*\\+"
|
|
219
|
+
- "new\\s+FileInputStream\\s*\\([^)]*\\+"
|
|
220
|
+
- "new\\s+FileOutputStream\\s*\\([^)]*\\+"
|
|
221
|
+
- "new\\s+FileReader\\s*\\([^)]*\\+"
|
|
222
|
+
- "new\\s+FileWriter\\s*\\([^)]*\\+"
|
|
223
|
+
- "Paths\\.get\\s*\\([^)]*\\+"
|
|
224
|
+
metadata:
|
|
225
|
+
cwe: "CWE-22"
|
|
226
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
227
|
+
confidence: MEDIUM
|
|
228
|
+
references:
|
|
229
|
+
- https://semgrep.dev/r/java.lang.security.audit.path-traversal-file
|
|
230
|
+
|
|
231
|
+
# ============================================================================
|
|
232
|
+
# SSRF
|
|
233
|
+
# ============================================================================
|
|
234
|
+
- id: java.lang.security.audit.ssrf-url
|
|
235
|
+
languages: [java]
|
|
236
|
+
severity: WARNING
|
|
237
|
+
message: "Possible SSRF vulnerability. Validate and whitelist URLs."
|
|
238
|
+
patterns:
|
|
239
|
+
- "new\\s+URL\\s*\\([^)]*\\+"
|
|
240
|
+
- "new\\s+URI\\s*\\([^)]*\\+"
|
|
241
|
+
- "HttpClient.*\\.send\\s*\\("
|
|
242
|
+
- "HttpURLConnection"
|
|
243
|
+
metadata:
|
|
244
|
+
cwe: "CWE-918"
|
|
245
|
+
owasp: "A10:2021 - Server-Side Request Forgery"
|
|
246
|
+
confidence: MEDIUM
|
|
247
|
+
references:
|
|
248
|
+
- https://semgrep.dev/r/java.lang.security.audit.ssrf-url
|
|
249
|
+
|
|
250
|
+
# ============================================================================
|
|
251
|
+
# LDAP INJECTION
|
|
252
|
+
# ============================================================================
|
|
253
|
+
- id: java.lang.security.audit.ldap-injection
|
|
254
|
+
languages: [java]
|
|
255
|
+
severity: ERROR
|
|
256
|
+
message: "Possible LDAP injection. Sanitize user input in LDAP queries."
|
|
257
|
+
patterns:
|
|
258
|
+
- "search\\s*\\([^)]*\\+"
|
|
259
|
+
- "NamingEnumeration"
|
|
260
|
+
- "DirContext\\.search\\s*\\("
|
|
261
|
+
metadata:
|
|
262
|
+
cwe: "CWE-90"
|
|
263
|
+
owasp: "A03:2021 - Injection"
|
|
264
|
+
confidence: MEDIUM
|
|
265
|
+
references:
|
|
266
|
+
- https://semgrep.dev/r/java.lang.security.audit.ldap-injection
|
|
267
|
+
|
|
268
|
+
# ============================================================================
|
|
269
|
+
# XPATH INJECTION
|
|
270
|
+
# ============================================================================
|
|
271
|
+
- id: java.lang.security.audit.xpath-injection
|
|
272
|
+
languages: [java]
|
|
273
|
+
severity: ERROR
|
|
274
|
+
message: "Possible XPath injection. Use parameterized XPath queries."
|
|
275
|
+
patterns:
|
|
276
|
+
- "XPath\\.compile\\s*\\([^)]*\\+"
|
|
277
|
+
- "xpath\\.evaluate\\s*\\([^)]*\\+"
|
|
278
|
+
metadata:
|
|
279
|
+
cwe: "CWE-643"
|
|
280
|
+
owasp: "A03:2021 - Injection"
|
|
281
|
+
confidence: MEDIUM
|
|
282
|
+
references:
|
|
283
|
+
- https://semgrep.dev/r/java.lang.security.audit.xpath-injection
|
|
284
|
+
|
|
285
|
+
# ============================================================================
|
|
286
|
+
# SSL/TLS
|
|
287
|
+
# ============================================================================
|
|
288
|
+
- id: java.lang.security.ssl.trust-all-certificates
|
|
289
|
+
languages: [java]
|
|
290
|
+
severity: ERROR
|
|
291
|
+
message: "Trust manager accepts all certificates. This allows MITM attacks."
|
|
292
|
+
patterns:
|
|
293
|
+
- "TrustAllCertificates"
|
|
294
|
+
- "X509TrustManager"
|
|
295
|
+
- "checkClientTrusted\\s*\\([^)]*\\)\\s*\\{\\s*\\}"
|
|
296
|
+
- "checkServerTrusted\\s*\\([^)]*\\)\\s*\\{\\s*\\}"
|
|
297
|
+
- "ALLOW_ALL_HOSTNAME_VERIFIER"
|
|
298
|
+
- "setHostnameVerifier\\s*\\(\\s*SSLSocketFactory\\.ALLOW_ALL"
|
|
299
|
+
metadata:
|
|
300
|
+
cwe: "CWE-295"
|
|
301
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
302
|
+
confidence: HIGH
|
|
303
|
+
references:
|
|
304
|
+
- https://semgrep.dev/r/java.lang.security.audit.ssl-trust-all-certificates
|
|
305
|
+
|
|
306
|
+
# ============================================================================
|
|
307
|
+
# HARDCODED SECRETS
|
|
308
|
+
# ============================================================================
|
|
309
|
+
- id: java.lang.security.audit.hardcoded-password
|
|
310
|
+
languages: [java]
|
|
311
|
+
severity: ERROR
|
|
312
|
+
message: "Hardcoded password detected. Use environment variables or a secrets manager."
|
|
313
|
+
patterns:
|
|
314
|
+
- "password\\s*=\\s*\"[^\"]{4,}\""
|
|
315
|
+
- "passwd\\s*=\\s*\"[^\"]{4,}\""
|
|
316
|
+
- "setPassword\\s*\\(\\s*\"[^\"]{4,}\"\\s*\\)"
|
|
317
|
+
metadata:
|
|
318
|
+
cwe: "CWE-798"
|
|
319
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
320
|
+
confidence: HIGH
|
|
321
|
+
references:
|
|
322
|
+
- https://semgrep.dev/r/java.lang.security.audit.hardcoded-password
|
|
323
|
+
|
|
324
|
+
- id: java.lang.security.audit.hardcoded-secret-key
|
|
325
|
+
languages: [java]
|
|
326
|
+
severity: ERROR
|
|
327
|
+
message: "Hardcoded secret key detected. Use environment variables."
|
|
328
|
+
patterns:
|
|
329
|
+
- "secretKey\\s*=\\s*\"[^\"]{8,}\""
|
|
330
|
+
- "apiKey\\s*=\\s*\"[^\"]{8,}\""
|
|
331
|
+
- "SecretKeySpec\\s*\\(\\s*\"[^\"]+\"\\.getBytes"
|
|
332
|
+
metadata:
|
|
333
|
+
cwe: "CWE-798"
|
|
334
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
335
|
+
confidence: HIGH
|
|
336
|
+
references:
|
|
337
|
+
- https://semgrep.dev/r/java.lang.security.audit.hardcoded-secret-key
|
|
338
|
+
|
|
339
|
+
# ============================================================================
|
|
340
|
+
# SPRING SECURITY
|
|
341
|
+
# ============================================================================
|
|
342
|
+
- id: java.spring.security.csrf-disabled
|
|
343
|
+
languages: [java]
|
|
344
|
+
severity: WARNING
|
|
345
|
+
message: "CSRF protection is disabled. Enable unless using stateless API."
|
|
346
|
+
patterns:
|
|
347
|
+
- "\\.csrf\\s*\\(\\s*\\)\\.disable\\s*\\("
|
|
348
|
+
- "csrf\\.disable\\s*\\("
|
|
349
|
+
metadata:
|
|
350
|
+
cwe: "CWE-352"
|
|
351
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
352
|
+
confidence: HIGH
|
|
353
|
+
references:
|
|
354
|
+
- https://semgrep.dev/r/java.spring.security.audit.csrf-disabled
|
|
355
|
+
|
|
356
|
+
- id: java.spring.security.permit-all
|
|
357
|
+
languages: [java]
|
|
358
|
+
severity: WARNING
|
|
359
|
+
message: "permitAll() allows unauthenticated access. Ensure this is intentional."
|
|
360
|
+
patterns:
|
|
361
|
+
- "\\.permitAll\\s*\\(\\s*\\)"
|
|
362
|
+
metadata:
|
|
363
|
+
cwe: "CWE-284"
|
|
364
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
365
|
+
confidence: LOW
|
|
366
|
+
references:
|
|
367
|
+
- https://semgrep.dev/r/java.spring.security.audit.permit-all
|
|
368
|
+
|
|
369
|
+
# ============================================================================
|
|
370
|
+
# LOGGING SENSITIVE DATA
|
|
371
|
+
# ============================================================================
|
|
372
|
+
- id: java.lang.security.audit.logging-sensitive-data
|
|
373
|
+
languages: [java]
|
|
374
|
+
severity: WARNING
|
|
375
|
+
message: "Possible sensitive data in log statement. Avoid logging passwords or secrets."
|
|
376
|
+
patterns:
|
|
377
|
+
- "log\\.(info|debug|warn|error|trace)\\s*\\([^)]*password"
|
|
378
|
+
- "log\\.(info|debug|warn|error|trace)\\s*\\([^)]*secret"
|
|
379
|
+
- "log\\.(info|debug|warn|error|trace)\\s*\\([^)]*token"
|
|
380
|
+
- "logger\\.(info|debug|warn|error|trace)\\s*\\([^)]*password"
|
|
381
|
+
- "System\\.out\\.print.*password"
|
|
382
|
+
metadata:
|
|
383
|
+
cwe: "CWE-532"
|
|
384
|
+
owasp: "A09:2021 - Security Logging and Monitoring Failures"
|
|
385
|
+
confidence: MEDIUM
|
|
386
|
+
references:
|
|
387
|
+
- https://semgrep.dev/r/java.lang.security.audit.logging-sensitive-data
|
|
388
|
+
|
|
389
|
+
# ============================================================================
|
|
390
|
+
# EXPRESSION LANGUAGE INJECTION (SPRING)
|
|
391
|
+
# ============================================================================
|
|
392
|
+
- id: java.spring.security.spel-injection
|
|
393
|
+
languages: [java]
|
|
394
|
+
severity: ERROR
|
|
395
|
+
message: "Possible SpEL injection. Avoid using user input in SpEL expressions."
|
|
396
|
+
patterns:
|
|
397
|
+
- "ExpressionParser.*parseExpression\\s*\\([^)]*\\+"
|
|
398
|
+
- "SpelExpressionParser"
|
|
399
|
+
- "@Value\\s*\\(\\s*\"#\\{"
|
|
400
|
+
metadata:
|
|
401
|
+
cwe: "CWE-917"
|
|
402
|
+
owasp: "A03:2021 - Injection"
|
|
403
|
+
confidence: MEDIUM
|
|
404
|
+
references:
|
|
405
|
+
- https://semgrep.dev/r/java.spring.security.audit.spel-injection
|
|
406
|
+
|
|
407
|
+
# ============================================================================
|
|
408
|
+
# OPEN REDIRECT
|
|
409
|
+
# ============================================================================
|
|
410
|
+
- id: java.lang.security.audit.open-redirect
|
|
411
|
+
languages: [java]
|
|
412
|
+
severity: WARNING
|
|
413
|
+
message: "Possible open redirect vulnerability. Validate redirect URLs."
|
|
414
|
+
patterns:
|
|
415
|
+
- "sendRedirect\\s*\\([^)]*\\+"
|
|
416
|
+
- "setHeader\\s*\\(\\s*\"Location\"\\s*,[^)]*\\+"
|
|
417
|
+
metadata:
|
|
418
|
+
cwe: "CWE-601"
|
|
419
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
420
|
+
confidence: MEDIUM
|
|
421
|
+
references:
|
|
422
|
+
- https://semgrep.dev/r/java.lang.security.audit.open-redirect
|
|
423
|
+
|
|
424
|
+
# ============================================================================
|
|
425
|
+
# JWT SECURITY
|
|
426
|
+
# ============================================================================
|
|
427
|
+
- id: java.jwt.security.jwt-none-algorithm
|
|
428
|
+
languages: [java]
|
|
429
|
+
severity: ERROR
|
|
430
|
+
message: "JWT with 'none' algorithm detected. Always use a secure algorithm."
|
|
431
|
+
patterns:
|
|
432
|
+
- "Algorithm\\.none\\s*\\("
|
|
433
|
+
- "SignatureAlgorithm\\.NONE"
|
|
434
|
+
metadata:
|
|
435
|
+
cwe: "CWE-327"
|
|
436
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
437
|
+
confidence: HIGH
|
|
438
|
+
references:
|
|
439
|
+
- https://semgrep.dev/r/java.jwt.security.jwt-none-algorithm
|
|
440
|
+
|
|
441
|
+
- id: java.jwt.security.jwt-hardcoded-secret
|
|
442
|
+
languages: [java]
|
|
443
|
+
severity: ERROR
|
|
444
|
+
message: "Hardcoded JWT secret detected. Use environment variables."
|
|
445
|
+
patterns:
|
|
446
|
+
- "Jwts\\.parser\\s*\\(\\s*\\)\\.setSigningKey\\s*\\(\\s*\"[^\"]{8,}\""
|
|
447
|
+
- "Algorithm\\.HMAC.*\\(\\s*\"[^\"]{8,}\""
|
|
448
|
+
metadata:
|
|
449
|
+
cwe: "CWE-798"
|
|
450
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
451
|
+
confidence: HIGH
|
|
452
|
+
references:
|
|
453
|
+
- https://semgrep.dev/r/java.jwt.security.jwt-hardcoded-secret
|