agent-security-scanner-mcp 1.1.2 → 1.3.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,459 @@
1
+ rules:
2
+ # =============================================================================
3
+ # C/C++ SECURITY RULES - Buffer Overflow (Dangerous Functions)
4
+ # =============================================================================
5
+
6
+ - id: c.lang.security.audit.strcpy-usage
7
+ languages: [c, cpp]
8
+ severity: ERROR
9
+ message: "strcpy is unsafe and can cause buffer overflow. Use strncpy or strlcpy with bounds checking."
10
+ patterns:
11
+ - "\\bstrcpy\\s*\\("
12
+ metadata:
13
+ cwe: "CWE-120"
14
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
15
+ confidence: HIGH
16
+ references:
17
+ - https://semgrep.dev/r/c.lang.security.insecure-use-strcpy
18
+ - https://cwe.mitre.org/data/definitions/120.html
19
+
20
+ - id: c.lang.security.audit.strcat-usage
21
+ languages: [c, cpp]
22
+ severity: ERROR
23
+ message: "strcat is unsafe and can cause buffer overflow. Use strncat or strlcat with bounds checking."
24
+ patterns:
25
+ - "\\bstrcat\\s*\\("
26
+ metadata:
27
+ cwe: "CWE-120"
28
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
29
+ confidence: HIGH
30
+ references:
31
+ - https://cwe.mitre.org/data/definitions/120.html
32
+
33
+ - id: c.lang.security.audit.gets-usage
34
+ languages: [c, cpp]
35
+ severity: ERROR
36
+ message: "gets() is extremely dangerous and removed in C11. Use fgets() with buffer size."
37
+ patterns:
38
+ - "\\bgets\\s*\\("
39
+ metadata:
40
+ cwe: "CWE-242"
41
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
42
+ confidence: HIGH
43
+ references:
44
+ - https://semgrep.dev/r/c.lang.security.insecure-use-gets
45
+ - https://cwe.mitre.org/data/definitions/242.html
46
+
47
+ - id: c.lang.security.audit.sprintf-usage
48
+ languages: [c, cpp]
49
+ severity: ERROR
50
+ message: "sprintf can cause buffer overflow. Use snprintf with buffer size limit."
51
+ patterns:
52
+ - "\\bsprintf\\s*\\("
53
+ metadata:
54
+ cwe: "CWE-120"
55
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
56
+ confidence: HIGH
57
+ references:
58
+ - https://semgrep.dev/r/c.lang.security.insecure-use-sprintf
59
+ - https://cwe.mitre.org/data/definitions/120.html
60
+
61
+ - id: c.lang.security.audit.vsprintf-usage
62
+ languages: [c, cpp]
63
+ severity: ERROR
64
+ message: "vsprintf can cause buffer overflow. Use vsnprintf with buffer size limit."
65
+ patterns:
66
+ - "\\bvsprintf\\s*\\("
67
+ metadata:
68
+ cwe: "CWE-120"
69
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
70
+ confidence: HIGH
71
+ references:
72
+ - https://cwe.mitre.org/data/definitions/120.html
73
+
74
+ # =============================================================================
75
+ # C/C++ SECURITY RULES - Format String Vulnerabilities
76
+ # =============================================================================
77
+
78
+ - id: c.lang.security.audit.format-string-printf
79
+ languages: [c, cpp]
80
+ severity: ERROR
81
+ message: "Format string vulnerability. User input as format string can lead to crashes or code execution. Use printf(\"%s\", str)."
82
+ patterns:
83
+ - "printf\\s*\\(\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*\\)"
84
+ - "fprintf\\s*\\([^,]*,\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*\\)"
85
+ - "sprintf\\s*\\([^,]*,\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*\\)"
86
+ metadata:
87
+ cwe: "CWE-134"
88
+ owasp: "A03:2021 - Injection"
89
+ confidence: MEDIUM
90
+ references:
91
+ - https://semgrep.dev/r/c.lang.security.format-string
92
+ - https://cwe.mitre.org/data/definitions/134.html
93
+
94
+ - id: c.lang.security.audit.format-string-syslog
95
+ languages: [c, cpp]
96
+ severity: ERROR
97
+ message: "Format string vulnerability in syslog. Use syslog(LOG_INFO, \"%s\", str)."
98
+ patterns:
99
+ - "syslog\\s*\\([^,]*,\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*\\)"
100
+ metadata:
101
+ cwe: "CWE-134"
102
+ owasp: "A03:2021 - Injection"
103
+ confidence: HIGH
104
+ references:
105
+ - https://cwe.mitre.org/data/definitions/134.html
106
+
107
+ # =============================================================================
108
+ # C/C++ SECURITY RULES - Memory Management
109
+ # =============================================================================
110
+
111
+ - id: c.lang.security.audit.use-after-free
112
+ languages: [c, cpp]
113
+ severity: ERROR
114
+ message: "Potential use-after-free. Set pointer to NULL after free() to prevent accidental reuse."
115
+ patterns:
116
+ - "free\\s*\\([^)]+\\)\\s*;(?!\\s*\\w+\\s*=\\s*NULL)"
117
+ metadata:
118
+ cwe: "CWE-416"
119
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
120
+ confidence: MEDIUM
121
+ references:
122
+ - https://semgrep.dev/r/c.lang.security.use-after-free
123
+ - https://cwe.mitre.org/data/definitions/416.html
124
+
125
+ - id: c.lang.security.audit.double-free
126
+ languages: [c, cpp]
127
+ severity: ERROR
128
+ message: "Potential double-free vulnerability. Track free() calls and set pointers to NULL."
129
+ patterns:
130
+ - "free\\s*\\(\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\)[^}]*free\\s*\\(\\s*\\1\\s*\\)"
131
+ metadata:
132
+ cwe: "CWE-415"
133
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
134
+ confidence: MEDIUM
135
+ references:
136
+ - https://semgrep.dev/r/c.lang.security.double-free
137
+ - https://cwe.mitre.org/data/definitions/415.html
138
+
139
+ - id: c.lang.security.audit.null-dereference
140
+ languages: [c, cpp]
141
+ severity: WARNING
142
+ message: "Potential null pointer dereference. Check pointer before dereferencing."
143
+ patterns:
144
+ - "\\*\\s*\\([^)]*malloc\\s*\\("
145
+ - "malloc\\s*\\([^)]*\\)\\s*;[^}]*\\*"
146
+ metadata:
147
+ cwe: "CWE-476"
148
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
149
+ confidence: LOW
150
+ references:
151
+ - https://cwe.mitre.org/data/definitions/476.html
152
+
153
+ # =============================================================================
154
+ # C/C++ SECURITY RULES - Integer Overflow
155
+ # =============================================================================
156
+
157
+ - id: c.lang.security.audit.integer-overflow-malloc
158
+ languages: [c, cpp]
159
+ severity: ERROR
160
+ message: "Potential integer overflow in malloc size calculation. Check for overflow before allocation."
161
+ patterns:
162
+ - "malloc\\s*\\([^)]*\\*[^)]*\\)"
163
+ - "calloc\\s*\\([^)]*\\*[^)]*\\)"
164
+ - "realloc\\s*\\([^,]*,[^)]*\\*[^)]*\\)"
165
+ metadata:
166
+ cwe: "CWE-190"
167
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
168
+ confidence: MEDIUM
169
+ references:
170
+ - https://cwe.mitre.org/data/definitions/190.html
171
+
172
+ # =============================================================================
173
+ # C/C++ SECURITY RULES - Unsafe Functions
174
+ # =============================================================================
175
+
176
+ - id: c.lang.security.audit.scanf-usage
177
+ languages: [c, cpp]
178
+ severity: WARNING
179
+ message: "scanf without width limit can overflow buffer. Use scanf(\"%99s\", buf) with width specifier."
180
+ patterns:
181
+ - "scanf\\s*\\([^)]*%s"
182
+ - "fscanf\\s*\\([^)]*%s"
183
+ - "sscanf\\s*\\([^)]*%s"
184
+ metadata:
185
+ cwe: "CWE-120"
186
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
187
+ confidence: MEDIUM
188
+ references:
189
+ - https://semgrep.dev/r/c.lang.security.insecure-use-scanf
190
+ - https://cwe.mitre.org/data/definitions/120.html
191
+
192
+ - id: c.lang.security.audit.strtok-usage
193
+ languages: [c, cpp]
194
+ severity: WARNING
195
+ message: "strtok is not thread-safe and modifies input. Use strtok_r for thread safety."
196
+ patterns:
197
+ - "\\bstrtok\\s*\\("
198
+ metadata:
199
+ cwe: "CWE-362"
200
+ owasp: "A04:2021 - Insecure Design"
201
+ confidence: MEDIUM
202
+ references:
203
+ - https://semgrep.dev/r/c.lang.security.strtok-use
204
+ - https://man7.org/linux/man-pages/man3/strtok.3.html
205
+
206
+ # =============================================================================
207
+ # C/C++ SECURITY RULES - Command Injection
208
+ # =============================================================================
209
+
210
+ - id: c.lang.security.audit.system-usage
211
+ languages: [c, cpp]
212
+ severity: ERROR
213
+ message: "system() executes shell commands. Avoid with user input or use exec family with arguments."
214
+ patterns:
215
+ - "\\bsystem\\s*\\("
216
+ metadata:
217
+ cwe: "CWE-78"
218
+ owasp: "A03:2021 - Injection"
219
+ confidence: HIGH
220
+ references:
221
+ - https://cwe.mitre.org/data/definitions/78.html
222
+
223
+ - id: c.lang.security.audit.popen-usage
224
+ languages: [c, cpp]
225
+ severity: WARNING
226
+ message: "popen() can be vulnerable to command injection. Validate and sanitize input."
227
+ patterns:
228
+ - "\\bpopen\\s*\\("
229
+ metadata:
230
+ cwe: "CWE-78"
231
+ owasp: "A03:2021 - Injection"
232
+ confidence: MEDIUM
233
+ references:
234
+ - https://cwe.mitre.org/data/definitions/78.html
235
+
236
+ # =============================================================================
237
+ # C/C++ SECURITY RULES - Cryptography
238
+ # =============================================================================
239
+
240
+ - id: c.lang.security.audit.weak-random
241
+ languages: [c, cpp]
242
+ severity: WARNING
243
+ message: "rand() is not cryptographically secure. Use /dev/urandom or platform secure random for security."
244
+ patterns:
245
+ - "\\brand\\s*\\("
246
+ - "\\bsrand\\s*\\("
247
+ metadata:
248
+ cwe: "CWE-330"
249
+ owasp: "A02:2021 - Cryptographic Failures"
250
+ confidence: MEDIUM
251
+ references:
252
+ - https://cwe.mitre.org/data/definitions/330.html
253
+
254
+ - id: c.lang.security.audit.weak-hash-md5
255
+ languages: [c, cpp]
256
+ severity: WARNING
257
+ message: "MD5 is cryptographically broken. Use SHA-256 or stronger for security-sensitive hashing."
258
+ patterns:
259
+ - "MD5_Init\\s*\\("
260
+ - "MD5_Update\\s*\\("
261
+ - "MD5_Final\\s*\\("
262
+ - "MD5\\s*\\("
263
+ metadata:
264
+ cwe: "CWE-328"
265
+ owasp: "A02:2021 - Cryptographic Failures"
266
+ confidence: HIGH
267
+ references:
268
+ - https://cwe.mitre.org/data/definitions/328.html
269
+
270
+ - id: c.lang.security.audit.weak-hash-sha1
271
+ languages: [c, cpp]
272
+ severity: WARNING
273
+ message: "SHA1 is deprecated for security use. Use SHA-256 or stronger."
274
+ patterns:
275
+ - "SHA1_Init\\s*\\("
276
+ - "SHA1_Update\\s*\\("
277
+ - "SHA1_Final\\s*\\("
278
+ - "SHA1\\s*\\("
279
+ metadata:
280
+ cwe: "CWE-328"
281
+ owasp: "A02:2021 - Cryptographic Failures"
282
+ confidence: HIGH
283
+ references:
284
+ - https://cwe.mitre.org/data/definitions/328.html
285
+
286
+ - id: c.lang.security.audit.weak-cipher-des
287
+ languages: [c, cpp]
288
+ severity: ERROR
289
+ message: "DES is a weak cipher. Use AES-256 for encryption."
290
+ patterns:
291
+ - "DES_set_key\\s*\\("
292
+ - "DES_ecb_encrypt\\s*\\("
293
+ - "DES_cbc_encrypt\\s*\\("
294
+ - "EVP_des_"
295
+ metadata:
296
+ cwe: "CWE-327"
297
+ owasp: "A02:2021 - Cryptographic Failures"
298
+ confidence: HIGH
299
+ references:
300
+ - https://cwe.mitre.org/data/definitions/327.html
301
+
302
+ - id: c.lang.security.audit.ecb-mode
303
+ languages: [c, cpp]
304
+ severity: ERROR
305
+ message: "ECB mode is insecure. Use CBC, GCM, or other authenticated modes."
306
+ patterns:
307
+ - "EVP_aes_.*_ecb\\s*\\("
308
+ - "AES_ecb_encrypt\\s*\\("
309
+ - "_ecb\\s*\\("
310
+ metadata:
311
+ cwe: "CWE-327"
312
+ owasp: "A02:2021 - Cryptographic Failures"
313
+ confidence: HIGH
314
+ references:
315
+ - https://cwe.mitre.org/data/definitions/327.html
316
+
317
+ # =============================================================================
318
+ # C/C++ SECURITY RULES - Insecure memset
319
+ # =============================================================================
320
+
321
+ - id: c.lang.security.audit.insecure-memset
322
+ languages: [c, cpp]
323
+ severity: WARNING
324
+ message: "memset may be optimized away by compiler when clearing sensitive data. Use explicit_bzero or volatile."
325
+ patterns:
326
+ - "memset\\s*\\([^,]*password"
327
+ - "memset\\s*\\([^,]*secret"
328
+ - "memset\\s*\\([^,]*key"
329
+ metadata:
330
+ cwe: "CWE-14"
331
+ owasp: "A02:2021 - Cryptographic Failures"
332
+ confidence: MEDIUM
333
+ references:
334
+ - https://semgrep.dev/r/c.lang.security.insecure-use-memset
335
+ - https://cwe.mitre.org/data/definitions/14.html
336
+
337
+ # =============================================================================
338
+ # C/C++ SECURITY RULES - File Descriptor Leaks
339
+ # =============================================================================
340
+
341
+ - id: c.lang.security.audit.fd-leak
342
+ languages: [c, cpp]
343
+ severity: WARNING
344
+ message: "Potential file descriptor leak. Ensure fopen/open calls have matching fclose/close."
345
+ patterns:
346
+ - "fopen\\s*\\([^)]+\\)\\s*;(?![^}]*fclose)"
347
+ - "open\\s*\\([^)]+\\)\\s*;(?![^}]*close)"
348
+ metadata:
349
+ cwe: "CWE-775"
350
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
351
+ confidence: LOW
352
+ references:
353
+ - https://semgrep.dev/r/c.lang.security.fd-leak
354
+ - https://cwe.mitre.org/data/definitions/775.html
355
+
356
+ # =============================================================================
357
+ # C/C++ SECURITY RULES - Hardcoded Credentials
358
+ # =============================================================================
359
+
360
+ - id: c.lang.security.audit.hardcoded-password
361
+ languages: [c, cpp]
362
+ severity: ERROR
363
+ message: "Hardcoded password detected. Use environment variables or secure configuration."
364
+ patterns:
365
+ - "password\\s*=\\s*\"[^\"]{4,}\""
366
+ - "passwd\\s*=\\s*\"[^\"]{4,}\""
367
+ - "secret\\s*=\\s*\"[^\"]{4,}\""
368
+ - "api_key\\s*=\\s*\"[^\"]{20,}\""
369
+ metadata:
370
+ cwe: "CWE-798"
371
+ owasp: "A07:2021 - Identification and Authentication Failures"
372
+ confidence: HIGH
373
+ references:
374
+ - https://cwe.mitre.org/data/definitions/798.html
375
+
376
+ # =============================================================================
377
+ # C++ SPECIFIC SECURITY RULES
378
+ # =============================================================================
379
+
380
+ - id: cpp.lang.security.audit.new-delete-mismatch
381
+ languages: [cpp]
382
+ severity: ERROR
383
+ message: "new/delete mismatch. Use delete[] for arrays allocated with new[]."
384
+ patterns:
385
+ - "new\\s+[a-zA-Z_][a-zA-Z0-9_]*\\s*\\[[^\\]]+\\][^}]*delete\\s+[^\\[]"
386
+ metadata:
387
+ cwe: "CWE-762"
388
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
389
+ confidence: MEDIUM
390
+ references:
391
+ - https://semgrep.dev/r/cpp.lang.security.new-delete-mismatch
392
+ - https://cwe.mitre.org/data/definitions/762.html
393
+
394
+ - id: cpp.lang.security.audit.unsafe-reinterpret-cast
395
+ languages: [cpp]
396
+ severity: WARNING
397
+ message: "reinterpret_cast can lead to undefined behavior. Use safer alternatives when possible."
398
+ patterns:
399
+ - "reinterpret_cast\\s*<"
400
+ metadata:
401
+ cwe: "CWE-704"
402
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
403
+ confidence: LOW
404
+ references:
405
+ - https://isocpp.org/wiki/faq/casts
406
+
407
+ - id: cpp.lang.security.audit.unchecked-return
408
+ languages: [c, cpp]
409
+ severity: WARNING
410
+ message: "Return value not checked. Security-sensitive functions should have return values validated."
411
+ patterns:
412
+ - "\\bfread\\s*\\([^)]+\\)\\s*;"
413
+ - "\\bfwrite\\s*\\([^)]+\\)\\s*;"
414
+ - "\\bread\\s*\\([^)]+\\)\\s*;"
415
+ - "\\bwrite\\s*\\([^)]+\\)\\s*;"
416
+ metadata:
417
+ cwe: "CWE-252"
418
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
419
+ confidence: LOW
420
+ references:
421
+ - https://semgrep.dev/r/c.lang.security.unchecked-return-value
422
+ - https://cwe.mitre.org/data/definitions/252.html
423
+
424
+ # =============================================================================
425
+ # C/C++ SECURITY RULES - Path Traversal
426
+ # =============================================================================
427
+
428
+ - id: c.lang.security.audit.path-traversal
429
+ languages: [c, cpp]
430
+ severity: ERROR
431
+ message: "Potential path traversal. Validate file paths and use realpath() to resolve canonical paths."
432
+ patterns:
433
+ - "fopen\\s*\\([^)]*\\.\\."
434
+ - "open\\s*\\([^)]*\\.\\."
435
+ metadata:
436
+ cwe: "CWE-22"
437
+ owasp: "A01:2021 - Broken Access Control"
438
+ confidence: HIGH
439
+ references:
440
+ - https://cwe.mitre.org/data/definitions/22.html
441
+
442
+ # =============================================================================
443
+ # C/C++ SECURITY RULES - Temporary Files
444
+ # =============================================================================
445
+
446
+ - id: c.lang.security.audit.insecure-tempfile
447
+ languages: [c, cpp]
448
+ severity: WARNING
449
+ message: "mktemp is insecure due to race conditions. Use mkstemp() instead."
450
+ patterns:
451
+ - "\\bmktemp\\s*\\("
452
+ - "\\btmpnam\\s*\\("
453
+ - "\\btempnam\\s*\\("
454
+ metadata:
455
+ cwe: "CWE-377"
456
+ owasp: "A01:2021 - Broken Access Control"
457
+ confidence: HIGH
458
+ references:
459
+ - https://cwe.mitre.org/data/definitions/377.html