agent-security-scanner-mcp 1.1.1 → 1.2.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,400 @@
1
+ rules:
2
+ # =============================================================================
3
+ # RUBY/RAILS SECURITY RULES - SQL Injection
4
+ # =============================================================================
5
+
6
+ - id: ruby.rails.security.audit.sql-injection-where
7
+ languages: [ruby]
8
+ severity: ERROR
9
+ message: "SQL Injection in ActiveRecord where clause. Use parameterized queries: where('column = ?', value)"
10
+ patterns:
11
+ - "\\.where\\s*\\(\\s*[\"'][^\"']*#\\{"
12
+ - "\\.where\\s*\\([^)]*\\+\\s*params"
13
+ - "\\.find_by_sql\\s*\\(\\s*[\"'][^\"']*#\\{"
14
+ metadata:
15
+ cwe: "CWE-89"
16
+ owasp: "A03:2021 - Injection"
17
+ confidence: HIGH
18
+ references:
19
+ - https://rails-sqli.org/
20
+ - https://semgrep.dev/r/ruby.rails.security.brakeman
21
+
22
+ - id: ruby.rails.security.audit.sql-injection-order
23
+ languages: [ruby]
24
+ severity: ERROR
25
+ message: "SQL Injection in order clause. Whitelist allowed columns instead of using user input directly."
26
+ patterns:
27
+ - "\\.order\\s*\\(\\s*params"
28
+ - "\\.order\\s*\\(\\s*[\"'][^\"']*#\\{.*params"
29
+ - "\\.reorder\\s*\\(\\s*params"
30
+ metadata:
31
+ cwe: "CWE-89"
32
+ owasp: "A03:2021 - Injection"
33
+ confidence: HIGH
34
+ references:
35
+ - https://rails-sqli.org/
36
+
37
+ - id: ruby.rails.security.audit.sql-injection-raw
38
+ languages: [ruby]
39
+ severity: ERROR
40
+ message: "Raw SQL with string interpolation. Use sanitize_sql or parameterized queries."
41
+ patterns:
42
+ - "execute\\s*\\(\\s*[\"'][^\"']*#\\{"
43
+ - "select_all\\s*\\(\\s*[\"'][^\"']*#\\{"
44
+ - "connection\\.execute\\s*\\(\\s*[\"'][^\"']*#\\{"
45
+ metadata:
46
+ cwe: "CWE-89"
47
+ owasp: "A03:2021 - Injection"
48
+ confidence: HIGH
49
+ references:
50
+ - https://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html
51
+
52
+ # =============================================================================
53
+ # RUBY/RAILS SECURITY RULES - Command Injection
54
+ # =============================================================================
55
+
56
+ - id: ruby.lang.security.audit.command-injection-system
57
+ languages: [ruby]
58
+ severity: ERROR
59
+ message: "Command Injection detected. User input in system/exec call. Use array form or Shellwords.escape()."
60
+ patterns:
61
+ - "system\\s*\\(\\s*[\"'][^\"']*#\\{.*params"
62
+ - "system\\s*\\([^)]*params\\["
63
+ - "`[^`]*#\\{.*params"
64
+ - "exec\\s*\\(\\s*[\"'][^\"']*#\\{"
65
+ metadata:
66
+ cwe: "CWE-78"
67
+ owasp: "A03:2021 - Injection"
68
+ confidence: HIGH
69
+ references:
70
+ - https://semgrep.dev/r/ruby.lang.security.system-call
71
+
72
+ - id: ruby.lang.security.audit.command-injection-open
73
+ languages: [ruby]
74
+ severity: ERROR
75
+ message: "Command injection via Open3 or IO.popen. Sanitize user input."
76
+ patterns:
77
+ - "Open3\\.(capture|popen|pipeline).*params"
78
+ - "IO\\.popen\\s*\\([^)]*params"
79
+ - "Kernel\\.spawn\\s*\\([^)]*params"
80
+ metadata:
81
+ cwe: "CWE-78"
82
+ owasp: "A03:2021 - Injection"
83
+ confidence: HIGH
84
+ references:
85
+ - https://ruby-doc.org/stdlib/libdoc/open3/rdoc/Open3.html
86
+
87
+ # =============================================================================
88
+ # RUBY/RAILS SECURITY RULES - XSS
89
+ # =============================================================================
90
+
91
+ - id: ruby.rails.security.audit.xss-raw
92
+ languages: [ruby]
93
+ severity: ERROR
94
+ message: "XSS vulnerability. raw() or html_safe bypasses escaping. Sanitize user input first."
95
+ patterns:
96
+ - "raw\\s*\\(\\s*params"
97
+ - "raw\\s*\\([^)]*#\\{.*params"
98
+ - "\\.html_safe"
99
+ - "<%==.*params"
100
+ metadata:
101
+ cwe: "CWE-79"
102
+ owasp: "A03:2021 - Injection"
103
+ confidence: HIGH
104
+ references:
105
+ - https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html
106
+
107
+ - id: ruby.rails.security.audit.xss-content-tag
108
+ languages: [ruby]
109
+ severity: WARNING
110
+ message: "Potential XSS in content_tag. Ensure user input is sanitized."
111
+ patterns:
112
+ - "content_tag\\s*\\([^)]*params\\[.*\\]\\s*,\\s*nil\\s*,.*escape:\\s*false"
113
+ metadata:
114
+ cwe: "CWE-79"
115
+ owasp: "A03:2021 - Injection"
116
+ confidence: MEDIUM
117
+ references:
118
+ - https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html
119
+
120
+ # =============================================================================
121
+ # RUBY/RAILS SECURITY RULES - Mass Assignment
122
+ # =============================================================================
123
+
124
+ - id: ruby.rails.security.audit.mass-assignment-permit-all
125
+ languages: [ruby]
126
+ severity: ERROR
127
+ message: "Mass assignment vulnerability. permit! allows all parameters. Whitelist specific attributes."
128
+ patterns:
129
+ - "params\\.permit!"
130
+ - "\\.permit\\s*\\(.*:all"
131
+ metadata:
132
+ cwe: "CWE-915"
133
+ owasp: "A04:2021 - Insecure Design"
134
+ confidence: HIGH
135
+ references:
136
+ - https://guides.rubyonrails.org/action_controller_overview.html#strong-parameters
137
+
138
+ - id: ruby.rails.security.audit.unscoped-find
139
+ languages: [ruby]
140
+ severity: WARNING
141
+ message: "Unscoped find may expose records from other users. Use scoped queries."
142
+ patterns:
143
+ - "Model\\.find\\s*\\(\\s*params"
144
+ - "\\.find\\s*\\(\\s*params\\[:id\\]\\s*\\)"
145
+ metadata:
146
+ cwe: "CWE-639"
147
+ owasp: "A01:2021 - Broken Access Control"
148
+ confidence: MEDIUM
149
+ references:
150
+ - https://semgrep.dev/r/ruby.rails.security.brakeman.check-unscoped-find
151
+
152
+ # =============================================================================
153
+ # RUBY/RAILS SECURITY RULES - Deserialization
154
+ # =============================================================================
155
+
156
+ - id: ruby.lang.security.audit.unsafe-yaml-load
157
+ languages: [ruby]
158
+ severity: ERROR
159
+ message: "Unsafe YAML deserialization. Use YAML.safe_load() or Psych.safe_load() instead."
160
+ patterns:
161
+ - "YAML\\.load\\s*\\("
162
+ - "Psych\\.load\\s*\\("
163
+ metadata:
164
+ cwe: "CWE-502"
165
+ owasp: "A08:2021 - Software and Data Integrity Failures"
166
+ confidence: HIGH
167
+ references:
168
+ - https://ruby-doc.org/stdlib/libdoc/yaml/rdoc/YAML.html
169
+
170
+ - id: ruby.lang.security.audit.unsafe-marshal
171
+ languages: [ruby]
172
+ severity: ERROR
173
+ message: "Unsafe Marshal deserialization. Marshal.load on untrusted data can lead to RCE."
174
+ patterns:
175
+ - "Marshal\\.load\\s*\\("
176
+ - "Marshal\\.restore\\s*\\("
177
+ metadata:
178
+ cwe: "CWE-502"
179
+ owasp: "A08:2021 - Software and Data Integrity Failures"
180
+ confidence: HIGH
181
+ references:
182
+ - https://ruby-doc.org/core/Marshal.html
183
+
184
+ # =============================================================================
185
+ # RUBY/RAILS SECURITY RULES - Code Injection
186
+ # =============================================================================
187
+
188
+ - id: ruby.lang.security.audit.eval-usage
189
+ languages: [ruby]
190
+ severity: ERROR
191
+ message: "eval() usage detected. Avoid eval() with user input as it allows arbitrary code execution."
192
+ patterns:
193
+ - "\\beval\\s*\\("
194
+ - "instance_eval\\s*\\("
195
+ - "class_eval\\s*\\("
196
+ - "module_eval\\s*\\("
197
+ metadata:
198
+ cwe: "CWE-95"
199
+ owasp: "A03:2021 - Injection"
200
+ confidence: HIGH
201
+ references:
202
+ - https://semgrep.dev/r/ruby.lang.security.eval-usage
203
+
204
+ - id: ruby.lang.security.audit.constantize
205
+ languages: [ruby]
206
+ severity: ERROR
207
+ message: "constantize with user input can instantiate arbitrary classes. Whitelist allowed classes."
208
+ patterns:
209
+ - "params.*\\.constantize"
210
+ - "\\.constantize\\s*\\.new"
211
+ metadata:
212
+ cwe: "CWE-470"
213
+ owasp: "A03:2021 - Injection"
214
+ confidence: HIGH
215
+ references:
216
+ - https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html
217
+
218
+ # =============================================================================
219
+ # RUBY/RAILS SECURITY RULES - Open Redirect
220
+ # =============================================================================
221
+
222
+ - id: ruby.rails.security.audit.open-redirect
223
+ languages: [ruby]
224
+ severity: WARNING
225
+ message: "Open redirect vulnerability. Validate redirect URLs against a whitelist."
226
+ patterns:
227
+ - "redirect_to\\s+params\\["
228
+ - "redirect_to\\s+[^,]*#\\{.*params"
229
+ metadata:
230
+ cwe: "CWE-601"
231
+ owasp: "A01:2021 - Broken Access Control"
232
+ confidence: HIGH
233
+ references:
234
+ - https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html
235
+
236
+ # =============================================================================
237
+ # RUBY/RAILS SECURITY RULES - CSRF
238
+ # =============================================================================
239
+
240
+ - id: ruby.rails.security.audit.csrf-disabled
241
+ languages: [ruby]
242
+ severity: ERROR
243
+ message: "CSRF protection disabled. Do not skip verify_authenticity_token for non-API controllers."
244
+ patterns:
245
+ - "skip_before_action\\s+:verify_authenticity_token"
246
+ - "skip_before_filter\\s+:verify_authenticity_token"
247
+ - "protect_from_forgery.*except:"
248
+ metadata:
249
+ cwe: "CWE-352"
250
+ owasp: "A01:2021 - Broken Access Control"
251
+ confidence: HIGH
252
+ references:
253
+ - https://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf
254
+
255
+ # =============================================================================
256
+ # RUBY/RAILS SECURITY RULES - SSL/TLS
257
+ # =============================================================================
258
+
259
+ - id: ruby.lang.security.audit.ssl-verify-disabled
260
+ languages: [ruby]
261
+ severity: ERROR
262
+ message: "SSL verification disabled. This allows MITM attacks. Enable SSL verification."
263
+ patterns:
264
+ - "verify_mode\\s*=\\s*OpenSSL::SSL::VERIFY_NONE"
265
+ - "ssl_verify_mode:\\s*:verify_none"
266
+ - ":verify_ssl\\s*=>\\s*false"
267
+ metadata:
268
+ cwe: "CWE-295"
269
+ owasp: "A07:2021 - Identification and Authentication Failures"
270
+ confidence: HIGH
271
+ references:
272
+ - https://ruby-doc.org/stdlib/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html
273
+
274
+ # =============================================================================
275
+ # RUBY/RAILS SECURITY RULES - File Operations
276
+ # =============================================================================
277
+
278
+ - id: ruby.lang.security.audit.path-traversal
279
+ languages: [ruby]
280
+ severity: ERROR
281
+ message: "Path traversal vulnerability. User input in file path. Use File.basename() to sanitize."
282
+ patterns:
283
+ - "File\\.(read|open|write|delete)\\s*\\([^)]*params"
284
+ - "FileUtils\\.(rm|mv|cp)\\s*\\([^)]*params"
285
+ - "send_file\\s+params"
286
+ metadata:
287
+ cwe: "CWE-22"
288
+ owasp: "A01:2021 - Broken Access Control"
289
+ confidence: HIGH
290
+ references:
291
+ - https://owasp.org/www-community/attacks/Path_Traversal
292
+
293
+ # =============================================================================
294
+ # RUBY/RAILS SECURITY RULES - Hardcoded Secrets
295
+ # =============================================================================
296
+
297
+ - id: ruby.lang.security.audit.hardcoded-secret
298
+ languages: [ruby]
299
+ severity: ERROR
300
+ message: "Hardcoded secret detected. Use environment variables or Rails credentials."
301
+ patterns:
302
+ - "secret_key_base\\s*=\\s*[\"'][a-f0-9]{30,}[\"']"
303
+ - "api_key\\s*=\\s*[\"'][^\"']{20,}[\"']"
304
+ - "password\\s*=\\s*[\"'][^\"']{4,}[\"']"
305
+ metadata:
306
+ cwe: "CWE-798"
307
+ owasp: "A07:2021 - Identification and Authentication Failures"
308
+ confidence: HIGH
309
+ references:
310
+ - https://guides.rubyonrails.org/security.html#custom-credentials
311
+
312
+ # =============================================================================
313
+ # RUBY/RAILS SECURITY RULES - Session Security
314
+ # =============================================================================
315
+
316
+ - id: ruby.rails.security.audit.session-secret-hardcoded
317
+ languages: [ruby]
318
+ severity: ERROR
319
+ message: "Hardcoded session secret. Use Rails.application.credentials or environment variables."
320
+ patterns:
321
+ - "secret_key_base:\\s*[\"'][a-f0-9]{30,}[\"']"
322
+ - "config\\.secret_key_base\\s*=\\s*[\"'][a-f0-9]{30,}[\"']"
323
+ metadata:
324
+ cwe: "CWE-798"
325
+ owasp: "A07:2021 - Identification and Authentication Failures"
326
+ confidence: HIGH
327
+ references:
328
+ - https://semgrep.dev/r/ruby.rails.security.session-secret
329
+
330
+ # =============================================================================
331
+ # RUBY/RAILS SECURITY RULES - Cryptography
332
+ # =============================================================================
333
+
334
+ - id: ruby.lang.security.audit.weak-hash
335
+ languages: [ruby]
336
+ severity: WARNING
337
+ message: "Weak hash algorithm. Use Digest::SHA256 or stronger for security-sensitive hashing."
338
+ patterns:
339
+ - "Digest::MD5"
340
+ - "Digest::SHA1"
341
+ - "OpenSSL::Digest::MD5"
342
+ - "OpenSSL::Digest::SHA1"
343
+ metadata:
344
+ cwe: "CWE-328"
345
+ owasp: "A02:2021 - Cryptographic Failures"
346
+ confidence: HIGH
347
+ references:
348
+ - https://ruby-doc.org/stdlib/libdoc/digest/rdoc/Digest.html
349
+
350
+ - id: ruby.lang.security.audit.weak-cipher
351
+ languages: [ruby]
352
+ severity: WARNING
353
+ message: "Weak cipher algorithm. Use AES-256-GCM or stronger encryption."
354
+ patterns:
355
+ - "OpenSSL::Cipher\\.new\\s*\\([\"']DES"
356
+ - "OpenSSL::Cipher\\.new\\s*\\([\"']RC4"
357
+ - "OpenSSL::Cipher\\.new\\s*\\([\"'].*ECB"
358
+ metadata:
359
+ cwe: "CWE-327"
360
+ owasp: "A02:2021 - Cryptographic Failures"
361
+ confidence: HIGH
362
+ references:
363
+ - https://ruby-doc.org/stdlib/libdoc/openssl/rdoc/OpenSSL/Cipher.html
364
+
365
+ # =============================================================================
366
+ # RUBY/RAILS SECURITY RULES - Regex DoS
367
+ # =============================================================================
368
+
369
+ - id: ruby.lang.security.audit.regex-dos
370
+ languages: [ruby]
371
+ severity: WARNING
372
+ message: "Potential ReDoS. Regex with nested quantifiers can cause catastrophic backtracking."
373
+ patterns:
374
+ - "/.*\\(.*\\+\\).*\\+/"
375
+ - "/.*\\(.*\\*\\).*\\*/"
376
+ - "Regexp\\.new\\s*\\([^)]*\\+\\).*\\+"
377
+ metadata:
378
+ cwe: "CWE-1333"
379
+ owasp: "A06:2021 - Vulnerable and Outdated Components"
380
+ confidence: MEDIUM
381
+ references:
382
+ - https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
383
+
384
+ # =============================================================================
385
+ # RUBY/RAILS SECURITY RULES - Render Vulnerability
386
+ # =============================================================================
387
+
388
+ - id: ruby.rails.security.audit.render-inline
389
+ languages: [ruby]
390
+ severity: ERROR
391
+ message: "Rendering user input as inline template allows code injection. Use render with safe templates."
392
+ patterns:
393
+ - "render\\s+inline:\\s*params"
394
+ - "render\\s+inline:.*#\\{.*params"
395
+ metadata:
396
+ cwe: "CWE-94"
397
+ owasp: "A03:2021 - Injection"
398
+ confidence: HIGH
399
+ references:
400
+ - https://guides.rubyonrails.org/security.html