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.
@@ -0,0 +1,504 @@
1
+ rules:
2
+ # ============================================================================
3
+ # XSS RULES
4
+ # ============================================================================
5
+ - id: javascript.browser.security.dom-based-xss.innerHTML
6
+ languages: [javascript, typescript]
7
+ severity: ERROR
8
+ message: "Detected innerHTML assignment. This can lead to XSS. Use textContent or sanitize input."
9
+ patterns:
10
+ - "\\.innerHTML\\s*="
11
+ - "\\.innerHTML\\s*\\+="
12
+ metadata:
13
+ cwe: "CWE-79"
14
+ owasp: "A03:2021 - Injection"
15
+ confidence: HIGH
16
+ references:
17
+ - https://semgrep.dev/r/javascript.browser.security.dom-based-xss.dom-based-xss-innerHTML
18
+
19
+ - id: javascript.browser.security.dom-based-xss.outerHTML
20
+ languages: [javascript, typescript]
21
+ severity: ERROR
22
+ message: "Detected outerHTML assignment. This can lead to XSS. Sanitize input before use."
23
+ patterns:
24
+ - "\\.outerHTML\\s*="
25
+ metadata:
26
+ cwe: "CWE-79"
27
+ owasp: "A03:2021 - Injection"
28
+ confidence: HIGH
29
+ references:
30
+ - https://semgrep.dev/r/javascript.browser.security.dom-based-xss.dom-based-xss-outerHTML
31
+
32
+ - id: javascript.browser.security.dom-based-xss.document-write
33
+ languages: [javascript, typescript]
34
+ severity: ERROR
35
+ message: "Detected document.write(). This can lead to XSS. Use safer DOM manipulation methods."
36
+ patterns:
37
+ - "document\\.write\\s*\\("
38
+ - "document\\.writeln\\s*\\("
39
+ metadata:
40
+ cwe: "CWE-79"
41
+ owasp: "A03:2021 - Injection"
42
+ confidence: HIGH
43
+ references:
44
+ - https://semgrep.dev/r/javascript.browser.security.dom-based-xss.dom-based-xss-document-write
45
+
46
+ - id: javascript.browser.security.dom-based-xss.insertAdjacentHTML
47
+ languages: [javascript, typescript]
48
+ severity: ERROR
49
+ message: "Detected insertAdjacentHTML. This can lead to XSS. Sanitize input before use."
50
+ patterns:
51
+ - "\\.insertAdjacentHTML\\s*\\("
52
+ metadata:
53
+ cwe: "CWE-79"
54
+ owasp: "A03:2021 - Injection"
55
+ confidence: HIGH
56
+ references:
57
+ - https://semgrep.dev/r/javascript.browser.security.dom-based-xss.dom-based-xss-insertAdjacentHTML
58
+
59
+ - id: javascript.react.security.dangerouslySetInnerHTML
60
+ languages: [javascript, typescript]
61
+ severity: ERROR
62
+ message: "Detected dangerouslySetInnerHTML in React. Ensure input is sanitized with DOMPurify."
63
+ patterns:
64
+ - "dangerouslySetInnerHTML\\s*="
65
+ - "dangerouslySetInnerHTML:\\s*\\{"
66
+ metadata:
67
+ cwe: "CWE-79"
68
+ owasp: "A03:2021 - Injection"
69
+ confidence: HIGH
70
+ references:
71
+ - https://semgrep.dev/r/javascript.react.security.audit.react-dangerouslysetinnerhtml
72
+
73
+ # ============================================================================
74
+ # CODE INJECTION / EVAL
75
+ # ============================================================================
76
+ - id: javascript.lang.security.audit.eval-detected
77
+ languages: [javascript, typescript]
78
+ severity: ERROR
79
+ message: "Detected eval(). This is dangerous and can lead to code injection. Avoid eval() with untrusted input."
80
+ patterns:
81
+ - "\\beval\\s*\\("
82
+ metadata:
83
+ cwe: "CWE-95"
84
+ owasp: "A03:2021 - Injection"
85
+ confidence: HIGH
86
+ references:
87
+ - https://semgrep.dev/r/javascript.lang.security.audit.eval-detected
88
+
89
+ - id: javascript.lang.security.audit.function-constructor
90
+ languages: [javascript, typescript]
91
+ severity: ERROR
92
+ message: "Detected Function constructor. This is similar to eval() and can lead to code injection."
93
+ patterns:
94
+ - "new\\s+Function\\s*\\("
95
+ - "Function\\s*\\("
96
+ metadata:
97
+ cwe: "CWE-95"
98
+ owasp: "A03:2021 - Injection"
99
+ confidence: HIGH
100
+ references:
101
+ - https://semgrep.dev/r/javascript.lang.security.audit.function-constructor
102
+
103
+ - id: javascript.lang.security.audit.setTimeout-string
104
+ languages: [javascript, typescript]
105
+ severity: WARNING
106
+ message: "Detected setTimeout/setInterval with string argument. Use function reference instead."
107
+ patterns:
108
+ - "setTimeout\\s*\\(\\s*[\"']"
109
+ - "setInterval\\s*\\(\\s*[\"']"
110
+ metadata:
111
+ cwe: "CWE-95"
112
+ owasp: "A03:2021 - Injection"
113
+ confidence: MEDIUM
114
+ references:
115
+ - https://semgrep.dev/r/javascript.lang.security.audit.setTimeout-string-argument
116
+
117
+ # ============================================================================
118
+ # COMMAND INJECTION
119
+ # ============================================================================
120
+ - id: javascript.lang.security.audit.child-process-exec
121
+ languages: [javascript, typescript]
122
+ severity: ERROR
123
+ message: "Detected child_process.exec() with user input. Use execFile() or spawn() with shell=false."
124
+ patterns:
125
+ - "exec\\s*\\([^)]*\\+[^)]*\\)"
126
+ - "exec\\s*\\(\\s*`"
127
+ - "execSync\\s*\\([^)]*\\+[^)]*\\)"
128
+ - "execSync\\s*\\(\\s*`"
129
+ metadata:
130
+ cwe: "CWE-78"
131
+ owasp: "A03:2021 - Injection"
132
+ confidence: HIGH
133
+ references:
134
+ - https://semgrep.dev/r/javascript.lang.security.audit.child-process-exec
135
+
136
+ - id: javascript.lang.security.audit.spawn-shell
137
+ languages: [javascript, typescript]
138
+ severity: ERROR
139
+ message: "Detected spawn() with shell=true. This can lead to command injection."
140
+ patterns:
141
+ - "spawn\\s*\\([^)]*shell\\s*:\\s*true"
142
+ - "spawnSync\\s*\\([^)]*shell\\s*:\\s*true"
143
+ metadata:
144
+ cwe: "CWE-78"
145
+ owasp: "A03:2021 - Injection"
146
+ confidence: HIGH
147
+ references:
148
+ - https://semgrep.dev/r/javascript.lang.security.audit.spawn-shell-true
149
+
150
+ # ============================================================================
151
+ # SQL INJECTION
152
+ # ============================================================================
153
+ - id: javascript.lang.security.audit.sql-injection
154
+ languages: [javascript, typescript]
155
+ severity: ERROR
156
+ message: "Possible SQL injection. Use parameterized queries or prepared statements."
157
+ patterns:
158
+ - "query\\s*\\([^)]*\\+[^)]*\\)"
159
+ - "query\\s*\\(\\s*`[^`]*\\$\\{"
160
+ - "execute\\s*\\([^)]*\\+[^)]*\\)"
161
+ - "raw\\s*\\(\\s*`[^`]*\\$\\{"
162
+ metadata:
163
+ cwe: "CWE-89"
164
+ owasp: "A03:2021 - Injection"
165
+ confidence: HIGH
166
+ references:
167
+ - https://semgrep.dev/r/javascript.lang.security.audit.sql-injection
168
+
169
+ - id: javascript.sequelize.security.raw-query
170
+ languages: [javascript, typescript]
171
+ severity: ERROR
172
+ message: "Detected Sequelize raw query with string interpolation. Use parameterized replacements."
173
+ patterns:
174
+ - "sequelize\\.query\\s*\\(\\s*`"
175
+ - "\\.query\\s*\\(\\s*`[^`]*\\$\\{"
176
+ metadata:
177
+ cwe: "CWE-89"
178
+ owasp: "A03:2021 - Injection"
179
+ confidence: HIGH
180
+ references:
181
+ - https://semgrep.dev/r/javascript.sequelize.security.audit.sequelize-raw-query
182
+
183
+ # ============================================================================
184
+ # NOSQL INJECTION
185
+ # ============================================================================
186
+ - id: javascript.mongodb.security.nosql-injection
187
+ languages: [javascript, typescript]
188
+ severity: ERROR
189
+ message: "Possible NoSQL injection. Validate and sanitize user input in MongoDB queries."
190
+ patterns:
191
+ - "\\$where\\s*:"
192
+ - "\\$expr\\s*:"
193
+ - "find\\s*\\(\\s*\\{[^}]*:\\s*req\\."
194
+ - "findOne\\s*\\(\\s*\\{[^}]*:\\s*req\\."
195
+ metadata:
196
+ cwe: "CWE-943"
197
+ owasp: "A03:2021 - Injection"
198
+ confidence: MEDIUM
199
+ references:
200
+ - https://semgrep.dev/r/javascript.mongodb.security.audit.nosql-injection
201
+
202
+ # ============================================================================
203
+ # PATH TRAVERSAL
204
+ # ============================================================================
205
+ - id: javascript.lang.security.audit.path-traversal
206
+ languages: [javascript, typescript]
207
+ severity: WARNING
208
+ message: "Possible path traversal vulnerability. Validate and sanitize file paths."
209
+ patterns:
210
+ - "readFile\\s*\\([^)]*\\+[^)]*\\)"
211
+ - "readFileSync\\s*\\([^)]*\\+[^)]*\\)"
212
+ - "writeFile\\s*\\([^)]*\\+[^)]*\\)"
213
+ - "writeFileSync\\s*\\([^)]*\\+[^)]*\\)"
214
+ - "createReadStream\\s*\\([^)]*\\+[^)]*\\)"
215
+ - "createWriteStream\\s*\\([^)]*\\+[^)]*\\)"
216
+ - "path\\.join\\s*\\([^)]*req\\."
217
+ metadata:
218
+ cwe: "CWE-22"
219
+ owasp: "A01:2021 - Broken Access Control"
220
+ confidence: MEDIUM
221
+ references:
222
+ - https://semgrep.dev/r/javascript.lang.security.audit.path-traversal
223
+
224
+ # ============================================================================
225
+ # SSRF
226
+ # ============================================================================
227
+ - id: javascript.lang.security.audit.ssrf-fetch
228
+ languages: [javascript, typescript]
229
+ severity: WARNING
230
+ message: "Possible SSRF vulnerability. Validate and whitelist URLs before making requests."
231
+ patterns:
232
+ - "fetch\\s*\\([^)]*\\+[^)]*\\)"
233
+ - "fetch\\s*\\(\\s*`[^`]*\\$\\{"
234
+ - "fetch\\s*\\(\\s*req\\."
235
+ metadata:
236
+ cwe: "CWE-918"
237
+ owasp: "A10:2021 - Server-Side Request Forgery"
238
+ confidence: MEDIUM
239
+ references:
240
+ - https://semgrep.dev/r/javascript.lang.security.audit.ssrf-fetch
241
+
242
+ - id: javascript.lang.security.audit.ssrf-axios
243
+ languages: [javascript, typescript]
244
+ severity: WARNING
245
+ message: "Possible SSRF vulnerability with axios. Validate and whitelist URLs."
246
+ patterns:
247
+ - "axios\\.(get|post|put|delete|patch)\\s*\\([^)]*\\+[^)]*\\)"
248
+ - "axios\\.(get|post|put|delete|patch)\\s*\\(\\s*`[^`]*\\$\\{"
249
+ - "axios\\s*\\(\\s*\\{[^}]*url\\s*:[^}]*\\+[^}]*\\}"
250
+ metadata:
251
+ cwe: "CWE-918"
252
+ owasp: "A10:2021 - Server-Side Request Forgery"
253
+ confidence: MEDIUM
254
+ references:
255
+ - https://semgrep.dev/r/javascript.axios.security.audit.ssrf-axios
256
+
257
+ # ============================================================================
258
+ # PROTOTYPE POLLUTION
259
+ # ============================================================================
260
+ - id: javascript.lang.security.audit.prototype-pollution
261
+ languages: [javascript, typescript]
262
+ severity: ERROR
263
+ message: "Possible prototype pollution vulnerability. Validate object keys before assignment."
264
+ patterns:
265
+ - "\\[\\s*[^\\]]+\\s*\\]\\s*=\\s*[^;]+\\[\\s*[^\\]]+\\s*\\]"
266
+ - "__proto__"
267
+ - "constructor\\s*\\[\\s*[\"']prototype[\"']\\s*\\]"
268
+ - "Object\\.assign\\s*\\([^,]*,\\s*req\\."
269
+ metadata:
270
+ cwe: "CWE-1321"
271
+ owasp: "A03:2021 - Injection"
272
+ confidence: MEDIUM
273
+ references:
274
+ - https://semgrep.dev/r/javascript.lang.security.audit.prototype-pollution
275
+
276
+ # ============================================================================
277
+ # HARDCODED SECRETS
278
+ # ============================================================================
279
+ - id: javascript.lang.security.audit.hardcoded-secret
280
+ languages: [javascript, typescript]
281
+ severity: ERROR
282
+ message: "Hardcoded secret detected. Use environment variables."
283
+ patterns:
284
+ - "(api[_-]?key|apikey)\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-]{16,}[\"']"
285
+ - "(secret[_-]?key|secretkey)\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-]{16,}[\"']"
286
+ - "password\\s*[:=]\\s*[\"'][^\"']{6,}[\"']"
287
+ - "token\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-\\.]{20,}[\"']"
288
+ metadata:
289
+ cwe: "CWE-798"
290
+ owasp: "A07:2021 - Identification and Authentication Failures"
291
+ confidence: HIGH
292
+ references:
293
+ - https://semgrep.dev/r/javascript.lang.security.audit.hardcoded-secret
294
+
295
+ # ============================================================================
296
+ # JWT SECURITY
297
+ # ============================================================================
298
+ - id: javascript.jwt.security.jwt-none-algorithm
299
+ languages: [javascript, typescript]
300
+ severity: ERROR
301
+ message: "JWT with 'none' algorithm detected. Always specify a secure algorithm."
302
+ patterns:
303
+ - "algorithm\\s*:\\s*[\"']none[\"']"
304
+ - "algorithms\\s*:\\s*\\[[^\\]]*[\"']none[\"']"
305
+ metadata:
306
+ cwe: "CWE-327"
307
+ owasp: "A02:2021 - Cryptographic Failures"
308
+ confidence: HIGH
309
+ references:
310
+ - https://semgrep.dev/r/javascript.jwt.security.jwt-none-algorithm
311
+
312
+ - id: javascript.jwt.security.jwt-hardcoded-secret
313
+ languages: [javascript, typescript]
314
+ severity: ERROR
315
+ message: "Hardcoded JWT secret detected. Use environment variables."
316
+ patterns:
317
+ - "jwt\\.sign\\s*\\([^,]+,\\s*[\"'][^\"']{8,}[\"']"
318
+ - "jwt\\.verify\\s*\\([^,]+,\\s*[\"'][^\"']{8,}[\"']"
319
+ metadata:
320
+ cwe: "CWE-798"
321
+ owasp: "A07:2021 - Identification and Authentication Failures"
322
+ confidence: HIGH
323
+ references:
324
+ - https://semgrep.dev/r/javascript.jwt.security.jwt-hardcoded-secret
325
+
326
+ # ============================================================================
327
+ # EXPRESS.JS SECURITY
328
+ # ============================================================================
329
+ - id: javascript.express.security.helmet-missing
330
+ languages: [javascript, typescript]
331
+ severity: WARNING
332
+ message: "Express app without helmet. Add helmet() middleware for security headers."
333
+ patterns:
334
+ - "express\\s*\\(\\s*\\)"
335
+ metadata:
336
+ cwe: "CWE-693"
337
+ owasp: "A05:2021 - Security Misconfiguration"
338
+ confidence: LOW
339
+ references:
340
+ - https://semgrep.dev/r/javascript.express.security.audit.helmet-missing
341
+
342
+ - id: javascript.express.security.cors-wildcard
343
+ languages: [javascript, typescript]
344
+ severity: WARNING
345
+ message: "CORS with wildcard origin detected. Restrict to specific origins."
346
+ patterns:
347
+ - "cors\\s*\\(\\s*\\)"
348
+ - "origin\\s*:\\s*[\"']\\*[\"']"
349
+ - "origin\\s*:\\s*true"
350
+ metadata:
351
+ cwe: "CWE-942"
352
+ owasp: "A05:2021 - Security Misconfiguration"
353
+ confidence: MEDIUM
354
+ references:
355
+ - https://semgrep.dev/r/javascript.express.security.audit.cors-wildcard
356
+
357
+ - id: javascript.express.security.csrf-disabled
358
+ languages: [javascript, typescript]
359
+ severity: WARNING
360
+ message: "CSRF protection may be disabled. Ensure CSRF middleware is configured."
361
+ patterns:
362
+ - "csrf\\s*:\\s*false"
363
+ - "ignoreMethods\\s*:\\s*\\[[^\\]]*[\"']POST[\"']"
364
+ metadata:
365
+ cwe: "CWE-352"
366
+ owasp: "A01:2021 - Broken Access Control"
367
+ confidence: MEDIUM
368
+ references:
369
+ - https://semgrep.dev/r/javascript.express.security.audit.csrf-disabled
370
+
371
+ # ============================================================================
372
+ # CRYPTOGRAPHY
373
+ # ============================================================================
374
+ - id: javascript.lang.security.crypto.insecure-hash-md5
375
+ languages: [javascript, typescript]
376
+ severity: WARNING
377
+ message: "MD5 is cryptographically weak. Use SHA-256 or stronger."
378
+ patterns:
379
+ - "createHash\\s*\\(\\s*[\"']md5[\"']\\s*\\)"
380
+ - "crypto\\.createHash\\s*\\(\\s*[\"']md5[\"']\\s*\\)"
381
+ - "MD5\\s*\\("
382
+ metadata:
383
+ cwe: "CWE-328"
384
+ owasp: "A02:2021 - Cryptographic Failures"
385
+ confidence: HIGH
386
+ references:
387
+ - https://semgrep.dev/r/javascript.lang.security.insecure-hash-function-md5
388
+
389
+ - id: javascript.lang.security.crypto.insecure-hash-sha1
390
+ languages: [javascript, typescript]
391
+ severity: WARNING
392
+ message: "SHA1 is cryptographically weak. Use SHA-256 or stronger."
393
+ patterns:
394
+ - "createHash\\s*\\(\\s*[\"']sha1[\"']\\s*\\)"
395
+ - "crypto\\.createHash\\s*\\(\\s*[\"']sha1[\"']\\s*\\)"
396
+ metadata:
397
+ cwe: "CWE-328"
398
+ owasp: "A02:2021 - Cryptographic Failures"
399
+ confidence: HIGH
400
+ references:
401
+ - https://semgrep.dev/r/javascript.lang.security.insecure-hash-function-sha1
402
+
403
+ - id: javascript.lang.security.crypto.insecure-random
404
+ languages: [javascript, typescript]
405
+ severity: WARNING
406
+ message: "Math.random() is not cryptographically secure. Use crypto.randomBytes() or crypto.getRandomValues()."
407
+ patterns:
408
+ - "Math\\.random\\s*\\(\\s*\\)"
409
+ metadata:
410
+ cwe: "CWE-330"
411
+ owasp: "A02:2021 - Cryptographic Failures"
412
+ confidence: MEDIUM
413
+ references:
414
+ - https://semgrep.dev/r/javascript.lang.security.insecure-random
415
+
416
+ # ============================================================================
417
+ # SSL/TLS
418
+ # ============================================================================
419
+ - id: javascript.lang.security.ssl.reject-unauthorized-false
420
+ languages: [javascript, typescript]
421
+ severity: ERROR
422
+ message: "SSL certificate verification is disabled. This allows MITM attacks."
423
+ patterns:
424
+ - "rejectUnauthorized\\s*:\\s*false"
425
+ - "NODE_TLS_REJECT_UNAUTHORIZED\\s*=\\s*[\"']0[\"']"
426
+ - "process\\.env\\.NODE_TLS_REJECT_UNAUTHORIZED\\s*=\\s*[\"']0[\"']"
427
+ metadata:
428
+ cwe: "CWE-295"
429
+ owasp: "A07:2021 - Identification and Authentication Failures"
430
+ confidence: HIGH
431
+ references:
432
+ - https://semgrep.dev/r/javascript.lang.security.audit.tls-reject-unauthorized-false
433
+
434
+ # ============================================================================
435
+ # OPEN REDIRECT
436
+ # ============================================================================
437
+ - id: javascript.express.security.open-redirect
438
+ languages: [javascript, typescript]
439
+ severity: WARNING
440
+ message: "Possible open redirect vulnerability. Validate redirect URLs."
441
+ patterns:
442
+ - "res\\.redirect\\s*\\(\\s*req\\."
443
+ - "res\\.redirect\\s*\\([^)]*\\+[^)]*\\)"
444
+ - "location\\s*=\\s*req\\."
445
+ metadata:
446
+ cwe: "CWE-601"
447
+ owasp: "A01:2021 - Broken Access Control"
448
+ confidence: MEDIUM
449
+ references:
450
+ - https://semgrep.dev/r/javascript.express.security.audit.open-redirect
451
+
452
+ # ============================================================================
453
+ # REGULAR EXPRESSION DOS
454
+ # ============================================================================
455
+ - id: javascript.lang.security.audit.regex-dos
456
+ languages: [javascript, typescript]
457
+ severity: WARNING
458
+ message: "Potentially vulnerable regex pattern (ReDoS). Review for catastrophic backtracking."
459
+ patterns:
460
+ - "new\\s+RegExp\\s*\\([^)]*\\([^)]*\\+\\)[^)]*\\+"
461
+ - "/\\([^)]*\\+\\)[^/]*\\+/"
462
+ metadata:
463
+ cwe: "CWE-1333"
464
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
465
+ confidence: LOW
466
+ references:
467
+ - https://semgrep.dev/r/javascript.lang.security.audit.regex-dos
468
+
469
+ # ============================================================================
470
+ # DESERIALIZATION
471
+ # ============================================================================
472
+ - id: javascript.lang.security.deserialization.node-serialize
473
+ languages: [javascript, typescript]
474
+ severity: ERROR
475
+ message: "node-serialize is vulnerable to RCE. Do not use with untrusted data."
476
+ patterns:
477
+ - "serialize\\.unserialize\\s*\\("
478
+ - "require\\s*\\(\\s*[\"']node-serialize[\"']\\s*\\)"
479
+ metadata:
480
+ cwe: "CWE-502"
481
+ owasp: "A08:2021 - Software and Data Integrity Failures"
482
+ confidence: HIGH
483
+ references:
484
+ - https://semgrep.dev/r/javascript.lang.security.deserialization.node-serialize
485
+
486
+ # ============================================================================
487
+ # LOGGING SENSITIVE DATA
488
+ # ============================================================================
489
+ - id: javascript.lang.security.audit.logging-sensitive-data
490
+ languages: [javascript, typescript]
491
+ severity: WARNING
492
+ message: "Possible sensitive data in log statement. Avoid logging passwords, tokens, or secrets."
493
+ patterns:
494
+ - "console\\.(log|info|warn|error|debug)\\s*\\([^)]*password"
495
+ - "console\\.(log|info|warn|error|debug)\\s*\\([^)]*secret"
496
+ - "console\\.(log|info|warn|error|debug)\\s*\\([^)]*token"
497
+ - "console\\.(log|info|warn|error|debug)\\s*\\([^)]*apiKey"
498
+ - "logger\\.(log|info|warn|error|debug)\\s*\\([^)]*password"
499
+ metadata:
500
+ cwe: "CWE-532"
501
+ owasp: "A09:2021 - Security Logging and Monitoring Failures"
502
+ confidence: MEDIUM
503
+ references:
504
+ - https://semgrep.dev/r/javascript.lang.security.audit.logging-sensitive-data