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.
- package/README.md +145 -15
- package/analyzer.py +7 -0
- package/index.js +508 -1
- package/package.json +7 -3
- package/rules/agent-attacks.security.yaml +791 -0
- package/rules/c.security.yaml +459 -0
- package/rules/php.security.yaml +461 -0
- package/rules/prompt-injection.security.yaml +684 -0
- package/rules/ruby.security.yaml +400 -0
- package/rules/terraform.security.yaml +505 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
rules:
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# PHP SECURITY RULES - SQL Injection
|
|
4
|
+
# =============================================================================
|
|
5
|
+
|
|
6
|
+
- id: php.lang.security.audit.sql-injection-query
|
|
7
|
+
languages: [php]
|
|
8
|
+
severity: ERROR
|
|
9
|
+
message: "SQL Injection detected. User input flows into SQL query. Use prepared statements with PDO or mysqli."
|
|
10
|
+
patterns:
|
|
11
|
+
- "\\$.*->query\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
12
|
+
- "mysql_query\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
13
|
+
- "mysqli_query\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
14
|
+
- "pg_query\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
15
|
+
metadata:
|
|
16
|
+
cwe: "CWE-89"
|
|
17
|
+
owasp: "A03:2021 - Injection"
|
|
18
|
+
confidence: HIGH
|
|
19
|
+
likelihood: HIGH
|
|
20
|
+
impact: HIGH
|
|
21
|
+
references:
|
|
22
|
+
- https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
|
|
23
|
+
|
|
24
|
+
- id: php.lang.security.audit.sql-injection-sprintf
|
|
25
|
+
languages: [php]
|
|
26
|
+
severity: ERROR
|
|
27
|
+
message: "SQL Injection via sprintf. Use prepared statements instead of string formatting."
|
|
28
|
+
patterns:
|
|
29
|
+
- "sprintf\\s*\\(\\s*[\"']\\s*(SELECT|INSERT|UPDATE|DELETE|DROP)"
|
|
30
|
+
- "\\$sql\\s*=\\s*[\"'][^\"']*\\$"
|
|
31
|
+
metadata:
|
|
32
|
+
cwe: "CWE-89"
|
|
33
|
+
owasp: "A03:2021 - Injection"
|
|
34
|
+
confidence: MEDIUM
|
|
35
|
+
references:
|
|
36
|
+
- https://semgrep.dev/r/php.lang.security.injection.tainted-sql-string
|
|
37
|
+
|
|
38
|
+
# =============================================================================
|
|
39
|
+
# PHP SECURITY RULES - Command Injection
|
|
40
|
+
# =============================================================================
|
|
41
|
+
|
|
42
|
+
- id: php.lang.security.audit.command-injection-exec
|
|
43
|
+
languages: [php]
|
|
44
|
+
severity: ERROR
|
|
45
|
+
message: "Command Injection detected. User input flows into exec/system/shell_exec. Use escapeshellarg() or escapeshellcmd()."
|
|
46
|
+
patterns:
|
|
47
|
+
- "exec\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
48
|
+
- "system\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
49
|
+
- "shell_exec\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
50
|
+
- "passthru\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
51
|
+
- "popen\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
52
|
+
- "proc_open\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
53
|
+
metadata:
|
|
54
|
+
cwe: "CWE-78"
|
|
55
|
+
owasp: "A03:2021 - Injection"
|
|
56
|
+
confidence: HIGH
|
|
57
|
+
likelihood: HIGH
|
|
58
|
+
impact: HIGH
|
|
59
|
+
references:
|
|
60
|
+
- https://semgrep.dev/r/php.lang.security.injection.tainted-exec
|
|
61
|
+
|
|
62
|
+
- id: php.lang.security.audit.backticks-exec
|
|
63
|
+
languages: [php]
|
|
64
|
+
severity: ERROR
|
|
65
|
+
message: "Command execution via backticks detected. Use escapeshellarg() for user input."
|
|
66
|
+
patterns:
|
|
67
|
+
- "`[^`]*\\$_(GET|POST|REQUEST|COOKIE)[^`]*`"
|
|
68
|
+
- "`[^`]*\\$[a-zA-Z_][^`]*`"
|
|
69
|
+
metadata:
|
|
70
|
+
cwe: "CWE-78"
|
|
71
|
+
owasp: "A03:2021 - Injection"
|
|
72
|
+
confidence: MEDIUM
|
|
73
|
+
references:
|
|
74
|
+
- https://semgrep.dev/r/php.lang.security.audit.backticks-use
|
|
75
|
+
|
|
76
|
+
# =============================================================================
|
|
77
|
+
# PHP SECURITY RULES - Code Injection
|
|
78
|
+
# =============================================================================
|
|
79
|
+
|
|
80
|
+
- id: php.lang.security.audit.eval-usage
|
|
81
|
+
languages: [php]
|
|
82
|
+
severity: ERROR
|
|
83
|
+
message: "eval() usage detected. Avoid eval() as it can execute arbitrary code."
|
|
84
|
+
patterns:
|
|
85
|
+
- "\\beval\\s*\\("
|
|
86
|
+
metadata:
|
|
87
|
+
cwe: "CWE-95"
|
|
88
|
+
owasp: "A03:2021 - Injection"
|
|
89
|
+
confidence: HIGH
|
|
90
|
+
references:
|
|
91
|
+
- https://semgrep.dev/r/php.lang.security.audit.eval-use
|
|
92
|
+
|
|
93
|
+
- id: php.lang.security.audit.assert-usage
|
|
94
|
+
languages: [php]
|
|
95
|
+
severity: WARNING
|
|
96
|
+
message: "assert() with string argument can execute code. Use boolean expressions instead."
|
|
97
|
+
patterns:
|
|
98
|
+
- "assert\\s*\\(\\s*[\"']"
|
|
99
|
+
- "assert\\s*\\(\\s*\\$"
|
|
100
|
+
metadata:
|
|
101
|
+
cwe: "CWE-95"
|
|
102
|
+
owasp: "A03:2021 - Injection"
|
|
103
|
+
confidence: MEDIUM
|
|
104
|
+
references:
|
|
105
|
+
- https://semgrep.dev/r/php.lang.security.audit.assert-use
|
|
106
|
+
|
|
107
|
+
- id: php.lang.security.audit.preg-code-exec
|
|
108
|
+
languages: [php]
|
|
109
|
+
severity: ERROR
|
|
110
|
+
message: "preg_replace with /e modifier allows code execution. Use preg_replace_callback() instead."
|
|
111
|
+
patterns:
|
|
112
|
+
- "preg_replace\\s*\\(\\s*[\"']/[^/]*/[a-z]*e"
|
|
113
|
+
metadata:
|
|
114
|
+
cwe: "CWE-95"
|
|
115
|
+
owasp: "A03:2021 - Injection"
|
|
116
|
+
confidence: HIGH
|
|
117
|
+
references:
|
|
118
|
+
- https://owasp.org/www-community/attacks/Code_Injection
|
|
119
|
+
|
|
120
|
+
# =============================================================================
|
|
121
|
+
# PHP SECURITY RULES - File Inclusion
|
|
122
|
+
# =============================================================================
|
|
123
|
+
|
|
124
|
+
- id: php.lang.security.audit.file-inclusion
|
|
125
|
+
languages: [php]
|
|
126
|
+
severity: ERROR
|
|
127
|
+
message: "File inclusion vulnerability. User input used in include/require. Validate and sanitize file paths."
|
|
128
|
+
patterns:
|
|
129
|
+
- "include\\s*\\(?\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
130
|
+
- "include_once\\s*\\(?\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
131
|
+
- "require\\s*\\(?\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
132
|
+
- "require_once\\s*\\(?\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
133
|
+
metadata:
|
|
134
|
+
cwe: "CWE-98"
|
|
135
|
+
owasp: "A03:2021 - Injection"
|
|
136
|
+
confidence: HIGH
|
|
137
|
+
likelihood: HIGH
|
|
138
|
+
impact: HIGH
|
|
139
|
+
references:
|
|
140
|
+
- https://semgrep.dev/r/php.lang.security.audit.file-inclusion
|
|
141
|
+
|
|
142
|
+
# =============================================================================
|
|
143
|
+
# PHP SECURITY RULES - XSS
|
|
144
|
+
# =============================================================================
|
|
145
|
+
|
|
146
|
+
- id: php.lang.security.audit.xss-echo
|
|
147
|
+
languages: [php]
|
|
148
|
+
severity: ERROR
|
|
149
|
+
message: "XSS vulnerability. User input echoed without escaping. Use htmlspecialchars() or htmlentities()."
|
|
150
|
+
patterns:
|
|
151
|
+
- "echo\\s+\\$_(GET|POST|REQUEST|COOKIE)"
|
|
152
|
+
- "print\\s+\\$_(GET|POST|REQUEST|COOKIE)"
|
|
153
|
+
- "print_r\\s*\\(\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
154
|
+
- "<\\?=\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
155
|
+
metadata:
|
|
156
|
+
cwe: "CWE-79"
|
|
157
|
+
owasp: "A03:2021 - Injection"
|
|
158
|
+
confidence: HIGH
|
|
159
|
+
references:
|
|
160
|
+
- https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
|
|
161
|
+
|
|
162
|
+
# =============================================================================
|
|
163
|
+
# PHP SECURITY RULES - Deserialization
|
|
164
|
+
# =============================================================================
|
|
165
|
+
|
|
166
|
+
- id: php.lang.security.audit.unsafe-unserialize
|
|
167
|
+
languages: [php]
|
|
168
|
+
severity: ERROR
|
|
169
|
+
message: "Unsafe deserialization detected. unserialize() on user input can lead to RCE. Use JSON instead."
|
|
170
|
+
patterns:
|
|
171
|
+
- "unserialize\\s*\\(\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
172
|
+
- "unserialize\\s*\\(\\s*file_get_contents"
|
|
173
|
+
- "unserialize\\s*\\(\\s*\\$"
|
|
174
|
+
metadata:
|
|
175
|
+
cwe: "CWE-502"
|
|
176
|
+
owasp: "A08:2021 - Software and Data Integrity Failures"
|
|
177
|
+
confidence: HIGH
|
|
178
|
+
likelihood: HIGH
|
|
179
|
+
impact: HIGH
|
|
180
|
+
references:
|
|
181
|
+
- https://semgrep.dev/r/php.lang.security.audit.unserialize-use
|
|
182
|
+
|
|
183
|
+
# =============================================================================
|
|
184
|
+
# PHP SECURITY RULES - Cryptography
|
|
185
|
+
# =============================================================================
|
|
186
|
+
|
|
187
|
+
- id: php.lang.security.audit.weak-hash-md5
|
|
188
|
+
languages: [php]
|
|
189
|
+
severity: WARNING
|
|
190
|
+
message: "MD5 is cryptographically weak. Use password_hash() for passwords or hash('sha256', ...) for checksums."
|
|
191
|
+
patterns:
|
|
192
|
+
- "\\bmd5\\s*\\("
|
|
193
|
+
- "hash\\s*\\(\\s*[\"']md5[\"']"
|
|
194
|
+
metadata:
|
|
195
|
+
cwe: "CWE-328"
|
|
196
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
197
|
+
confidence: HIGH
|
|
198
|
+
references:
|
|
199
|
+
- https://semgrep.dev/r/php.lang.security.audit.md5-used-as-password
|
|
200
|
+
|
|
201
|
+
- id: php.lang.security.audit.weak-hash-sha1
|
|
202
|
+
languages: [php]
|
|
203
|
+
severity: WARNING
|
|
204
|
+
message: "SHA1 is cryptographically weak. Use hash('sha256', ...) or stronger algorithms."
|
|
205
|
+
patterns:
|
|
206
|
+
- "\\bsha1\\s*\\("
|
|
207
|
+
- "hash\\s*\\(\\s*[\"']sha1[\"']"
|
|
208
|
+
metadata:
|
|
209
|
+
cwe: "CWE-328"
|
|
210
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
211
|
+
confidence: HIGH
|
|
212
|
+
references:
|
|
213
|
+
- https://owasp.org/www-project-web-security-testing-guide/
|
|
214
|
+
|
|
215
|
+
- id: php.lang.security.audit.mcrypt-deprecated
|
|
216
|
+
languages: [php]
|
|
217
|
+
severity: WARNING
|
|
218
|
+
message: "mcrypt is deprecated and removed in PHP 7.2+. Use OpenSSL instead."
|
|
219
|
+
patterns:
|
|
220
|
+
- "mcrypt_encrypt\\s*\\("
|
|
221
|
+
- "mcrypt_decrypt\\s*\\("
|
|
222
|
+
- "mcrypt_create_iv\\s*\\("
|
|
223
|
+
metadata:
|
|
224
|
+
cwe: "CWE-327"
|
|
225
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
226
|
+
confidence: HIGH
|
|
227
|
+
references:
|
|
228
|
+
- https://semgrep.dev/r/php.lang.security.audit.mcrypt-use
|
|
229
|
+
|
|
230
|
+
- id: php.lang.security.audit.weak-random
|
|
231
|
+
languages: [php]
|
|
232
|
+
severity: WARNING
|
|
233
|
+
message: "Weak random number generator. Use random_bytes() or random_int() for security-sensitive operations."
|
|
234
|
+
patterns:
|
|
235
|
+
- "\\brand\\s*\\("
|
|
236
|
+
- "\\bmt_rand\\s*\\("
|
|
237
|
+
- "\\bsrand\\s*\\("
|
|
238
|
+
- "\\bmt_srand\\s*\\("
|
|
239
|
+
metadata:
|
|
240
|
+
cwe: "CWE-330"
|
|
241
|
+
owasp: "A02:2021 - Cryptographic Failures"
|
|
242
|
+
confidence: MEDIUM
|
|
243
|
+
references:
|
|
244
|
+
- https://www.php.net/manual/en/function.random-int.php
|
|
245
|
+
|
|
246
|
+
# =============================================================================
|
|
247
|
+
# PHP SECURITY RULES - SSL/TLS
|
|
248
|
+
# =============================================================================
|
|
249
|
+
|
|
250
|
+
- id: php.lang.security.audit.curl-ssl-disabled
|
|
251
|
+
languages: [php]
|
|
252
|
+
severity: ERROR
|
|
253
|
+
message: "SSL verification disabled in cURL. This allows MITM attacks. Set CURLOPT_SSL_VERIFYPEER to true."
|
|
254
|
+
patterns:
|
|
255
|
+
- "CURLOPT_SSL_VERIFYPEER\\s*,\\s*(false|0|FALSE)"
|
|
256
|
+
- "CURLOPT_SSL_VERIFYHOST\\s*,\\s*(false|0|FALSE)"
|
|
257
|
+
metadata:
|
|
258
|
+
cwe: "CWE-295"
|
|
259
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
260
|
+
confidence: HIGH
|
|
261
|
+
references:
|
|
262
|
+
- https://semgrep.dev/r/php.lang.security.audit.curl-ssl-verifypeer-off
|
|
263
|
+
|
|
264
|
+
# =============================================================================
|
|
265
|
+
# PHP SECURITY RULES - SSRF
|
|
266
|
+
# =============================================================================
|
|
267
|
+
|
|
268
|
+
- id: php.lang.security.audit.ssrf
|
|
269
|
+
languages: [php]
|
|
270
|
+
severity: ERROR
|
|
271
|
+
message: "SSRF vulnerability. User input used in URL fetch. Validate and whitelist URLs."
|
|
272
|
+
patterns:
|
|
273
|
+
- "file_get_contents\\s*\\(\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
274
|
+
- "curl_setopt\\s*\\([^,]*,\\s*CURLOPT_URL\\s*,\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
275
|
+
- "fopen\\s*\\(\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
276
|
+
metadata:
|
|
277
|
+
cwe: "CWE-918"
|
|
278
|
+
owasp: "A10:2021 - Server-Side Request Forgery"
|
|
279
|
+
confidence: HIGH
|
|
280
|
+
references:
|
|
281
|
+
- https://semgrep.dev/r/php.lang.security.audit.php-ssrf
|
|
282
|
+
|
|
283
|
+
# =============================================================================
|
|
284
|
+
# PHP SECURITY RULES - Path Traversal
|
|
285
|
+
# =============================================================================
|
|
286
|
+
|
|
287
|
+
- id: php.lang.security.audit.path-traversal
|
|
288
|
+
languages: [php]
|
|
289
|
+
severity: ERROR
|
|
290
|
+
message: "Path traversal vulnerability. User input in file path. Use basename() and validate paths."
|
|
291
|
+
patterns:
|
|
292
|
+
- "file_get_contents\\s*\\([^)]*\\.\\./"
|
|
293
|
+
- "fopen\\s*\\([^)]*\\.\\./"
|
|
294
|
+
- "readfile\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
295
|
+
- "file_put_contents\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
296
|
+
metadata:
|
|
297
|
+
cwe: "CWE-22"
|
|
298
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
299
|
+
confidence: HIGH
|
|
300
|
+
references:
|
|
301
|
+
- https://owasp.org/www-community/attacks/Path_Traversal
|
|
302
|
+
|
|
303
|
+
# =============================================================================
|
|
304
|
+
# PHP SECURITY RULES - Open Redirect
|
|
305
|
+
# =============================================================================
|
|
306
|
+
|
|
307
|
+
- id: php.lang.security.audit.open-redirect
|
|
308
|
+
languages: [php]
|
|
309
|
+
severity: WARNING
|
|
310
|
+
message: "Open redirect vulnerability. User input in redirect. Validate redirect URLs against whitelist."
|
|
311
|
+
patterns:
|
|
312
|
+
- "header\\s*\\(\\s*[\"']Location:\\s*[\"']\\s*\\.\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
313
|
+
- "header\\s*\\(\\s*[\"']Location:\\s*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
314
|
+
metadata:
|
|
315
|
+
cwe: "CWE-601"
|
|
316
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
317
|
+
confidence: HIGH
|
|
318
|
+
references:
|
|
319
|
+
- https://semgrep.dev/r/php.lang.security.audit.redirect-to-request-uri
|
|
320
|
+
|
|
321
|
+
# =============================================================================
|
|
322
|
+
# PHP SECURITY RULES - LDAP Injection
|
|
323
|
+
# =============================================================================
|
|
324
|
+
|
|
325
|
+
- id: php.lang.security.audit.ldap-injection
|
|
326
|
+
languages: [php]
|
|
327
|
+
severity: ERROR
|
|
328
|
+
message: "LDAP Injection detected. User input in LDAP query. Escape special characters."
|
|
329
|
+
patterns:
|
|
330
|
+
- "ldap_search\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
331
|
+
- "ldap_bind\\s*\\([^)]*\\$_(GET|POST|REQUEST|COOKIE)"
|
|
332
|
+
metadata:
|
|
333
|
+
cwe: "CWE-90"
|
|
334
|
+
owasp: "A03:2021 - Injection"
|
|
335
|
+
confidence: HIGH
|
|
336
|
+
references:
|
|
337
|
+
- https://cheatsheetseries.owasp.org/cheatsheets/LDAP_Injection_Prevention_Cheat_Sheet.html
|
|
338
|
+
|
|
339
|
+
# =============================================================================
|
|
340
|
+
# PHP SECURITY RULES - XXE
|
|
341
|
+
# =============================================================================
|
|
342
|
+
|
|
343
|
+
- id: php.lang.security.audit.xxe
|
|
344
|
+
languages: [php]
|
|
345
|
+
severity: ERROR
|
|
346
|
+
message: "XXE vulnerability. External entities enabled in XML parsing. Use libxml_disable_entity_loader(true)."
|
|
347
|
+
patterns:
|
|
348
|
+
- "simplexml_load_string\\s*\\("
|
|
349
|
+
- "simplexml_load_file\\s*\\("
|
|
350
|
+
- "DOMDocument\\s*\\(\\)->loadXML"
|
|
351
|
+
- "new\\s+SimpleXMLElement\\s*\\("
|
|
352
|
+
metadata:
|
|
353
|
+
cwe: "CWE-611"
|
|
354
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
355
|
+
confidence: MEDIUM
|
|
356
|
+
references:
|
|
357
|
+
- https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html
|
|
358
|
+
|
|
359
|
+
# =============================================================================
|
|
360
|
+
# PHP SECURITY RULES - Hardcoded Credentials
|
|
361
|
+
# =============================================================================
|
|
362
|
+
|
|
363
|
+
- id: php.lang.security.audit.hardcoded-password
|
|
364
|
+
languages: [php]
|
|
365
|
+
severity: ERROR
|
|
366
|
+
message: "Hardcoded password detected. Use environment variables or secure configuration."
|
|
367
|
+
patterns:
|
|
368
|
+
- "\\$password\\s*=\\s*[\"'][^\"']{4,}[\"']"
|
|
369
|
+
- "\\$pass\\s*=\\s*[\"'][^\"']{4,}[\"']"
|
|
370
|
+
- "\\$pwd\\s*=\\s*[\"'][^\"']{4,}[\"']"
|
|
371
|
+
- "\\$secret\\s*=\\s*[\"'][^\"']{4,}[\"']"
|
|
372
|
+
- "'password'\\s*=>\\s*[\"'][^\"']{4,}[\"']"
|
|
373
|
+
metadata:
|
|
374
|
+
cwe: "CWE-798"
|
|
375
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
376
|
+
confidence: MEDIUM
|
|
377
|
+
references:
|
|
378
|
+
- https://semgrep.dev/r/php.lang.security.audit.hardcoded-credentials
|
|
379
|
+
|
|
380
|
+
- id: php.lang.security.audit.hardcoded-api-key
|
|
381
|
+
languages: [php]
|
|
382
|
+
severity: ERROR
|
|
383
|
+
message: "Hardcoded API key detected. Use environment variables."
|
|
384
|
+
patterns:
|
|
385
|
+
- "\\$api_key\\s*=\\s*[\"'][a-zA-Z0-9_-]{20,}[\"']"
|
|
386
|
+
- "\\$apiKey\\s*=\\s*[\"'][a-zA-Z0-9_-]{20,}[\"']"
|
|
387
|
+
- "'api_key'\\s*=>\\s*[\"'][a-zA-Z0-9_-]{20,}[\"']"
|
|
388
|
+
- "Authorization.*Bearer\\s+[a-zA-Z0-9_-]{20,}"
|
|
389
|
+
metadata:
|
|
390
|
+
cwe: "CWE-798"
|
|
391
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
392
|
+
confidence: HIGH
|
|
393
|
+
references:
|
|
394
|
+
- https://owasp.org/www-project-web-security-testing-guide/
|
|
395
|
+
|
|
396
|
+
# =============================================================================
|
|
397
|
+
# PHP SECURITY RULES - Information Disclosure
|
|
398
|
+
# =============================================================================
|
|
399
|
+
|
|
400
|
+
- id: php.lang.security.audit.phpinfo-exposure
|
|
401
|
+
languages: [php]
|
|
402
|
+
severity: WARNING
|
|
403
|
+
message: "phpinfo() exposes sensitive server information. Remove from production code."
|
|
404
|
+
patterns:
|
|
405
|
+
- "\\bphpinfo\\s*\\("
|
|
406
|
+
metadata:
|
|
407
|
+
cwe: "CWE-200"
|
|
408
|
+
owasp: "A01:2021 - Broken Access Control"
|
|
409
|
+
confidence: HIGH
|
|
410
|
+
references:
|
|
411
|
+
- https://semgrep.dev/r/php.lang.security.audit.phpinfo-use
|
|
412
|
+
|
|
413
|
+
- id: php.lang.security.audit.error-display
|
|
414
|
+
languages: [php]
|
|
415
|
+
severity: WARNING
|
|
416
|
+
message: "Error display enabled. Disable display_errors in production to prevent information leakage."
|
|
417
|
+
patterns:
|
|
418
|
+
- "ini_set\\s*\\(\\s*[\"']display_errors[\"']\\s*,\\s*[\"']?(1|on|true)[\"']?\\s*\\)"
|
|
419
|
+
- "error_reporting\\s*\\(\\s*E_ALL\\s*\\)"
|
|
420
|
+
metadata:
|
|
421
|
+
cwe: "CWE-209"
|
|
422
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
423
|
+
confidence: HIGH
|
|
424
|
+
references:
|
|
425
|
+
- https://www.php.net/manual/en/errorfunc.configuration.php
|
|
426
|
+
|
|
427
|
+
# =============================================================================
|
|
428
|
+
# PHP SECURITY RULES - CORS
|
|
429
|
+
# =============================================================================
|
|
430
|
+
|
|
431
|
+
- id: php.lang.security.audit.permissive-cors
|
|
432
|
+
languages: [php]
|
|
433
|
+
severity: WARNING
|
|
434
|
+
message: "Permissive CORS configuration. Wildcard origin allows any site to make requests."
|
|
435
|
+
patterns:
|
|
436
|
+
- "header\\s*\\(\\s*[\"']Access-Control-Allow-Origin:\\s*\\*[\"']\\s*\\)"
|
|
437
|
+
- "Access-Control-Allow-Origin.*\\*"
|
|
438
|
+
metadata:
|
|
439
|
+
cwe: "CWE-942"
|
|
440
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
441
|
+
confidence: HIGH
|
|
442
|
+
references:
|
|
443
|
+
- https://semgrep.dev/r/php.lang.security.audit.php-permissive-cors
|
|
444
|
+
|
|
445
|
+
# =============================================================================
|
|
446
|
+
# PHP SECURITY RULES - Session Security
|
|
447
|
+
# =============================================================================
|
|
448
|
+
|
|
449
|
+
- id: php.lang.security.audit.session-fixation
|
|
450
|
+
languages: [php]
|
|
451
|
+
severity: WARNING
|
|
452
|
+
message: "Potential session fixation. Regenerate session ID after authentication with session_regenerate_id(true)."
|
|
453
|
+
patterns:
|
|
454
|
+
- "\\$_SESSION\\s*\\[[\"']user[\"']\\]\\s*="
|
|
455
|
+
- "\\$_SESSION\\s*\\[[\"']logged_in[\"']\\]\\s*=\\s*true"
|
|
456
|
+
metadata:
|
|
457
|
+
cwe: "CWE-384"
|
|
458
|
+
owasp: "A07:2021 - Identification and Authentication Failures"
|
|
459
|
+
confidence: LOW
|
|
460
|
+
references:
|
|
461
|
+
- https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
|