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,380 @@
|
|
|
1
|
+
rules:
|
|
2
|
+
# ============================================================================
|
|
3
|
+
# SQL INJECTION
|
|
4
|
+
# ============================================================================
|
|
5
|
+
- id: go.lang.security.audit.sqli.sql-injection-db
|
|
6
|
+
languages: [go]
|
|
7
|
+
severity: ERROR
|
|
8
|
+
message: "Possible SQL injection. Use parameterized queries with $1, $2 placeholders."
|
|
9
|
+
patterns:
|
|
10
|
+
- "db\\.Query\\s*\\([^)]*\\+"
|
|
11
|
+
- "db\\.Exec\\s*\\([^)]*\\+"
|
|
12
|
+
- "db\\.QueryRow\\s*\\([^)]*\\+"
|
|
13
|
+
- "fmt\\.Sprintf.*SELECT.*FROM"
|
|
14
|
+
- "fmt\\.Sprintf.*INSERT.*INTO"
|
|
15
|
+
- "fmt\\.Sprintf.*UPDATE.*SET"
|
|
16
|
+
- "fmt\\.Sprintf.*DELETE.*FROM"
|
|
17
|
+
metadata:
|
|
18
|
+
cwe: "CWE-89"
|
|
19
|
+
owasp: "A03:2021 - Injection"
|
|
20
|
+
confidence: HIGH
|
|
21
|
+
references:
|
|
22
|
+
- https://semgrep.dev/r/go.lang.security.audit.sqli.sql-injection-db
|
|
23
|
+
|
|
24
|
+
# ============================================================================
|
|
25
|
+
# COMMAND INJECTION
|
|
26
|
+
# ============================================================================
|
|
27
|
+
- id: go.lang.security.audit.command-injection-exec
|
|
28
|
+
languages: [go]
|
|
29
|
+
severity: ERROR
|
|
30
|
+
message: "Possible command injection via exec.Command. Validate and sanitize input."
|
|
31
|
+
patterns:
|
|
32
|
+
- "exec\\.Command\\s*\\([^)]*\\+"
|
|
33
|
+
- "exec\\.CommandContext\\s*\\([^)]*\\+"
|
|
34
|
+
metadata:
|
|
35
|
+
cwe: "CWE-78"
|
|
36
|
+
owasp: "A03:2021 - Injection"
|
|
37
|
+
confidence: HIGH
|
|
38
|
+
references:
|
|
39
|
+
- https://semgrep.dev/r/go.lang.security.audit.command-injection-exec
|
|
40
|
+
|
|
41
|
+
# ============================================================================
|
|
42
|
+
# PATH TRAVERSAL
|
|
43
|
+
# ============================================================================
|
|
44
|
+
- id: go.lang.security.audit.path-traversal
|
|
45
|
+
languages: [go]
|
|
46
|
+
severity: WARNING
|
|
47
|
+
message: "Possible path traversal vulnerability. Use filepath.Clean and validate paths."
|
|
48
|
+
patterns:
|
|
49
|
+
- "os\\.Open\\s*\\([^)]*\\+"
|
|
50
|
+
- "os\\.Create\\s*\\([^)]*\\+"
|
|
51
|
+
- "os\\.ReadFile\\s*\\([^)]*\\+"
|
|
52
|
+
- "ioutil\\.ReadFile\\s*\\([^)]*\\+"
|
|
53
|
+
- "ioutil\\.WriteFile\\s*\\([^)]*\\+"
|
|
54
|
+
- "filepath\\.Join\\s*\\([^)]*\\.\\./"
|
|
55
|
+
metadata:
|
|
56
|
+
cwe: "CWE-22"
|
|
57
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
58
|
+
confidence: MEDIUM
|
|
59
|
+
references:
|
|
60
|
+
- https://semgrep.dev/r/go.lang.security.audit.path-traversal
|
|
61
|
+
|
|
62
|
+
# ============================================================================
|
|
63
|
+
# SSRF
|
|
64
|
+
# ============================================================================
|
|
65
|
+
- id: go.lang.security.audit.ssrf-http
|
|
66
|
+
languages: [go]
|
|
67
|
+
severity: WARNING
|
|
68
|
+
message: "Possible SSRF vulnerability. Validate and whitelist URLs."
|
|
69
|
+
patterns:
|
|
70
|
+
- "http\\.Get\\s*\\([^)]*\\+"
|
|
71
|
+
- "http\\.Post\\s*\\([^)]*\\+"
|
|
72
|
+
- "http\\.NewRequest\\s*\\([^)]*\\+"
|
|
73
|
+
- "client\\.Do\\s*\\("
|
|
74
|
+
metadata:
|
|
75
|
+
cwe: "CWE-918"
|
|
76
|
+
owasp: "A10:2021 - Server-Side Request Forgery"
|
|
77
|
+
confidence: MEDIUM
|
|
78
|
+
references:
|
|
79
|
+
- https://semgrep.dev/r/go.lang.security.audit.ssrf-http
|
|
80
|
+
|
|
81
|
+
# ============================================================================
|
|
82
|
+
# CRYPTOGRAPHY
|
|
83
|
+
# ============================================================================
|
|
84
|
+
- id: go.lang.security.crypto.weak-hash-md5
|
|
85
|
+
languages: [go]
|
|
86
|
+
severity: WARNING
|
|
87
|
+
message: "MD5 is cryptographically weak. Use SHA-256 or stronger."
|
|
88
|
+
patterns:
|
|
89
|
+
- "md5\\.New\\s*\\("
|
|
90
|
+
- "md5\\.Sum\\s*\\("
|
|
91
|
+
- "crypto/md5"
|
|
92
|
+
metadata:
|
|
93
|
+
cwe: "CWE-328"
|
|
94
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
95
|
+
confidence: HIGH
|
|
96
|
+
references:
|
|
97
|
+
- https://semgrep.dev/r/go.lang.security.audit.weak-hash-md5
|
|
98
|
+
|
|
99
|
+
- id: go.lang.security.crypto.weak-hash-sha1
|
|
100
|
+
languages: [go]
|
|
101
|
+
severity: WARNING
|
|
102
|
+
message: "SHA-1 is cryptographically weak. Use SHA-256 or stronger."
|
|
103
|
+
patterns:
|
|
104
|
+
- "sha1\\.New\\s*\\("
|
|
105
|
+
- "sha1\\.Sum\\s*\\("
|
|
106
|
+
- "crypto/sha1"
|
|
107
|
+
metadata:
|
|
108
|
+
cwe: "CWE-328"
|
|
109
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
110
|
+
confidence: HIGH
|
|
111
|
+
references:
|
|
112
|
+
- https://semgrep.dev/r/go.lang.security.audit.weak-hash-sha1
|
|
113
|
+
|
|
114
|
+
- id: go.lang.security.crypto.insecure-random
|
|
115
|
+
languages: [go]
|
|
116
|
+
severity: WARNING
|
|
117
|
+
message: "math/rand is not cryptographically secure. Use crypto/rand."
|
|
118
|
+
patterns:
|
|
119
|
+
- "math/rand"
|
|
120
|
+
- "rand\\.Seed\\s*\\("
|
|
121
|
+
- "rand\\.Int\\s*\\("
|
|
122
|
+
- "rand\\.Intn\\s*\\("
|
|
123
|
+
metadata:
|
|
124
|
+
cwe: "CWE-330"
|
|
125
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
126
|
+
confidence: MEDIUM
|
|
127
|
+
references:
|
|
128
|
+
- https://semgrep.dev/r/go.lang.security.audit.insecure-random
|
|
129
|
+
|
|
130
|
+
- id: go.lang.security.crypto.weak-cipher-des
|
|
131
|
+
languages: [go]
|
|
132
|
+
severity: ERROR
|
|
133
|
+
message: "DES/3DES is insecure. Use AES."
|
|
134
|
+
patterns:
|
|
135
|
+
- "des\\.NewCipher\\s*\\("
|
|
136
|
+
- "des\\.NewTripleDESCipher\\s*\\("
|
|
137
|
+
- "crypto/des"
|
|
138
|
+
metadata:
|
|
139
|
+
cwe: "CWE-327"
|
|
140
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
141
|
+
confidence: HIGH
|
|
142
|
+
references:
|
|
143
|
+
- https://semgrep.dev/r/go.lang.security.audit.weak-cipher-des
|
|
144
|
+
|
|
145
|
+
# ============================================================================
|
|
146
|
+
# SSL/TLS
|
|
147
|
+
# ============================================================================
|
|
148
|
+
- id: go.lang.security.ssl.insecure-skip-verify
|
|
149
|
+
languages: [go]
|
|
150
|
+
severity: ERROR
|
|
151
|
+
message: "TLS certificate verification is disabled. This allows MITM attacks."
|
|
152
|
+
patterns:
|
|
153
|
+
- "InsecureSkipVerify\\s*:\\s*true"
|
|
154
|
+
- "tls\\.Config\\s*\\{[^}]*InsecureSkipVerify"
|
|
155
|
+
metadata:
|
|
156
|
+
cwe: "CWE-295"
|
|
157
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
158
|
+
confidence: HIGH
|
|
159
|
+
references:
|
|
160
|
+
- https://semgrep.dev/r/go.lang.security.audit.tls-insecure-skip-verify
|
|
161
|
+
|
|
162
|
+
- id: go.lang.security.ssl.weak-tls-version
|
|
163
|
+
languages: [go]
|
|
164
|
+
severity: ERROR
|
|
165
|
+
message: "Weak TLS version. Use TLS 1.2 or higher."
|
|
166
|
+
patterns:
|
|
167
|
+
- "MinVersion\\s*:\\s*tls\\.VersionSSL30"
|
|
168
|
+
- "MinVersion\\s*:\\s*tls\\.VersionTLS10"
|
|
169
|
+
- "MinVersion\\s*:\\s*tls\\.VersionTLS11"
|
|
170
|
+
metadata:
|
|
171
|
+
cwe: "CWE-326"
|
|
172
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
173
|
+
confidence: HIGH
|
|
174
|
+
references:
|
|
175
|
+
- https://semgrep.dev/r/go.lang.security.audit.weak-tls-version
|
|
176
|
+
|
|
177
|
+
# ============================================================================
|
|
178
|
+
# HARDCODED SECRETS
|
|
179
|
+
# ============================================================================
|
|
180
|
+
- id: go.lang.security.audit.hardcoded-password
|
|
181
|
+
languages: [go]
|
|
182
|
+
severity: ERROR
|
|
183
|
+
message: "Hardcoded password detected. Use environment variables."
|
|
184
|
+
patterns:
|
|
185
|
+
- "password\\s*:?=\\s*\"[^\"]{4,}\""
|
|
186
|
+
- "passwd\\s*:?=\\s*\"[^\"]{4,}\""
|
|
187
|
+
- "Password\\s*:\\s*\"[^\"]{4,}\""
|
|
188
|
+
metadata:
|
|
189
|
+
cwe: "CWE-798"
|
|
190
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
191
|
+
confidence: HIGH
|
|
192
|
+
references:
|
|
193
|
+
- https://semgrep.dev/r/go.lang.security.audit.hardcoded-password
|
|
194
|
+
|
|
195
|
+
- id: go.lang.security.audit.hardcoded-api-key
|
|
196
|
+
languages: [go]
|
|
197
|
+
severity: ERROR
|
|
198
|
+
message: "Hardcoded API key detected. Use environment variables."
|
|
199
|
+
patterns:
|
|
200
|
+
- "apiKey\\s*:?=\\s*\"[A-Za-z0-9_-]{16,}\""
|
|
201
|
+
- "secretKey\\s*:?=\\s*\"[A-Za-z0-9_-]{16,}\""
|
|
202
|
+
- "ApiKey\\s*:\\s*\"[A-Za-z0-9_-]{16,}\""
|
|
203
|
+
metadata:
|
|
204
|
+
cwe: "CWE-798"
|
|
205
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
206
|
+
confidence: HIGH
|
|
207
|
+
references:
|
|
208
|
+
- https://semgrep.dev/r/go.lang.security.audit.hardcoded-api-key
|
|
209
|
+
|
|
210
|
+
# ============================================================================
|
|
211
|
+
# TEMPLATE INJECTION
|
|
212
|
+
# ============================================================================
|
|
213
|
+
- id: go.lang.security.audit.template-injection
|
|
214
|
+
languages: [go]
|
|
215
|
+
severity: ERROR
|
|
216
|
+
message: "Possible template injection. Avoid user input in template parsing."
|
|
217
|
+
patterns:
|
|
218
|
+
- "template\\.HTML\\s*\\("
|
|
219
|
+
- "template\\.JS\\s*\\("
|
|
220
|
+
- "template\\.URL\\s*\\("
|
|
221
|
+
metadata:
|
|
222
|
+
cwe: "CWE-94"
|
|
223
|
+
owasp: "A03:2021 - Injection"
|
|
224
|
+
confidence: MEDIUM
|
|
225
|
+
references:
|
|
226
|
+
- https://semgrep.dev/r/go.lang.security.audit.template-injection
|
|
227
|
+
|
|
228
|
+
# ============================================================================
|
|
229
|
+
# OPEN REDIRECT
|
|
230
|
+
# ============================================================================
|
|
231
|
+
- id: go.lang.security.audit.open-redirect
|
|
232
|
+
languages: [go]
|
|
233
|
+
severity: WARNING
|
|
234
|
+
message: "Possible open redirect vulnerability. Validate redirect URLs."
|
|
235
|
+
patterns:
|
|
236
|
+
- "http\\.Redirect\\s*\\([^)]*\\+"
|
|
237
|
+
- "w\\.Header\\s*\\(\\s*\\)\\.Set\\s*\\(\\s*\"Location\""
|
|
238
|
+
metadata:
|
|
239
|
+
cwe: "CWE-601"
|
|
240
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
241
|
+
confidence: MEDIUM
|
|
242
|
+
references:
|
|
243
|
+
- https://semgrep.dev/r/go.lang.security.audit.open-redirect
|
|
244
|
+
|
|
245
|
+
# ============================================================================
|
|
246
|
+
# XSS
|
|
247
|
+
# ============================================================================
|
|
248
|
+
- id: go.lang.security.audit.xss-response-writer
|
|
249
|
+
languages: [go]
|
|
250
|
+
severity: ERROR
|
|
251
|
+
message: "Possible XSS via ResponseWriter.Write. Escape user input."
|
|
252
|
+
patterns:
|
|
253
|
+
- "w\\.Write\\s*\\([^)]*\\+"
|
|
254
|
+
- "fmt\\.Fprintf\\s*\\(\\s*w\\s*,"
|
|
255
|
+
- "io\\.WriteString\\s*\\(\\s*w\\s*,"
|
|
256
|
+
metadata:
|
|
257
|
+
cwe: "CWE-79"
|
|
258
|
+
owasp: "A03:2021 - Injection"
|
|
259
|
+
confidence: MEDIUM
|
|
260
|
+
references:
|
|
261
|
+
- https://semgrep.dev/r/go.lang.security.audit.xss-response-writer
|
|
262
|
+
|
|
263
|
+
# ============================================================================
|
|
264
|
+
# JWT SECURITY
|
|
265
|
+
# ============================================================================
|
|
266
|
+
- id: go.jwt.security.jwt-none-algorithm
|
|
267
|
+
languages: [go]
|
|
268
|
+
severity: ERROR
|
|
269
|
+
message: "JWT with 'none' algorithm is insecure. Use RS256 or HS256."
|
|
270
|
+
patterns:
|
|
271
|
+
- "jwt\\.SigningMethodNone"
|
|
272
|
+
- "SigningMethodNone"
|
|
273
|
+
metadata:
|
|
274
|
+
cwe: "CWE-327"
|
|
275
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
276
|
+
confidence: HIGH
|
|
277
|
+
references:
|
|
278
|
+
- https://semgrep.dev/r/go.jwt.security.jwt-none-algorithm
|
|
279
|
+
|
|
280
|
+
- id: go.jwt.security.jwt-hardcoded-secret
|
|
281
|
+
languages: [go]
|
|
282
|
+
severity: ERROR
|
|
283
|
+
message: "Hardcoded JWT secret detected. Use environment variables."
|
|
284
|
+
patterns:
|
|
285
|
+
- "jwt\\.Parse.*\\[\\]byte\\s*\\(\\s*\"[^\"]{8,}\"\\s*\\)"
|
|
286
|
+
- "SignedString\\s*\\(\\s*\\[\\]byte\\s*\\(\\s*\"[^\"]{8,}\"\\s*\\)\\s*\\)"
|
|
287
|
+
metadata:
|
|
288
|
+
cwe: "CWE-798"
|
|
289
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
290
|
+
confidence: HIGH
|
|
291
|
+
references:
|
|
292
|
+
- https://semgrep.dev/r/go.jwt.security.jwt-hardcoded-secret
|
|
293
|
+
|
|
294
|
+
# ============================================================================
|
|
295
|
+
# CORS
|
|
296
|
+
# ============================================================================
|
|
297
|
+
- id: go.lang.security.audit.cors-wildcard
|
|
298
|
+
languages: [go]
|
|
299
|
+
severity: WARNING
|
|
300
|
+
message: "CORS with wildcard origin. Restrict to specific origins."
|
|
301
|
+
patterns:
|
|
302
|
+
- "Access-Control-Allow-Origin.*\\*"
|
|
303
|
+
- "AllowOrigins\\s*:\\s*\\[\\s*\"\\*\"\\s*\\]"
|
|
304
|
+
metadata:
|
|
305
|
+
cwe: "CWE-942"
|
|
306
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
307
|
+
confidence: HIGH
|
|
308
|
+
references:
|
|
309
|
+
- https://semgrep.dev/r/go.lang.security.audit.cors-wildcard
|
|
310
|
+
|
|
311
|
+
# ============================================================================
|
|
312
|
+
# LOGGING SENSITIVE DATA
|
|
313
|
+
# ============================================================================
|
|
314
|
+
- id: go.lang.security.audit.logging-sensitive-data
|
|
315
|
+
languages: [go]
|
|
316
|
+
severity: WARNING
|
|
317
|
+
message: "Possible sensitive data in log. Avoid logging passwords or secrets."
|
|
318
|
+
patterns:
|
|
319
|
+
- "log\\.(Print|Printf|Println|Fatal|Fatalf).*password"
|
|
320
|
+
- "log\\.(Print|Printf|Println|Fatal|Fatalf).*secret"
|
|
321
|
+
- "log\\.(Print|Printf|Println|Fatal|Fatalf).*token"
|
|
322
|
+
- "fmt\\.(Print|Printf|Println).*password"
|
|
323
|
+
metadata:
|
|
324
|
+
cwe: "CWE-532"
|
|
325
|
+
owasp: "A09:2021 - Security Logging and Monitoring Failures"
|
|
326
|
+
confidence: MEDIUM
|
|
327
|
+
references:
|
|
328
|
+
- https://semgrep.dev/r/go.lang.security.audit.logging-sensitive-data
|
|
329
|
+
|
|
330
|
+
# ============================================================================
|
|
331
|
+
# DESERIALIZATION
|
|
332
|
+
# ============================================================================
|
|
333
|
+
- id: go.lang.security.deserialization.gob-decode
|
|
334
|
+
languages: [go]
|
|
335
|
+
severity: WARNING
|
|
336
|
+
message: "gob.Decode can deserialize arbitrary types. Validate input source."
|
|
337
|
+
patterns:
|
|
338
|
+
- "gob\\.NewDecoder\\s*\\("
|
|
339
|
+
- "\\.Decode\\s*\\(&"
|
|
340
|
+
metadata:
|
|
341
|
+
cwe: "CWE-502"
|
|
342
|
+
owasp: "A08:2021 - Software and Data Integrity Failures"
|
|
343
|
+
confidence: LOW
|
|
344
|
+
references:
|
|
345
|
+
- https://semgrep.dev/r/go.lang.security.deserialization.gob-decode
|
|
346
|
+
|
|
347
|
+
# ============================================================================
|
|
348
|
+
# RACE CONDITIONS
|
|
349
|
+
# ============================================================================
|
|
350
|
+
- id: go.lang.security.audit.race-condition-goroutine
|
|
351
|
+
languages: [go]
|
|
352
|
+
severity: WARNING
|
|
353
|
+
message: "Possible race condition. Use mutex or channels for shared state."
|
|
354
|
+
patterns:
|
|
355
|
+
- "go\\s+func\\s*\\([^)]*\\)\\s*\\{[^}]*\\+\\+"
|
|
356
|
+
- "go\\s+func\\s*\\([^)]*\\)\\s*\\{[^}]*\\-\\-"
|
|
357
|
+
metadata:
|
|
358
|
+
cwe: "CWE-362"
|
|
359
|
+
owasp: "A04:2021 - Insecure Design"
|
|
360
|
+
confidence: LOW
|
|
361
|
+
references:
|
|
362
|
+
- https://semgrep.dev/r/go.lang.security.audit.race-condition
|
|
363
|
+
|
|
364
|
+
# ============================================================================
|
|
365
|
+
# UNVALIDATED INPUT
|
|
366
|
+
# ============================================================================
|
|
367
|
+
- id: go.lang.security.audit.gin-bind-struct-tag
|
|
368
|
+
languages: [go]
|
|
369
|
+
severity: WARNING
|
|
370
|
+
message: "Gin binding without validation. Add binding tags for input validation."
|
|
371
|
+
patterns:
|
|
372
|
+
- "\\.Bind\\s*\\(&"
|
|
373
|
+
- "\\.ShouldBind\\s*\\(&"
|
|
374
|
+
- "\\.BindJSON\\s*\\(&"
|
|
375
|
+
metadata:
|
|
376
|
+
cwe: "CWE-20"
|
|
377
|
+
owasp: "A03:2021 - Injection"
|
|
378
|
+
confidence: LOW
|
|
379
|
+
references:
|
|
380
|
+
- https://semgrep.dev/r/go.lang.security.audit.gin-bind-validation
|