deepscan-cli 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.
Files changed (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +419 -0
  3. package/dist/bin/deepscan.d.ts +1 -0
  4. package/dist/bin/deepscan.js +393 -0
  5. package/dist/bin/deepscan.js.map +1 -0
  6. package/dist/chunk-OSYJXVNF.js +7268 -0
  7. package/dist/chunk-OSYJXVNF.js.map +1 -0
  8. package/dist/index.d.ts +470 -0
  9. package/dist/index.js +21 -0
  10. package/dist/index.js.map +1 -0
  11. package/package.json +68 -0
  12. package/rules/built-in/converted-semgrep.yml +37 -0
  13. package/rules/built-in/default-config.yml +59 -0
  14. package/rules/built-in/quality.yml +117 -0
  15. package/rules/built-in/security.yml +383 -0
  16. package/rules/built-in/semgrep-apex.yml +336 -0
  17. package/rules/built-in/semgrep-bash.yml +362 -0
  18. package/rules/built-in/semgrep-c.yml +429 -0
  19. package/rules/built-in/semgrep-clojure.yml +166 -0
  20. package/rules/built-in/semgrep-csharp.yml +1260 -0
  21. package/rules/built-in/semgrep-dart.yml +21 -0
  22. package/rules/built-in/semgrep-dockerfile.yml +874 -0
  23. package/rules/built-in/semgrep-elixir.yml +146 -0
  24. package/rules/built-in/semgrep-generic.yml +2945 -0
  25. package/rules/built-in/semgrep-go.yml +2898 -0
  26. package/rules/built-in/semgrep-hcl.yml +8181 -0
  27. package/rules/built-in/semgrep-html.yml +94 -0
  28. package/rules/built-in/semgrep-java.yml +4219 -0
  29. package/rules/built-in/semgrep-javascript.yml +6243 -0
  30. package/rules/built-in/semgrep-json.yml +360 -0
  31. package/rules/built-in/semgrep-kotlin.yml +540 -0
  32. package/rules/built-in/semgrep-lua.yml +46 -0
  33. package/rules/built-in/semgrep-ocaml.yml +773 -0
  34. package/rules/built-in/semgrep-php.yml +1638 -0
  35. package/rules/built-in/semgrep-python.yml +11240 -0
  36. package/rules/built-in/semgrep-regex.yml +6444 -0
  37. package/rules/built-in/semgrep-ruby.yml +2687 -0
  38. package/rules/built-in/semgrep-rust.yml +278 -0
  39. package/rules/built-in/semgrep-scala.yml +807 -0
  40. package/rules/built-in/semgrep-sh.yml +46 -0
  41. package/rules/built-in/semgrep-solidity.yml +1046 -0
  42. package/rules/built-in/semgrep-swift.yml +200 -0
  43. package/rules/built-in/semgrep-terraform.yml +147 -0
  44. package/rules/built-in/semgrep-typescript.yml +6212 -0
  45. package/rules/built-in/semgrep-xml.yml +31 -0
  46. package/rules/built-in/semgrep-yaml.yml +2785 -0
  47. package/rules/examples/custom-api-security.yml +66 -0
@@ -0,0 +1,2687 @@
1
+ rules:
2
+ - id: anthropic-hardcoded-api-key-ruby
3
+ name: anthropic-hardcoded-api-key-ruby
4
+ description: Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
5
+ category: secrets
6
+ severity: high
7
+ confidence: medium
8
+ languages:
9
+ - ruby
10
+ patterns:
11
+ - pattern: |
12
+ Anthropic::Client.new(api_key: "$KEY", ...)
13
+ message: Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
14
+ cwe:
15
+ - CWE-798
16
+ owasp: []
17
+ references:
18
+ - https://docs.anthropic.com/en/docs/initial-setup
19
+ tags:
20
+ - anthropic
21
+ - id: llm-api-key-in-source-ruby
22
+ name: llm-api-key-in-source-ruby
23
+ description: >-
24
+ AI/LLM API key found hardcoded in source code. Detected key prefix matches a known AI provider (OpenAI, Anthropic,
25
+ Google, Hugging Face). Use environment variables or a secrets manager instead.
26
+ category: injection
27
+ severity: high
28
+ confidence: medium
29
+ languages:
30
+ - ruby
31
+ patterns:
32
+ - pattern: $VAR = "$KEY"
33
+ message: >-
34
+ AI/LLM API key found hardcoded in source code. Detected key prefix matches a known AI provider (OpenAI,
35
+ Anthropic, Google, Hugging Face). Use environment variables or a secrets manager instead.
36
+ cwe:
37
+ - CWE-798
38
+ owasp: []
39
+ references:
40
+ - https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/
41
+ tags:
42
+ - openai
43
+ - anthropic
44
+ - google
45
+ - huggingface
46
+ - id: openai-hardcoded-api-key-ruby
47
+ name: openai-hardcoded-api-key-ruby
48
+ description: OpenAI API key is hardcoded in source code. Use environment variables or a secrets manager instead.
49
+ category: secrets
50
+ severity: high
51
+ confidence: medium
52
+ languages:
53
+ - ruby
54
+ patterns:
55
+ - pattern: |
56
+ OpenAI::Client.new(access_token: "$KEY", ...)
57
+ message: OpenAI API key is hardcoded in source code. Use environment variables or a secrets manager instead.
58
+ cwe:
59
+ - CWE-798
60
+ owasp: []
61
+ references:
62
+ - https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
63
+ tags:
64
+ - openai
65
+ - id: contains-bidirectional-characters
66
+ name: contains-bidirectional-characters
67
+ description: >-
68
+ This code contains bidirectional (bidi) characters. While this is useful for support of right-to-left languages
69
+ such as Arabic or Hebrew, it can also be used to trick language parsers into executing code in a manner that is
70
+ different from how it is displayed in code editing and review tools. If this is not what you were expecting,
71
+ please review this code in an editor that can reveal hidden Unicode characters.
72
+ category: security
73
+ severity: medium
74
+ confidence: medium
75
+ languages:
76
+ - bash
77
+ - c
78
+ - csharp
79
+ - go
80
+ - java
81
+ - javascript
82
+ - json
83
+ - kotlin
84
+ - lua
85
+ - ocaml
86
+ - php
87
+ - python
88
+ - ruby
89
+ - rust
90
+ - scala
91
+ - sh
92
+ - typescript
93
+ - yaml
94
+ patterns:
95
+ - regex: .*
96
+ message: >-
97
+ This code contains bidirectional (bidi) characters. While this is useful for support of right-to-left
98
+ languages such as Arabic or Hebrew, it can also be used to trick language parsers into executing code in a
99
+ manner that is different from how it is displayed in code editing and review tools. If this is not what you
100
+ were expecting, please review this code in an editor that can reveal hidden Unicode characters.
101
+ cwe:
102
+ - CWE-94
103
+ owasp:
104
+ - A03:2021
105
+ - A05:2025
106
+ references:
107
+ - https://trojansource.codes/
108
+ tags:
109
+ - unicode
110
+ - id: bundler-gemfile-missing-cooldown
111
+ name: bundler-gemfile-missing-cooldown
112
+ description: >-
113
+ A Gemfile `source` declaration without a `cooldown` (or with a cooldown below 7 days) allows Bundler to resolve
114
+ newly published gem versions immediately, before the community has had time to detect malicious releases. The May
115
+ 2026 RubyGems supply-chain attack demonstrated that threat actors can push compromised gem versions and have them
116
+ automatically pulled into builds within minutes. Add `cooldown: 7` to each public source declaration so Bundler
117
+ ignores gem versions published within the last 7 days during dependency resolution (e.g. `source
118
+ "https://rubygems.org", cooldown: 7`). If you operate an internal or private registry where the supply-chain risk
119
+ is lower, use `cooldown: 0` as an explicit bypass. Note: this feature requires Bundler >= 4.0.13. Cooldown only
120
+ applies during `bundle update` and `bundle add`; `bundle install` with an existing lockfile is unaffected.
121
+ category: file-ops
122
+ severity: medium
123
+ confidence: medium
124
+ languages:
125
+ - ruby
126
+ patterns:
127
+ - regex: .*
128
+ message: >-
129
+ A Gemfile `source` declaration without a `cooldown` (or with a cooldown below 7 days) allows Bundler to
130
+ resolve newly published gem versions immediately, before the community has had time to detect malicious
131
+ releases. The May 2026 RubyGems supply-chain attack demonstrated that threat actors can push compromised gem
132
+ versions and have them automatically pulled into builds within minutes. Add `cooldown: 7` to each public
133
+ source declaration so Bundler ignores gem versions published within the last 7 days during dependency
134
+ resolution (e.g. `source "https://rubygems.org", cooldown: 7`). If you operate an internal or private registry
135
+ where the supply-chain risk is lower, use `cooldown: 0` as an explicit bypass. Note: this feature requires
136
+ Bundler >= 4.0.13. Cooldown only applies during `bundle update` and `bundle add`; `bundle install` with an
137
+ existing lockfile is unaffected.
138
+ cwe:
139
+ - CWE-829
140
+ owasp:
141
+ - A08:2021
142
+ references:
143
+ - https://blog.rubygems.org/2026/06/03/cooldown-let-new-gems-be-vetted.html
144
+ tags:
145
+ - bundler
146
+ - ruby
147
+ - id: http-client-requests
148
+ name: http-client-requests
149
+ description: >-
150
+ Checks for requests to http (unencrypted) sites using some of ruby's most popular REST/HTTP libraries, including
151
+ httparty and restclient.
152
+ category: security
153
+ severity: medium
154
+ confidence: medium
155
+ languages:
156
+ - ruby
157
+ patterns:
158
+ - pattern: |
159
+ HTTParty.$PARTYVERB("=~/[hH][tT][tT][pP]://.*/", ...)
160
+ message: >-
161
+ Checks for requests to http (unencrypted) sites using some of ruby's most popular REST/HTTP libraries,
162
+ including httparty and restclient.
163
+ - pattern: |
164
+ $STRING = "=~/[hH][tT][tT][pP]://.*/"
165
+ ...
166
+ HTTParty.$PARTYVERB($STRING, ...)
167
+ message: >-
168
+ Checks for requests to http (unencrypted) sites using some of ruby's most popular REST/HTTP libraries,
169
+ including httparty and restclient.
170
+ - pattern: |
171
+ RestClient.$RESTVERB "=~/[hH][tT][tT][pP]://.*/", ...
172
+ message: >-
173
+ Checks for requests to http (unencrypted) sites using some of ruby's most popular REST/HTTP libraries,
174
+ including httparty and restclient.
175
+ - pattern: |
176
+ RestClient::Request.execute(..., url: "=~/[hH][tT][tT][pP]://.*/", ...)
177
+ message: >-
178
+ Checks for requests to http (unencrypted) sites using some of ruby's most popular REST/HTTP libraries,
179
+ including httparty and restclient.
180
+ cwe:
181
+ - CWE-319
182
+ owasp:
183
+ - A03:2017
184
+ references:
185
+ - https://github.com/rest-client/rest-client
186
+ - https://github.com/jnunemaker/httparty/tree/master/docs
187
+ tags:
188
+ - httparty
189
+ - rest-client
190
+ - id: net-ftp-request
191
+ name: net-ftp-request
192
+ description: >-
193
+ Checks for outgoing connections to ftp servers with the 'net/ftp' package. FTP does not encrypt traffic, possibly
194
+ leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
195
+ category: security
196
+ severity: medium
197
+ confidence: medium
198
+ languages:
199
+ - ruby
200
+ patterns:
201
+ - pattern: |
202
+ $FTP = Net::FTP.new('...')
203
+ ...
204
+ $FTP.login
205
+ message: >-
206
+ Checks for outgoing connections to ftp servers with the 'net/ftp' package. FTP does not encrypt traffic,
207
+ possibly leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
208
+ - pattern: |
209
+ Net::FTP.open('...') do |ftp|
210
+ ...
211
+ ftp.login
212
+ end
213
+ message: >-
214
+ Checks for outgoing connections to ftp servers with the 'net/ftp' package. FTP does not encrypt traffic,
215
+ possibly leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
216
+ cwe:
217
+ - CWE-319
218
+ owasp:
219
+ - A03:2017
220
+ references:
221
+ - https://docs.ruby-lang.org/en/2.0.0/Net/FTP.html
222
+ tags:
223
+ - ruby
224
+ - id: net-http-request
225
+ name: net-http-request
226
+ description: >-
227
+ Checks for requests sent to http:// URLs. This is dangerous as the server is attempting to connect to a website
228
+ that does not encrypt traffic with TLS. Instead, only send requests to https:// URLs.
229
+ category: security
230
+ severity: medium
231
+ confidence: medium
232
+ languages:
233
+ - ruby
234
+ patterns:
235
+ - regex: .*
236
+ message: >-
237
+ Checks for requests sent to http:// URLs. This is dangerous as the server is attempting to connect to a
238
+ website that does not encrypt traffic with TLS. Instead, only send requests to https:// URLs.
239
+ cwe:
240
+ - CWE-319
241
+ owasp:
242
+ - A03:2017
243
+ references:
244
+ - https://ruby-doc.org/stdlib-2.6.5/libdoc/net/http/rdoc/Net/
245
+ tags:
246
+ - ruby
247
+ - id: net-telnet-request
248
+ name: net-telnet-request
249
+ description: >-
250
+ Checks for creation of telnet servers or attempts to connect through telnet. This is insecure as the telnet
251
+ protocol supports no encryption, and data passes through unencrypted.
252
+ category: security
253
+ severity: medium
254
+ confidence: medium
255
+ languages:
256
+ - ruby
257
+ patterns:
258
+ - pattern: |
259
+ Net::Telnet::new(...)
260
+ message: >-
261
+ Checks for creation of telnet servers or attempts to connect through telnet. This is insecure as the telnet
262
+ protocol supports no encryption, and data passes through unencrypted.
263
+ - pattern: |
264
+ Net::SSH::Telnet.new(...)
265
+ message: >-
266
+ Checks for creation of telnet servers or attempts to connect through telnet. This is insecure as the telnet
267
+ protocol supports no encryption, and data passes through unencrypted.
268
+ cwe:
269
+ - CWE-319
270
+ owasp:
271
+ - A03:2017
272
+ references:
273
+ - https://docs.ruby-lang.org/en/2.2.0/Net/Telnet.html
274
+ - https://www.rubydoc.info/gems/net-ssh-telnet2/0.1.0/Net/SSH/Telnet
275
+ tags:
276
+ - ruby
277
+ - id: openuri-request
278
+ name: openuri-request
279
+ description: Checks for requests to http and ftp (unencrypted) sites using OpenURI.
280
+ category: security
281
+ severity: medium
282
+ confidence: medium
283
+ languages:
284
+ - ruby
285
+ patterns:
286
+ - pattern: |
287
+ URI.open('=~/[hH][tT][tT][pP]://.*/', ...)
288
+ message: Checks for requests to http and ftp (unencrypted) sites using OpenURI.
289
+ - pattern: |
290
+ $URI = URI.parse('=~/[hH][tT][tT][pP]://.*/', ...)
291
+ ...
292
+ $URI.open
293
+ message: Checks for requests to http and ftp (unencrypted) sites using OpenURI.
294
+ - pattern: |
295
+ URI.open('=~/^[fF][tT][pP]://.*/', ...)
296
+ message: Checks for requests to http and ftp (unencrypted) sites using OpenURI.
297
+ - pattern: |
298
+ $URI = URI.parse('=~/^[fF][tT][pP]://.*/', ...)
299
+ ...
300
+ $URI.open
301
+ message: Checks for requests to http and ftp (unencrypted) sites using OpenURI.
302
+ cwe:
303
+ - CWE-319
304
+ owasp:
305
+ - A03:2017
306
+ references:
307
+ - https://ruby-doc.org/stdlib-2.6.3/libdoc/open-uri/rdoc/OpenURI.html
308
+ tags:
309
+ - open-uri
310
+ - id: activerecord-sqli
311
+ name: activerecord-sqli
312
+ description: >-
313
+ Detected SQL statement that is tainted by `event` object. This could lead to SQL injection if the variable is
314
+ user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
315
+ prepared statements instead. You can use parameterized statements like so: `Example.find_by_sql ["SELECT title
316
+ FROM posts WHERE author = ? AND created > ?", author_id, start_date]`
317
+ category: injection
318
+ severity: medium
319
+ confidence: medium
320
+ languages:
321
+ - ruby
322
+ patterns:
323
+ - regex: .*
324
+ message: >-
325
+ Detected SQL statement that is tainted by `event` object. This could lead to SQL injection if the variable is
326
+ user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
327
+ prepared statements instead. You can use parameterized statements like so: `Example.find_by_sql ["SELECT title
328
+ FROM posts WHERE author = ? AND created > ?", author_id, start_date]`
329
+ cwe:
330
+ - CWE-89
331
+ owasp:
332
+ - A01:2017
333
+ - A03:2021
334
+ - A05:2025
335
+ references:
336
+ - https://guides.rubyonrails.org/active_record_querying.html#finding-by-sql
337
+ tags:
338
+ - aws-lambda
339
+ - active-record
340
+ - id: mysql2-sqli
341
+ name: mysql2-sqli
342
+ description: >-
343
+ Detected SQL statement that is tainted by `event` object. This could lead to SQL injection if the variable is
344
+ user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
345
+ prepared statements instead. You can use sanitize statements like so: `escaped = client.escape(user_input)`
346
+ category: injection
347
+ severity: medium
348
+ confidence: medium
349
+ languages:
350
+ - ruby
351
+ patterns:
352
+ - regex: .*
353
+ message: >-
354
+ Detected SQL statement that is tainted by `event` object. This could lead to SQL injection if the variable is
355
+ user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
356
+ prepared statements instead. You can use sanitize statements like so: `escaped = client.escape(user_input)`
357
+ cwe:
358
+ - CWE-89
359
+ owasp:
360
+ - A01:2017
361
+ - A03:2021
362
+ - A05:2025
363
+ references:
364
+ - https://github.com/brianmario/mysql2
365
+ tags:
366
+ - aws-lambda
367
+ - mysql2
368
+ - id: pg-sqli
369
+ name: pg-sqli
370
+ description: >-
371
+ Detected SQL statement that is tainted by `event` object. This could lead to SQL injection if the variable is
372
+ user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
373
+ prepared statements instead. You can use parameterized statements like so: `conn.exec_params('SELECT $1 AS a, $2
374
+ AS b, $3 AS c', [1, 2, nil])`
375
+ category: injection
376
+ severity: medium
377
+ confidence: medium
378
+ languages:
379
+ - ruby
380
+ patterns:
381
+ - regex: .*
382
+ message: >-
383
+ Detected SQL statement that is tainted by `event` object. This could lead to SQL injection if the variable is
384
+ user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
385
+ prepared statements instead. You can use parameterized statements like so: `conn.exec_params('SELECT $1 AS a,
386
+ $2 AS b, $3 AS c', [1, 2, nil])`
387
+ cwe:
388
+ - CWE-89
389
+ owasp:
390
+ - A01:2017
391
+ - A03:2021
392
+ - A05:2025
393
+ references:
394
+ - https://www.rubydoc.info/gems/pg/PG/Connection
395
+ tags:
396
+ - aws-lambda
397
+ - postgres
398
+ - pg
399
+ - id: sequel-sqli
400
+ name: sequel-sqli
401
+ description: >-
402
+ Detected SQL statement that is tainted by `event` object. This could lead to SQL injection if the variable is
403
+ user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
404
+ prepared statements instead. You can use parameterized statements like so: `DB['select * from items where name =
405
+ ?', name]`
406
+ category: injection
407
+ severity: medium
408
+ confidence: medium
409
+ languages:
410
+ - ruby
411
+ patterns:
412
+ - regex: .*
413
+ message: >-
414
+ Detected SQL statement that is tainted by `event` object. This could lead to SQL injection if the variable is
415
+ user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
416
+ prepared statements instead. You can use parameterized statements like so: `DB['select * from items where name
417
+ = ?', name]`
418
+ cwe:
419
+ - CWE-89
420
+ owasp:
421
+ - A01:2017
422
+ - A03:2021
423
+ - A05:2025
424
+ references:
425
+ - https://github.com/jeremyevans/sequel#label-Arbitrary+SQL+queries
426
+ tags:
427
+ - aws-lambda
428
+ - sequel
429
+ - id: tainted-deserialization
430
+ name: tainted-deserialization
431
+ description: >-
432
+ Deserialization of a string tainted by `event` object found. Objects in Ruby can be serialized into strings, then
433
+ later loaded from strings. However, uses of `load` can cause remote code execution. Loading user input with
434
+ MARSHAL, YAML or CSV can potentially be dangerous. If you need to deserialize untrusted data, you should use JSON
435
+ as it is only capable of returning 'primitive' types such as strings, arrays, hashes, numbers and nil.
436
+ category: security
437
+ severity: medium
438
+ confidence: medium
439
+ languages:
440
+ - ruby
441
+ patterns:
442
+ - regex: .*
443
+ message: >-
444
+ Deserialization of a string tainted by `event` object found. Objects in Ruby can be serialized into strings,
445
+ then later loaded from strings. However, uses of `load` can cause remote code execution. Loading user input
446
+ with MARSHAL, YAML or CSV can potentially be dangerous. If you need to deserialize untrusted data, you should
447
+ use JSON as it is only capable of returning 'primitive' types such as strings, arrays, hashes, numbers and
448
+ nil.
449
+ cwe:
450
+ - CWE-502
451
+ owasp:
452
+ - A08:2017
453
+ - A08:2021
454
+ - A08:2025
455
+ references:
456
+ - https://ruby-doc.org/core-3.1.2/doc/security_rdoc.html
457
+ - https://groups.google.com/g/rubyonrails-security/c/61bkgvnSGTQ/m/nehwjA8tQ8EJ
458
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_deserialize.rb
459
+ tags:
460
+ - ruby
461
+ - aws-lambda
462
+ - id: tainted-sql-string
463
+ name: tainted-sql-string
464
+ description: >-
465
+ Detected user input used to manually construct a SQL string. This is usually bad practice because manual
466
+ construction could accidentally result in a SQL injection. An attacker could use a SQL injection to steal or
467
+ modify contents of the database. Instead, use a parameterized query which is available by default in most database
468
+ engines. Alternatively, consider using an object-relational mapper (ORM) such as Sequelize which will protect your
469
+ queries.
470
+ category: injection
471
+ severity: high
472
+ confidence: medium
473
+ languages:
474
+ - ruby
475
+ patterns:
476
+ - regex: .*
477
+ message: >-
478
+ Detected user input used to manually construct a SQL string. This is usually bad practice because manual
479
+ construction could accidentally result in a SQL injection. An attacker could use a SQL injection to steal or
480
+ modify contents of the database. Instead, use a parameterized query which is available by default in most
481
+ database engines. Alternatively, consider using an object-relational mapper (ORM) such as Sequelize which will
482
+ protect your queries.
483
+ cwe:
484
+ - CWE-89
485
+ owasp:
486
+ - A01:2017
487
+ - A03:2021
488
+ - A05:2025
489
+ references:
490
+ - https://rorsecurity.info/portfolio/ruby-on-rails-sql-injection-cheat-sheet
491
+ tags:
492
+ - aws-lambda
493
+ - id: ruby-jwt-decode-without-verify
494
+ name: ruby-jwt-decode-without-verify
495
+ description: >-
496
+ Detected the decoding of a JWT token without a verify step. JWT tokens must be verified before use, otherwise the
497
+ token's integrity is unknown. This means a malicious actor could forge a JWT token with any claims.
498
+ category: auth
499
+ severity: medium
500
+ confidence: medium
501
+ languages:
502
+ - ruby
503
+ patterns:
504
+ - pattern: JWT.decode($PAYLOAD,$SECRET,false,...)
505
+ message: >-
506
+ Detected the decoding of a JWT token without a verify step. JWT tokens must be verified before use, otherwise
507
+ the token's integrity is unknown. This means a malicious actor could forge a JWT token with any claims.
508
+ cwe:
509
+ - CWE-345
510
+ owasp:
511
+ - A08:2021
512
+ - A08:2025
513
+ references:
514
+ - https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures
515
+ tags:
516
+ - jwt
517
+ - id: ruby-jwt-exposed-data
518
+ name: ruby-jwt-exposed-data
519
+ description: >-
520
+ The object is passed strictly to jsonwebtoken.sign(...) Make sure that sensitive information is not exposed
521
+ through JWT token payload.
522
+ category: auth
523
+ severity: medium
524
+ confidence: medium
525
+ languages:
526
+ - ruby
527
+ patterns:
528
+ - pattern: |
529
+ JWT.encode($INPUT,...)
530
+ message: >-
531
+ The object is passed strictly to jsonwebtoken.sign(...) Make sure that sensitive information is not exposed
532
+ through JWT token payload.
533
+ cwe:
534
+ - CWE-522
535
+ owasp:
536
+ - A02:2017
537
+ - A04:2021
538
+ - A06:2025
539
+ references:
540
+ - https://owasp.org/Top10/A04_2021-Insecure_Design
541
+ tags:
542
+ - jwt
543
+ - id: ruby-jwt-exposed-credentials
544
+ name: ruby-jwt-exposed-credentials
545
+ description: >-
546
+ Password is exposed through JWT token payload. This is not encrypted and the password could be compromised. Do not
547
+ store passwords in JWT tokens.
548
+ category: auth
549
+ severity: high
550
+ confidence: medium
551
+ languages:
552
+ - ruby
553
+ patterns:
554
+ - pattern: |
555
+ $PAYLOAD = {...,password:...,...}
556
+ ...
557
+ JWT.encode($PAYLOAD,...)
558
+ message: >-
559
+ Password is exposed through JWT token payload. This is not encrypted and the password could be compromised. Do
560
+ not store passwords in JWT tokens.
561
+ cwe:
562
+ - CWE-522
563
+ owasp:
564
+ - A02:2017
565
+ - A04:2021
566
+ - A06:2025
567
+ references:
568
+ - https://cwe.mitre.org/data/definitions/522.html
569
+ tags:
570
+ - jwt
571
+ - id: ruby-jwt-hardcoded-secret
572
+ name: ruby-jwt-hardcoded-secret
573
+ description: >-
574
+ Hardcoded JWT secret or private key is used. This is a Insufficiently Protected Credentials weakness:
575
+ https://cwe.mitre.org/data/definitions/522.html Consider using an appropriate security mechanism to protect the
576
+ credentials (e.g. keeping secrets in environment variables)
577
+ category: secrets
578
+ severity: high
579
+ confidence: medium
580
+ languages:
581
+ - ruby
582
+ patterns:
583
+ - regex: .*
584
+ message: >-
585
+ Hardcoded JWT secret or private key is used. This is a Insufficiently Protected Credentials weakness:
586
+ https://cwe.mitre.org/data/definitions/522.html Consider using an appropriate security mechanism to protect
587
+ the credentials (e.g. keeping secrets in environment variables)
588
+ cwe:
589
+ - CWE-522
590
+ owasp:
591
+ - A02:2017
592
+ - A04:2021
593
+ - A06:2025
594
+ references:
595
+ - https://owasp.org/Top10/A04_2021-Insecure_Design
596
+ tags:
597
+ - jwt
598
+ - id: ruby-jwt-none-alg
599
+ name: ruby-jwt-none-alg
600
+ description: >-
601
+ Detected use of the 'none' algorithm in a JWT token. The 'none' algorithm assumes the integrity of the token has
602
+ already been verified. This would allow a malicious actor to forge a JWT token that will automatically be
603
+ verified. Do not explicitly use the 'none' algorithm. Instead, use an algorithm such as 'HS256'.
604
+ category: auth
605
+ severity: high
606
+ confidence: medium
607
+ languages:
608
+ - ruby
609
+ patterns:
610
+ - pattern: |
611
+ JWT.encode($PAYLOAD, $SECRET, 'none', ...)
612
+ message: >-
613
+ Detected use of the 'none' algorithm in a JWT token. The 'none' algorithm assumes the integrity of the token
614
+ has already been verified. This would allow a malicious actor to forge a JWT token that will automatically be
615
+ verified. Do not explicitly use the 'none' algorithm. Instead, use an algorithm such as 'HS256'.
616
+ cwe:
617
+ - CWE-327
618
+ owasp:
619
+ - A03:2017
620
+ - A02:2021
621
+ - A04:2025
622
+ references:
623
+ - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
624
+ tags:
625
+ - jwt
626
+ - id: sha224-hash
627
+ name: sha224-hash
628
+ description: >-
629
+ This code uses a 224-bit hash function, which is deprecated or disallowed in some security policies. Consider
630
+ updating to a stronger hash function such as SHA-384 or higher to ensure compliance and security.
631
+ category: crypto
632
+ severity: medium
633
+ confidence: medium
634
+ languages:
635
+ - ruby
636
+ patterns:
637
+ - pattern: Digest::SHA224.$FUNC
638
+ message: >-
639
+ This code uses a 224-bit hash function, which is deprecated or disallowed in some security policies. Consider
640
+ updating to a stronger hash function such as SHA-384 or higher to ensure compliance and security.
641
+ - pattern: OpenSSL::Digest::SHA224.$FUNC
642
+ message: >-
643
+ This code uses a 224-bit hash function, which is deprecated or disallowed in some security policies. Consider
644
+ updating to a stronger hash function such as SHA-384 or higher to ensure compliance and security.
645
+ - pattern: SHA3::Digest::SHA224(...)
646
+ message: >-
647
+ This code uses a 224-bit hash function, which is deprecated or disallowed in some security policies. Consider
648
+ updating to a stronger hash function such as SHA-384 or higher to ensure compliance and security.
649
+ cwe:
650
+ - CWE-328
651
+ owasp:
652
+ - A03:2017
653
+ - A02:2021
654
+ - A04:2025
655
+ references:
656
+ - https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar3.ipd.pdf
657
+ - >-
658
+ https://www.cyber.gov.au/resources-business-and-government/essential-cyber-security/ism/cyber-security-guidelines/guidelines-cryptography
659
+ tags:
660
+ - ruby
661
+ - id: bad-deserialization-env
662
+ name: bad-deserialization-env
663
+ description: >-
664
+ Checks for unsafe deserialization. Objects in Ruby can be serialized into strings, then later loaded from strings.
665
+ However, uses of load and object_load can cause remote code execution. Loading user input with MARSHAL or CSV can
666
+ potentially be dangerous. Use JSON in a secure fashion instead.
667
+ category: security
668
+ severity: high
669
+ confidence: medium
670
+ languages:
671
+ - ruby
672
+ patterns:
673
+ - regex: .*
674
+ message: >-
675
+ Checks for unsafe deserialization. Objects in Ruby can be serialized into strings, then later loaded from
676
+ strings. However, uses of load and object_load can cause remote code execution. Loading user input with
677
+ MARSHAL or CSV can potentially be dangerous. Use JSON in a secure fashion instead.
678
+ cwe:
679
+ - CWE-502
680
+ owasp:
681
+ - A08:2017
682
+ - A08:2021
683
+ - A08:2025
684
+ references:
685
+ - https://groups.google.com/g/rubyonrails-security/c/61bkgvnSGTQ/m/nehwjA8tQ8EJ
686
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_deserialize.rb
687
+ tags:
688
+ - ruby
689
+ - id: bad-deserialization-yaml
690
+ name: bad-deserialization-yaml
691
+ description: >-
692
+ Unsafe deserialization from YAML. Objects in Ruby can be serialized into strings, then later loaded from strings.
693
+ However, uses of load and object_load can cause remote code execution. Loading user input with YAML can
694
+ potentially be dangerous. Use JSON in a secure fashion instead. However, loading YAML from a static file is not
695
+ dangerous and should not be flagged.
696
+ category: security
697
+ severity: high
698
+ confidence: medium
699
+ languages:
700
+ - ruby
701
+ patterns:
702
+ - pattern: |
703
+ YAML.load($...ARGS)
704
+ message: >-
705
+ Unsafe deserialization from YAML. Objects in Ruby can be serialized into strings, then later loaded from
706
+ strings. However, uses of load and object_load can cause remote code execution. Loading user input with YAML
707
+ can potentially be dangerous. Use JSON in a secure fashion instead. However, loading YAML from a static file
708
+ is not dangerous and should not be flagged.
709
+ cwe:
710
+ - CWE-502
711
+ owasp:
712
+ - A08:2017
713
+ - A08:2021
714
+ - A08:2025
715
+ references:
716
+ - https://groups.google.com/g/rubyonrails-security/c/61bkgvnSGTQ/m/nehwjA8tQ8EJ
717
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_deserialize.rb
718
+ tags:
719
+ - ruby
720
+ - yaml
721
+ - id: bad-deserialization
722
+ name: bad-deserialization
723
+ description: >-
724
+ Checks for unsafe deserialization. Objects in Ruby can be serialized into strings, then later loaded from strings.
725
+ However, uses of load and object_load can cause remote code execution. Loading user input with MARSHAL or CSV can
726
+ potentially be dangerous. Use JSON in a secure fashion instead.
727
+ category: security
728
+ severity: high
729
+ confidence: medium
730
+ languages:
731
+ - ruby
732
+ patterns:
733
+ - regex: .*
734
+ message: >-
735
+ Checks for unsafe deserialization. Objects in Ruby can be serialized into strings, then later loaded from
736
+ strings. However, uses of load and object_load can cause remote code execution. Loading user input with
737
+ MARSHAL or CSV can potentially be dangerous. Use JSON in a secure fashion instead.
738
+ cwe:
739
+ - CWE-502
740
+ owasp:
741
+ - A08:2017
742
+ - A08:2021
743
+ - A08:2025
744
+ references:
745
+ - https://groups.google.com/g/rubyonrails-security/c/61bkgvnSGTQ/m/nehwjA8tQ8EJ
746
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_deserialize.rb
747
+ tags:
748
+ - ruby
749
+ - id: cookie-serialization
750
+ name: cookie-serialization
751
+ description: >-
752
+ Checks if code allows cookies to be deserialized using Marshal. If the attacker can craft a valid cookie, this
753
+ could lead to remote code execution. The hybrid check is just to warn users to migrate to :json for best practice.
754
+ category: security
755
+ severity: high
756
+ confidence: medium
757
+ languages:
758
+ - ruby
759
+ patterns:
760
+ - pattern: |
761
+ Rails.application.config.action_dispatch.cookies_serializer = :marshal
762
+ message: >-
763
+ Checks if code allows cookies to be deserialized using Marshal. If the attacker can craft a valid cookie, this
764
+ could lead to remote code execution. The hybrid check is just to warn users to migrate to :json for best
765
+ practice.
766
+ - pattern: |
767
+ Rails.application.config.action_dispatch.cookies_serializer = :hybrid
768
+ message: >-
769
+ Checks if code allows cookies to be deserialized using Marshal. If the attacker can craft a valid cookie, this
770
+ could lead to remote code execution. The hybrid check is just to warn users to migrate to :json for best
771
+ practice.
772
+ cwe:
773
+ - CWE-94
774
+ owasp:
775
+ - A03:2021
776
+ - A05:2025
777
+ references:
778
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_cookie_serialization.rb
779
+ - https://robertheaton.com/2013/07/22/how-to-hack-a-rails-app-using-its-secret-token/
780
+ tags:
781
+ - ruby
782
+ - id: create-with
783
+ name: create-with
784
+ description: >-
785
+ Checks for strong parameter bypass through usage of create_with. Create_with bypasses strong parameter protection,
786
+ which could allow attackers to set arbitrary attributes on models. To fix this vulnerability, either remove all
787
+ create_with calls or use the permit function to specify tags that are allowed to be set.
788
+ category: security
789
+ severity: high
790
+ confidence: medium
791
+ languages:
792
+ - ruby
793
+ patterns:
794
+ - pattern: |
795
+ $FUNC.create_with($PARAMSA)
796
+ message: >-
797
+ Checks for strong parameter bypass through usage of create_with. Create_with bypasses strong parameter
798
+ protection, which could allow attackers to set arbitrary attributes on models. To fix this vulnerability,
799
+ either remove all create_with calls or use the permit function to specify tags that are allowed to be set.
800
+ cwe:
801
+ - CWE-915
802
+ owasp:
803
+ - A08:2021
804
+ - A08:2025
805
+ references:
806
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_create_with.rb
807
+ - https://groups.google.com/g/rubyonrails-security/c/M4chq5Sb540/m/CC1Fh0Y_NWwJ
808
+ tags:
809
+ - ruby
810
+ - id: dangerous-exec
811
+ name: dangerous-exec
812
+ description: >-
813
+ Detected non-static command inside $EXEC. Audit the input to '$EXEC'. If unverified user data can reach this call
814
+ site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary
815
+ code.
816
+ category: security
817
+ severity: medium
818
+ confidence: medium
819
+ languages:
820
+ - ruby
821
+ patterns:
822
+ - regex: .*
823
+ message: >-
824
+ Detected non-static command inside $EXEC. Audit the input to '$EXEC'. If unverified user data can reach this
825
+ call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
826
+ arbitrary code.
827
+ cwe:
828
+ - CWE-94
829
+ owasp:
830
+ - A03:2021
831
+ - A05:2025
832
+ references:
833
+ - https://guides.rubyonrails.org/security.html#command-line-injection
834
+ tags:
835
+ - ruby
836
+ - rails
837
+ - id: dangerous-open
838
+ name: dangerous-open
839
+ description: >-
840
+ Detected non-static command inside 'open'. Audit the input to 'open'. If unverified user data can reach this call
841
+ site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary
842
+ code.
843
+ category: security
844
+ severity: medium
845
+ confidence: medium
846
+ languages:
847
+ - ruby
848
+ patterns:
849
+ - pattern: |
850
+ open($CMD,...)
851
+ message: >-
852
+ Detected non-static command inside 'open'. Audit the input to 'open'. If unverified user data can reach this
853
+ call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
854
+ arbitrary code.
855
+ cwe:
856
+ - CWE-94
857
+ owasp:
858
+ - A03:2021
859
+ - A05:2025
860
+ references:
861
+ - https://owasp.org/Top10/A03_2021-Injection
862
+ tags:
863
+ - ruby
864
+ - id: dangerous-open3-pipeline
865
+ name: dangerous-open3-pipeline
866
+ description: >-
867
+ Detected non-static command inside $PIPE. Audit the input to '$PIPE'. If unverified user data can reach this call
868
+ site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary
869
+ code.
870
+ category: security
871
+ severity: medium
872
+ confidence: medium
873
+ languages:
874
+ - ruby
875
+ patterns:
876
+ - pattern: |
877
+ Open3.$PIPE(...)
878
+ message: >-
879
+ Detected non-static command inside $PIPE. Audit the input to '$PIPE'. If unverified user data can reach this
880
+ call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
881
+ arbitrary code.
882
+ cwe:
883
+ - CWE-94
884
+ owasp:
885
+ - A03:2021
886
+ - A05:2025
887
+ references:
888
+ - https://owasp.org/Top10/A03_2021-Injection
889
+ tags:
890
+ - ruby
891
+ - id: dangerous-subshell
892
+ name: dangerous-subshell
893
+ description: >-
894
+ Detected non-static command inside `...`. If unverified user data can reach this call site, this is a code
895
+ injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary code.
896
+ category: security
897
+ severity: medium
898
+ confidence: medium
899
+ languages:
900
+ - ruby
901
+ patterns:
902
+ - pattern: |
903
+ `...#{$VAL}...`
904
+ message: >-
905
+ Detected non-static command inside `...`. If unverified user data can reach this call site, this is a code
906
+ injection vulnerability. A malicious actor can inject a malicious script to execute arbitrary code.
907
+ cwe:
908
+ - CWE-94
909
+ owasp:
910
+ - A03:2021
911
+ - A05:2025
912
+ references:
913
+ - https://owasp.org/Top10/A03_2021-Injection
914
+ tags:
915
+ - ruby
916
+ - id: dangerous-syscall
917
+ name: dangerous-syscall
918
+ description: >-
919
+ 'syscall' is essentially unsafe and unportable. The DL (https://apidock.com/ruby/Fiddle) library is preferred for
920
+ safer and a bit more portable programming.
921
+ category: security
922
+ severity: medium
923
+ confidence: medium
924
+ languages:
925
+ - ruby
926
+ patterns:
927
+ - pattern: |
928
+ syscall
929
+ message: >-
930
+ 'syscall' is essentially unsafe and unportable. The DL (https://apidock.com/ruby/Fiddle) library is preferred
931
+ for safer and a bit more portable programming.
932
+ cwe:
933
+ - CWE-94
934
+ owasp:
935
+ - A03:2021
936
+ - A05:2025
937
+ references:
938
+ - https://owasp.org/Top10/A03_2021-Injection
939
+ tags:
940
+ - ruby
941
+ - id: divide-by-zero
942
+ name: divide-by-zero
943
+ description: Detected a possible ZeroDivisionError.
944
+ category: security
945
+ severity: medium
946
+ confidence: medium
947
+ languages:
948
+ - ruby
949
+ patterns:
950
+ - regex: .*
951
+ message: Detected a possible ZeroDivisionError.
952
+ cwe:
953
+ - CWE-369
954
+ owasp: []
955
+ references:
956
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_divide_by_zero.rb
957
+ tags:
958
+ - ruby
959
+ - id: file-disclosure
960
+ name: file-disclosure
961
+ description: >-
962
+ Special requests can determine whether a file exists on a filesystem that's outside the Rails app's root
963
+ directory. To fix this, set config.serve_static_assets = false.
964
+ category: file-ops
965
+ severity: high
966
+ confidence: medium
967
+ languages:
968
+ - ruby
969
+ patterns:
970
+ - pattern: config.serve_static_assets = true
971
+ message: >-
972
+ Special requests can determine whether a file exists on a filesystem that's outside the Rails app's root
973
+ directory. To fix this, set config.serve_static_assets = false.
974
+ cwe:
975
+ - CWE-22
976
+ owasp:
977
+ - A05:2017
978
+ - A01:2021
979
+ - A01:2025
980
+ references:
981
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_file_disclosure.rb
982
+ - https://groups.google.com/g/rubyonrails-security/c/23fiuwb1NBA/m/MQVM1-5GkPMJ
983
+ tags:
984
+ - ruby
985
+ - id: filter-skipping
986
+ name: filter-skipping
987
+ description: >-
988
+ Checks for use of action in Ruby routes. This can cause Rails to render an arbitrary view if an attacker creates
989
+ an URL accurately. Affects 3.0 applications. Can avoid the vulnerability by providing additional constraints.
990
+ category: security
991
+ severity: high
992
+ confidence: medium
993
+ languages:
994
+ - ruby
995
+ patterns:
996
+ - pattern: |
997
+ $CALL "=~/.*(/:action.*).*/"
998
+ message: >-
999
+ Checks for use of action in Ruby routes. This can cause Rails to render an arbitrary view if an attacker
1000
+ creates an URL accurately. Affects 3.0 applications. Can avoid the vulnerability by providing additional
1001
+ constraints.
1002
+ cwe:
1003
+ - CWE-1021
1004
+ owasp:
1005
+ - A04:2021
1006
+ - A06:2025
1007
+ references:
1008
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_filter_skipping.rb
1009
+ - https://groups.google.com/g/rubyonrails-security/c/NCCsca7TEtY
1010
+ tags:
1011
+ - ruby
1012
+ - id: force-ssl-false
1013
+ name: force-ssl-false
1014
+ description: >-
1015
+ Checks for configuration setting of force_ssl to false. Force_ssl forces usage of HTTPS, which could lead to
1016
+ network interception of unencrypted application traffic. To fix, set config.force_ssl = true.
1017
+ category: injection
1018
+ severity: medium
1019
+ confidence: medium
1020
+ languages:
1021
+ - ruby
1022
+ patterns:
1023
+ - pattern: config.force_ssl = false
1024
+ message: >-
1025
+ Checks for configuration setting of force_ssl to false. Force_ssl forces usage of HTTPS, which could lead to
1026
+ network interception of unencrypted application traffic. To fix, set config.force_ssl = true.
1027
+ cwe:
1028
+ - CWE-311
1029
+ owasp:
1030
+ - A03:2017
1031
+ - A04:2021
1032
+ - A06:2025
1033
+ references:
1034
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_force_ssl.rb
1035
+ tags:
1036
+ - ruby
1037
+ - id: hardcoded-http-auth-in-controller
1038
+ name: hardcoded-http-auth-in-controller
1039
+ description: >-
1040
+ Detected hardcoded password used in basic authentication in a controller class. Including this password in version
1041
+ control could expose this credential. Consider refactoring to use environment variables or configuration files.
1042
+ category: auth
1043
+ severity: medium
1044
+ confidence: medium
1045
+ languages:
1046
+ - ruby
1047
+ patterns:
1048
+ - regex: .*
1049
+ message: >-
1050
+ Detected hardcoded password used in basic authentication in a controller class. Including this password in
1051
+ version control could expose this credential. Consider refactoring to use environment variables or
1052
+ configuration files.
1053
+ cwe:
1054
+ - CWE-798
1055
+ owasp:
1056
+ - A07:2021
1057
+ - A07:2025
1058
+ references:
1059
+ - https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
1060
+ tags:
1061
+ - ruby
1062
+ - secrets
1063
+ - id: hardcoded-secret-rsa-passphrase
1064
+ name: hardcoded-secret-rsa-passphrase
1065
+ description: >-
1066
+ Found the use of an hardcoded passphrase for RSA. The passphrase can be easily discovered, and therefore should
1067
+ not be stored in source-code. It is recommended to remove the passphrase from source-code, and use system
1068
+ environment variables or a restricted configuration file.
1069
+ category: secrets
1070
+ severity: medium
1071
+ confidence: medium
1072
+ languages:
1073
+ - ruby
1074
+ patterns:
1075
+ - regex: .*
1076
+ message: >-
1077
+ Found the use of an hardcoded passphrase for RSA. The passphrase can be easily discovered, and therefore
1078
+ should not be stored in source-code. It is recommended to remove the passphrase from source-code, and use
1079
+ system environment variables or a restricted configuration file.
1080
+ cwe:
1081
+ - CWE-798
1082
+ owasp:
1083
+ - A07:2021
1084
+ - A07:2025
1085
+ references:
1086
+ - https://cwe.mitre.org/data/definitions/522.html
1087
+ tags:
1088
+ - ruby
1089
+ - secrets
1090
+ - id: insufficient-rsa-key-size
1091
+ name: insufficient-rsa-key-size
1092
+ description: The RSA key size $SIZE is insufficent by NIST standards. It is recommended to use a key length of 2048 or higher.
1093
+ category: secrets
1094
+ severity: medium
1095
+ confidence: medium
1096
+ languages:
1097
+ - ruby
1098
+ patterns:
1099
+ - regex: .*
1100
+ message: >-
1101
+ The RSA key size $SIZE is insufficent by NIST standards. It is recommended to use a key length of 2048 or
1102
+ higher.
1103
+ cwe:
1104
+ - CWE-326
1105
+ owasp:
1106
+ - A03:2017
1107
+ - A02:2021
1108
+ - A04:2025
1109
+ references:
1110
+ - https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57Pt3r1.pdf
1111
+ tags:
1112
+ - ruby
1113
+ - id: json-entity-escape
1114
+ name: json-entity-escape
1115
+ description: Checks if HTML escaping is globally disabled for JSON output. This could lead to XSS.
1116
+ category: security
1117
+ severity: medium
1118
+ confidence: medium
1119
+ languages:
1120
+ - ruby
1121
+ patterns:
1122
+ - pattern: |
1123
+ ActiveSupport.escape_html_entities_in_json = false
1124
+ message: Checks if HTML escaping is globally disabled for JSON output. This could lead to XSS.
1125
+ - pattern: |
1126
+ config.active_support.escape_html_entities_in_json = false
1127
+ message: Checks if HTML escaping is globally disabled for JSON output. This could lead to XSS.
1128
+ cwe:
1129
+ - CWE-79
1130
+ owasp:
1131
+ - A07:2017
1132
+ - A03:2021
1133
+ - A05:2025
1134
+ references:
1135
+ - https://owasp.org/Top10/A03_2021-Injection
1136
+ tags:
1137
+ - ruby
1138
+ - id: mass-assignment-protection-disabled
1139
+ name: mass-assignment-protection-disabled
1140
+ description: >-
1141
+ Mass assignment protection disabled for '$MODEL'. This could permit assignment to sensitive model fields without
1142
+ intention. Instead, use 'attr_accessible' for the model or disable mass assigment using
1143
+ 'config.active_record.whitelist_attributes = true'. ':without_protection => true' must be removed for this to take
1144
+ effect.
1145
+ category: security
1146
+ severity: medium
1147
+ confidence: medium
1148
+ languages:
1149
+ - ruby
1150
+ patterns:
1151
+ - pattern: $MODEL.new(params[...], ..., :without_protection => true, ...)
1152
+ message: >-
1153
+ Mass assignment protection disabled for '$MODEL'. This could permit assignment to sensitive model fields
1154
+ without intention. Instead, use 'attr_accessible' for the model or disable mass assigment using
1155
+ 'config.active_record.whitelist_attributes = true'. ':without_protection => true' must be removed for this to
1156
+ take effect.
1157
+ cwe:
1158
+ - CWE-915
1159
+ owasp:
1160
+ - A08:2021
1161
+ - A08:2025
1162
+ references:
1163
+ - https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures
1164
+ tags:
1165
+ - ruby
1166
+ - id: md5-used-as-password
1167
+ name: md5-used-as-password
1168
+ description: >-
1169
+ It looks like MD5 is used as a password hash. MD5 is not considered a secure password hash because it can be
1170
+ cracked by an attacker in a short amount of time. Instead, use a suitable password hashing function such as
1171
+ bcrypt. You can use the `bcrypt` gem.
1172
+ category: secrets
1173
+ severity: medium
1174
+ confidence: medium
1175
+ languages:
1176
+ - ruby
1177
+ patterns:
1178
+ - regex: .*
1179
+ message: >-
1180
+ It looks like MD5 is used as a password hash. MD5 is not considered a secure password hash because it can be
1181
+ cracked by an attacker in a short amount of time. Instead, use a suitable password hashing function such as
1182
+ bcrypt. You can use the `bcrypt` gem.
1183
+ cwe:
1184
+ - CWE-327
1185
+ owasp:
1186
+ - A03:2017
1187
+ - A02:2021
1188
+ - A04:2025
1189
+ references:
1190
+ - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
1191
+ - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
1192
+ - https://github.com/returntocorp/semgrep-rules/issues/1609
1193
+ tags:
1194
+ - md5
1195
+ - id: missing-csrf-protection
1196
+ name: missing-csrf-protection
1197
+ description: >-
1198
+ Detected controller which does not enable cross-site request forgery protections using 'protect_from_forgery'. Add
1199
+ 'protect_from_forgery :with => :exception' to your controller class.
1200
+ category: api-security
1201
+ severity: high
1202
+ confidence: medium
1203
+ languages:
1204
+ - ruby
1205
+ patterns:
1206
+ - pattern: |
1207
+ class $CONTROLLER < ActionController::Base
1208
+ ...
1209
+ end
1210
+ message: >-
1211
+ Detected controller which does not enable cross-site request forgery protections using 'protect_from_forgery'.
1212
+ Add 'protect_from_forgery :with => :exception' to your controller class.
1213
+ cwe:
1214
+ - CWE-352
1215
+ owasp:
1216
+ - A01:2021
1217
+ - A01:2025
1218
+ references:
1219
+ - https://owasp.org/Top10/A01_2021-Broken_Access_Control
1220
+ tags:
1221
+ - ruby
1222
+ - id: model-attr-accessible
1223
+ name: model-attr-accessible
1224
+ description: >-
1225
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1226
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned, role,
1227
+ and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow admin, banned,
1228
+ role, and account_id using permit or attr_accessible.
1229
+ category: security
1230
+ severity: high
1231
+ confidence: medium
1232
+ languages:
1233
+ - ruby
1234
+ patterns:
1235
+ - pattern: |
1236
+ ....permit(..., :admin, ...)
1237
+ message: >-
1238
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1239
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1240
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1241
+ admin, banned, role, and account_id using permit or attr_accessible.
1242
+ - pattern: |
1243
+ ....permit(..., :role, ...)
1244
+ message: >-
1245
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1246
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1247
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1248
+ admin, banned, role, and account_id using permit or attr_accessible.
1249
+ - pattern: |
1250
+ ....permit(..., :banned, ...)
1251
+ message: >-
1252
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1253
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1254
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1255
+ admin, banned, role, and account_id using permit or attr_accessible.
1256
+ - pattern: |
1257
+ ....permit(..., :account_id, ...)
1258
+ message: >-
1259
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1260
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1261
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1262
+ admin, banned, role, and account_id using permit or attr_accessible.
1263
+ - pattern: |
1264
+ attr_accessible ..., :admin, ...
1265
+ message: >-
1266
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1267
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1268
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1269
+ admin, banned, role, and account_id using permit or attr_accessible.
1270
+ - pattern: |
1271
+ attr_accessible ..., :role, ...
1272
+ message: >-
1273
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1274
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1275
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1276
+ admin, banned, role, and account_id using permit or attr_accessible.
1277
+ - pattern: |
1278
+ attr_accessible ..., :banned, ...
1279
+ message: >-
1280
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1281
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1282
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1283
+ admin, banned, role, and account_id using permit or attr_accessible.
1284
+ - pattern: |
1285
+ attr_accessible ..., :account_id, ...
1286
+ message: >-
1287
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1288
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1289
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1290
+ admin, banned, role, and account_id using permit or attr_accessible.
1291
+ - pattern: |
1292
+ params.permit!
1293
+ message: >-
1294
+ Checks for dangerous permitted attributes that can lead to mass assignment vulnerabilities. Query parameters
1295
+ allowed using permit and attr_accessible are checked for allowance of dangerous attributes admin, banned,
1296
+ role, and account_id. Also checks for usages of params.permit!, which allows everything. Fix: don't allow
1297
+ admin, banned, role, and account_id using permit or attr_accessible.
1298
+ cwe:
1299
+ - CWE-915
1300
+ owasp:
1301
+ - A08:2021
1302
+ - A08:2025
1303
+ references:
1304
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_model_attr_accessible.rb
1305
+ tags:
1306
+ - ruby
1307
+ - id: model-attributes-attr-accessible
1308
+ name: model-attributes-attr-accessible
1309
+ description: >-
1310
+ Checks for models that do not use attr_accessible. This means there is no limiting of which variables can be
1311
+ manipulated through mass assignment. For newer Rails applications, parameters should be allowlisted using strong
1312
+ parameters. For older Rails versions, they should be allowlisted using strong_attributes.
1313
+ category: security
1314
+ severity: high
1315
+ confidence: medium
1316
+ languages:
1317
+ - ruby
1318
+ patterns:
1319
+ - pattern: |
1320
+ class $CLASS < $TYPE
1321
+ ...
1322
+ end
1323
+ ...
1324
+ $CLASS.$FUNC(...)
1325
+ message: >-
1326
+ Checks for models that do not use attr_accessible. This means there is no limiting of which variables can be
1327
+ manipulated through mass assignment. For newer Rails applications, parameters should be allowlisted using
1328
+ strong parameters. For older Rails versions, they should be allowlisted using strong_attributes.
1329
+ cwe:
1330
+ - CWE-915
1331
+ owasp:
1332
+ - A08:2021
1333
+ - A08:2025
1334
+ references:
1335
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_model_attributes.rb
1336
+ tags:
1337
+ - rails
1338
+ - id: ruby-eval
1339
+ name: ruby-eval
1340
+ description: >-
1341
+ Use of eval with user-controllable input detected. This can lead to attackers running arbitrary code. Ensure
1342
+ external data does not reach here, otherwise this is a security vulnerability. Consider other ways to do this
1343
+ without eval.
1344
+ category: injection
1345
+ severity: medium
1346
+ confidence: medium
1347
+ languages:
1348
+ - ruby
1349
+ patterns:
1350
+ - regex: .*
1351
+ message: >-
1352
+ Use of eval with user-controllable input detected. This can lead to attackers running arbitrary code. Ensure
1353
+ external data does not reach here, otherwise this is a security vulnerability. Consider other ways to do
1354
+ this without eval.
1355
+ cwe:
1356
+ - CWE-94
1357
+ owasp:
1358
+ - A03:2021
1359
+ - A05:2025
1360
+ references:
1361
+ - https://owasp.org/Top10/A03_2021-Injection
1362
+ tags:
1363
+ - ruby
1364
+ - rails
1365
+ - id: bad-send
1366
+ name: bad-send
1367
+ description: >-
1368
+ Checks for unsafe use of Object#send, try, __send__, and public_send. These only account for unsafe use of a
1369
+ method, not target. This can lead to arbitrary calling of exit, along with arbitrary code execution. Please be
1370
+ sure to sanitize input in order to avoid this.
1371
+ category: security
1372
+ severity: high
1373
+ confidence: medium
1374
+ languages:
1375
+ - ruby
1376
+ patterns:
1377
+ - pattern: |
1378
+ $PARAM = params[...]
1379
+ ...
1380
+ $RES = $MOD.send($PARAM.$FUNC)
1381
+ message: >-
1382
+ Checks for unsafe use of Object#send, try, __send__, and public_send. These only account for unsafe use of a
1383
+ method, not target. This can lead to arbitrary calling of exit, along with arbitrary code execution. Please be
1384
+ sure to sanitize input in order to avoid this.
1385
+ - pattern: |
1386
+ $PARAM = params[...]
1387
+ ...
1388
+ $RES = $MOD.try($PARAM.$FUNC)
1389
+ message: >-
1390
+ Checks for unsafe use of Object#send, try, __send__, and public_send. These only account for unsafe use of a
1391
+ method, not target. This can lead to arbitrary calling of exit, along with arbitrary code execution. Please be
1392
+ sure to sanitize input in order to avoid this.
1393
+ - pattern: |
1394
+ $PARAM = params[...]
1395
+ ...
1396
+ $RES = $MOD.__send__($PARAM.$FUNC)
1397
+ message: >-
1398
+ Checks for unsafe use of Object#send, try, __send__, and public_send. These only account for unsafe use of a
1399
+ method, not target. This can lead to arbitrary calling of exit, along with arbitrary code execution. Please be
1400
+ sure to sanitize input in order to avoid this.
1401
+ - pattern: |
1402
+ $PARAM = params[...]
1403
+ ...
1404
+ $RES = $MOD.public_send($PARAM.$FUNC)
1405
+ message: >-
1406
+ Checks for unsafe use of Object#send, try, __send__, and public_send. These only account for unsafe use of a
1407
+ method, not target. This can lead to arbitrary calling of exit, along with arbitrary code execution. Please be
1408
+ sure to sanitize input in order to avoid this.
1409
+ cwe:
1410
+ - CWE-94
1411
+ owasp:
1412
+ - A03:2021
1413
+ - A05:2025
1414
+ references:
1415
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_send.rb
1416
+ - https://the.igreque.info/posts/2016/01-object-send-considered-harmful-en.html
1417
+ tags:
1418
+ - ruby
1419
+ - id: ssl-mode-no-verify
1420
+ name: ssl-mode-no-verify
1421
+ description: >-
1422
+ Detected SSL that will accept an unverified connection. This makes the connections susceptible to
1423
+ man-in-the-middle attacks. Use 'OpenSSL::SSL::VERIFY_PEER' instead.
1424
+ category: security
1425
+ severity: medium
1426
+ confidence: medium
1427
+ languages:
1428
+ - ruby
1429
+ patterns:
1430
+ - pattern: OpenSSL::SSL::VERIFY_NONE
1431
+ message: >-
1432
+ Detected SSL that will accept an unverified connection. This makes the connections susceptible to
1433
+ man-in-the-middle attacks. Use 'OpenSSL::SSL::VERIFY_PEER' instead.
1434
+ cwe:
1435
+ - CWE-295
1436
+ owasp:
1437
+ - A03:2017
1438
+ - A07:2021
1439
+ - A07:2025
1440
+ references:
1441
+ - https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures
1442
+ tags:
1443
+ - ruby
1444
+ - id: mass-assignment-vuln
1445
+ name: mass-assignment-vuln
1446
+ description: >-
1447
+ Checks for calls to without_protection during mass assignment (which allows record creation from hash values).
1448
+ This can lead to users bypassing permissions protections. For Rails 4 and higher, mass protection is on by
1449
+ default. Fix: Don't use :without_protection => true. Instead, configure attr_accessible to control attribute
1450
+ access.
1451
+ category: security
1452
+ severity: medium
1453
+ confidence: medium
1454
+ languages:
1455
+ - ruby
1456
+ patterns:
1457
+ - regex: .*
1458
+ message: >-
1459
+ Checks for calls to without_protection during mass assignment (which allows record creation from hash values).
1460
+ This can lead to users bypassing permissions protections. For Rails 4 and higher, mass protection is on by
1461
+ default. Fix: Don't use :without_protection => true. Instead, configure attr_accessible to control attribute
1462
+ access.
1463
+ cwe:
1464
+ - CWE-915
1465
+ owasp:
1466
+ - A08:2021
1467
+ - A08:2025
1468
+ references:
1469
+ - https://github.com/presidentbeef/brakeman/blob/main/lib/brakeman/checks/check_without_protection.rb
1470
+ - https://www.acunetix.com/vulnerabilities/web/rails-mass-assignment/
1471
+ tags:
1472
+ - ruby
1473
+ - id: weak-hashes-md5
1474
+ name: weak-hashes-md5
1475
+ description: >-
1476
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1477
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1478
+ instead.
1479
+ category: crypto
1480
+ severity: medium
1481
+ confidence: medium
1482
+ languages:
1483
+ - ruby
1484
+ patterns:
1485
+ - pattern: Digest::MD5.base64digest $X
1486
+ message: >-
1487
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1488
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1489
+ instead.
1490
+ - pattern: Digest::MD5.hexdigest $X
1491
+ message: >-
1492
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1493
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1494
+ instead.
1495
+ - pattern: Digest::MD5.digest $X
1496
+ message: >-
1497
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1498
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1499
+ instead.
1500
+ - pattern: Digest::MD5.new
1501
+ message: >-
1502
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1503
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1504
+ instead.
1505
+ - pattern: OpenSSL::Digest::MD5.base64digest $X
1506
+ message: >-
1507
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1508
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1509
+ instead.
1510
+ - pattern: OpenSSL::Digest::MD5.hexdigest $X
1511
+ message: >-
1512
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1513
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1514
+ instead.
1515
+ - pattern: OpenSSL::Digest::MD5.digest $X
1516
+ message: >-
1517
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1518
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1519
+ instead.
1520
+ - pattern: OpenSSL::Digest::MD5.new
1521
+ message: >-
1522
+ Should not use md5 to generate hashes. md5 is proven to be vulnerable through the use of brute-force attacks.
1523
+ Could also result in collisions, leading to potential collision attacks. Use SHA256 or other hashing functions
1524
+ instead.
1525
+ cwe:
1526
+ - CWE-328
1527
+ owasp:
1528
+ - A03:2017
1529
+ - A02:2021
1530
+ - A04:2025
1531
+ references:
1532
+ - >-
1533
+ https://www.ibm.com/support/pages/security-bulletin-vulnerability-md5-signature-and-hash-algorithm-affects-sterling-integrator-and-sterling-file-gateway-cve-2015-7575
1534
+ tags:
1535
+ - ruby
1536
+ - id: weak-hashes-sha1
1537
+ name: weak-hashes-sha1
1538
+ description: >-
1539
+ Should not use SHA1 to generate hashes. There is a proven SHA1 hash collision by Google, which could lead to
1540
+ vulnerabilities. Use SHA256, SHA3 or other hashing functions instead.
1541
+ category: crypto
1542
+ severity: medium
1543
+ confidence: medium
1544
+ languages:
1545
+ - ruby
1546
+ patterns:
1547
+ - pattern: Digest::SHA1.$FUNC
1548
+ message: >-
1549
+ Should not use SHA1 to generate hashes. There is a proven SHA1 hash collision by Google, which could lead to
1550
+ vulnerabilities. Use SHA256, SHA3 or other hashing functions instead.
1551
+ - pattern: OpenSSL::Digest::SHA1.$FUNC
1552
+ message: >-
1553
+ Should not use SHA1 to generate hashes. There is a proven SHA1 hash collision by Google, which could lead to
1554
+ vulnerabilities. Use SHA256, SHA3 or other hashing functions instead.
1555
+ - pattern: OpenSSL::HMAC.$FUNC("sha1",...)
1556
+ message: >-
1557
+ Should not use SHA1 to generate hashes. There is a proven SHA1 hash collision by Google, which could lead to
1558
+ vulnerabilities. Use SHA256, SHA3 or other hashing functions instead.
1559
+ cwe:
1560
+ - CWE-328
1561
+ owasp:
1562
+ - A03:2017
1563
+ - A02:2021
1564
+ - A04:2025
1565
+ references:
1566
+ - https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html
1567
+ - https://shattered.io/
1568
+ tags:
1569
+ - ruby
1570
+ - id: rails-no-render-after-save
1571
+ name: rails-no-render-after-save
1572
+ description: >-
1573
+ Found a call to `render $T` after calling `$T.save`. Do not call `render` after calling `save` on an ActiveRecord
1574
+ object. Reloading the page will cause the state-changing operation to be repeated which may cause undesirable side
1575
+ effects. Use `redirect_to` instead.
1576
+ category: security
1577
+ severity: medium
1578
+ confidence: medium
1579
+ languages:
1580
+ - ruby
1581
+ patterns:
1582
+ - regex: .*
1583
+ message: >-
1584
+ Found a call to `render $T` after calling `$T.save`. Do not call `render` after calling `save` on an
1585
+ ActiveRecord object. Reloading the page will cause the state-changing operation to be repeated which may cause
1586
+ undesirable side effects. Use `redirect_to` instead.
1587
+ cwe: []
1588
+ owasp: []
1589
+ references:
1590
+ - https://guides.rubyonrails.org/getting_started.html#creating-a-new-article
1591
+ tags:
1592
+ - rails
1593
+ - ruby
1594
+ - activerecord
1595
+ - id: ruby-rails-performance-indexes-are-beneficial
1596
+ name: ruby-rails-performance-indexes-are-beneficial
1597
+ description: >-
1598
+ The $COLUMN column appears to be a foreign key. Would it benefit from an index? Having an index can improve
1599
+ performance.
1600
+ category: security
1601
+ severity: low
1602
+ confidence: medium
1603
+ languages:
1604
+ - ruby
1605
+ patterns:
1606
+ - pattern: |
1607
+ add_column $TABLE, $COLUMN, $TYPE, ...
1608
+ message: >-
1609
+ The $COLUMN column appears to be a foreign key. Would it benefit from an index? Having an index can improve
1610
+ performance.
1611
+ cwe: []
1612
+ owasp: []
1613
+ references:
1614
+ - https://archive.is/i7SLO
1615
+ tags:
1616
+ - rails
1617
+ - id: avoid-logging-everything
1618
+ name: avoid-logging-everything
1619
+ description: >-
1620
+ Avoid logging `params` and `params.inspect` as this bypasses Rails filter_parameters and may inadvertently log
1621
+ sensitive data. Instead, reference specific fields to ensure only expected data is logged.
1622
+ category: security
1623
+ severity: high
1624
+ confidence: medium
1625
+ languages:
1626
+ - ruby
1627
+ patterns:
1628
+ - regex: .*
1629
+ message: >-
1630
+ Avoid logging `params` and `params.inspect` as this bypasses Rails filter_parameters and may inadvertently log
1631
+ sensitive data. Instead, reference specific fields to ensure only expected data is logged.
1632
+ cwe:
1633
+ - CWE-532
1634
+ owasp: []
1635
+ references:
1636
+ - https://guides.rubyonrails.org/configuring.html#config-filter-parameters
1637
+ - https://api.rubyonrails.org/v7.1/classes/ActiveSupport/ParameterFilter.html
1638
+ tags:
1639
+ - rails
1640
+ - id: avoid-session-manipulation
1641
+ name: avoid-session-manipulation
1642
+ description: >-
1643
+ This gets data from session using user inputs. A malicious user may be able to retrieve information from your
1644
+ session that you didn't intend them to. Do not use user input as a session key.
1645
+ category: auth
1646
+ severity: medium
1647
+ confidence: medium
1648
+ languages:
1649
+ - ruby
1650
+ patterns:
1651
+ - regex: .*
1652
+ message: >-
1653
+ This gets data from session using user inputs. A malicious user may be able to retrieve information from your
1654
+ session that you didn't intend them to. Do not use user input as a session key.
1655
+ cwe:
1656
+ - CWE-276
1657
+ owasp:
1658
+ - A01:2021
1659
+ - A01:2025
1660
+ references:
1661
+ - https://brakemanscanner.org/docs/warning_types/session_manipulation/
1662
+ tags:
1663
+ - rails
1664
+ - id: avoid-tainted-file-access
1665
+ name: avoid-tainted-file-access
1666
+ description: >-
1667
+ Using user input when accessing files is potentially dangerous. A malicious actor could use this to modify or
1668
+ access files they have no right to.
1669
+ category: file-ops
1670
+ severity: medium
1671
+ confidence: medium
1672
+ languages:
1673
+ - ruby
1674
+ patterns:
1675
+ - regex: .*
1676
+ message: >-
1677
+ Using user input when accessing files is potentially dangerous. A malicious actor could use this to modify or
1678
+ access files they have no right to.
1679
+ cwe:
1680
+ - CWE-22
1681
+ owasp:
1682
+ - A05:2017
1683
+ - A01:2021
1684
+ - A01:2025
1685
+ references:
1686
+ - https://github.com/presidentbeef/brakeman/blob/main/docs/warning_types/file_access/index.markdown
1687
+ tags:
1688
+ - rails
1689
+ - id: avoid-tainted-ftp-call
1690
+ name: avoid-tainted-ftp-call
1691
+ description: >-
1692
+ Using user input when accessing files is potentially dangerous. A malicious actor could use this to modify or
1693
+ access files they have no right to.
1694
+ category: security
1695
+ severity: medium
1696
+ confidence: medium
1697
+ languages:
1698
+ - ruby
1699
+ patterns:
1700
+ - regex: .*
1701
+ message: >-
1702
+ Using user input when accessing files is potentially dangerous. A malicious actor could use this to modify or
1703
+ access files they have no right to.
1704
+ cwe:
1705
+ - CWE-22
1706
+ owasp:
1707
+ - A05:2017
1708
+ - A01:2021
1709
+ - A01:2025
1710
+ references:
1711
+ - https://github.com/presidentbeef/brakeman/blob/main/docs/warning_types/file_access/index.markdown
1712
+ tags:
1713
+ - rails
1714
+ - id: avoid-tainted-http-request
1715
+ name: avoid-tainted-http-request
1716
+ description: >-
1717
+ Using user input when accessing files is potentially dangerous. A malicious actor could use this to modify or
1718
+ access files they have no right to.
1719
+ category: security
1720
+ severity: medium
1721
+ confidence: medium
1722
+ languages:
1723
+ - ruby
1724
+ patterns:
1725
+ - regex: .*
1726
+ message: >-
1727
+ Using user input when accessing files is potentially dangerous. A malicious actor could use this to modify or
1728
+ access files they have no right to.
1729
+ cwe:
1730
+ - CWE-918
1731
+ owasp:
1732
+ - A10:2021
1733
+ - A01:2025
1734
+ references:
1735
+ - https://github.com/presidentbeef/brakeman/blob/main/docs/warning_types/file_access/index.markdown
1736
+ tags:
1737
+ - rails
1738
+ - id: avoid-tainted-shell-call
1739
+ name: avoid-tainted-shell-call
1740
+ description: >-
1741
+ Using user input when accessing files is potentially dangerous. A malicious actor could use this to modify or
1742
+ access files they have no right to.
1743
+ category: security
1744
+ severity: high
1745
+ confidence: medium
1746
+ languages:
1747
+ - ruby
1748
+ patterns:
1749
+ - regex: .*
1750
+ message: >-
1751
+ Using user input when accessing files is potentially dangerous. A malicious actor could use this to modify or
1752
+ access files they have no right to.
1753
+ cwe:
1754
+ - CWE-78
1755
+ owasp:
1756
+ - A01:2017
1757
+ - A03:2021
1758
+ - A05:2025
1759
+ references:
1760
+ - https://github.com/presidentbeef/brakeman/blob/main/docs/warning_types/file_access/index.markdown
1761
+ tags:
1762
+ - rails
1763
+ - id: detailed-exceptions
1764
+ name: detailed-exceptions
1765
+ description: >-
1766
+ Found that the setting for providing detailed exception reports in Rails is set to true. This can lead to
1767
+ information exposure, where sensitive system or internal information is displayed to the end user. Instead, turn
1768
+ this setting off.
1769
+ category: security
1770
+ severity: medium
1771
+ confidence: medium
1772
+ languages:
1773
+ - ruby
1774
+ patterns:
1775
+ - regex: .*
1776
+ message: >-
1777
+ Found that the setting for providing detailed exception reports in Rails is set to true. This can lead to
1778
+ information exposure, where sensitive system or internal information is displayed to the end user. Instead,
1779
+ turn this setting off.
1780
+ cwe:
1781
+ - CWE-200
1782
+ owasp:
1783
+ - A01:2021
1784
+ - A01:2025
1785
+ references:
1786
+ - https://owasp.org/Top10/A01_2021-Broken_Access_Control
1787
+ tags:
1788
+ - rails
1789
+ - id: rails-skip-forgery-protection
1790
+ name: rails-skip-forgery-protection
1791
+ description: This call turns off CSRF protection allowing CSRF attacks against the application
1792
+ category: security
1793
+ severity: medium
1794
+ confidence: medium
1795
+ languages:
1796
+ - ruby
1797
+ patterns:
1798
+ - pattern: skip_forgery_protection
1799
+ message: This call turns off CSRF protection allowing CSRF attacks against the application
1800
+ cwe:
1801
+ - CWE-352
1802
+ owasp:
1803
+ - A01:2021
1804
+ - A01:2025
1805
+ references:
1806
+ - >-
1807
+ https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#method-i-skip_forgery_protection
1808
+ tags:
1809
+ - rails
1810
+ - id: ruby-pg-sqli
1811
+ name: ruby-pg-sqli
1812
+ description: >-
1813
+ Detected string concatenation with a non-literal variable in a pg Ruby SQL statement. This could lead to SQL
1814
+ injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection, use
1815
+ parameterized queries or prepared statements instead. You can use parameterized queries like so:
1816
+ `conn.exec_params('SELECT $1 AS a, $2 AS b, $3 AS c', [1, 2, nil])` And you can use prepared statements with
1817
+ `exec_prepared`.
1818
+ category: injection
1819
+ severity: medium
1820
+ confidence: medium
1821
+ languages:
1822
+ - ruby
1823
+ patterns:
1824
+ - regex: .*
1825
+ message: >-
1826
+ Detected string concatenation with a non-literal variable in a pg Ruby SQL statement. This could lead to SQL
1827
+ injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection,
1828
+ use parameterized queries or prepared statements instead. You can use parameterized queries like so:
1829
+ `conn.exec_params('SELECT $1 AS a, $2 AS b, $3 AS c', [1, 2, nil])` And you can use prepared statements with
1830
+ `exec_prepared`.
1831
+ cwe:
1832
+ - CWE-89
1833
+ owasp:
1834
+ - A01:2017
1835
+ - A03:2021
1836
+ - A05:2025
1837
+ references:
1838
+ - https://www.rubydoc.info/gems/pg/PG/Connection
1839
+ tags:
1840
+ - rails
1841
+ - id: avoid-content-tag
1842
+ name: avoid-content-tag
1843
+ description: >-
1844
+ 'content_tag()' bypasses HTML escaping for some portion of the content. If external data can reach here, this
1845
+ exposes your application to cross-site scripting (XSS) attacks. Ensure no external data reaches here. If you must
1846
+ do this, create your HTML manually and use 'html_safe'. Ensure no external data enters the HTML-safe string!
1847
+ category: security
1848
+ severity: medium
1849
+ confidence: medium
1850
+ languages:
1851
+ - ruby
1852
+ patterns:
1853
+ - pattern: content_tag(...)
1854
+ message: >-
1855
+ 'content_tag()' bypasses HTML escaping for some portion of the content. If external data can reach here, this
1856
+ exposes your application to cross-site scripting (XSS) attacks. Ensure no external data reaches here. If you
1857
+ must do this, create your HTML manually and use 'html_safe'. Ensure no external data enters the HTML-safe
1858
+ string!
1859
+ cwe:
1860
+ - CWE-79
1861
+ owasp:
1862
+ - A07:2017
1863
+ - A03:2021
1864
+ - A05:2025
1865
+ references:
1866
+ - https://github.com/presidentbeef/brakeman/blob/main/docs/warning_types/template_injection/index.markdown
1867
+ - https://www.netsparker.com/blog/web-security/preventing-xss-ruby-on-rails-web-applications/
1868
+ tags:
1869
+ - rails
1870
+ - id: avoid-default-routes
1871
+ name: avoid-default-routes
1872
+ description: >-
1873
+ Default routes are enabled in this routes file. This means any public method on a controller can be called as an
1874
+ action. It is very easy to accidentally expose a method you didn't mean to. Instead, remove this line and
1875
+ explicitly include all routes you intend external users to follow.
1876
+ category: security
1877
+ severity: medium
1878
+ confidence: medium
1879
+ languages:
1880
+ - ruby
1881
+ patterns:
1882
+ - regex: .*
1883
+ message: >-
1884
+ Default routes are enabled in this routes file. This means any public method on a controller can be called as
1885
+ an action. It is very easy to accidentally expose a method you didn't mean to. Instead, remove this line and
1886
+ explicitly include all routes you intend external users to follow.
1887
+ cwe:
1888
+ - CWE-276
1889
+ owasp:
1890
+ - A01:2021
1891
+ - A01:2025
1892
+ references:
1893
+ - https://github.com/presidentbeef/brakeman/blob/main/docs/warning_types/default_routes/index.markdown
1894
+ tags:
1895
+ - rails
1896
+ - id: avoid-html-safe
1897
+ name: avoid-html-safe
1898
+ description: >-
1899
+ 'html_safe()' does not make the supplied string safe. 'html_safe()' bypasses HTML escaping. If external data can
1900
+ reach here, this exposes your application to cross-site scripting (XSS) attacks. Ensure no external data reaches
1901
+ here.
1902
+ category: security
1903
+ severity: medium
1904
+ confidence: medium
1905
+ languages:
1906
+ - ruby
1907
+ patterns:
1908
+ - pattern: $STR.html_safe
1909
+ message: >-
1910
+ 'html_safe()' does not make the supplied string safe. 'html_safe()' bypasses HTML escaping. If external data
1911
+ can reach here, this exposes your application to cross-site scripting (XSS) attacks. Ensure no external data
1912
+ reaches here.
1913
+ - pattern: $STR.html_safe.$MORE
1914
+ message: >-
1915
+ 'html_safe()' does not make the supplied string safe. 'html_safe()' bypasses HTML escaping. If external data
1916
+ can reach here, this exposes your application to cross-site scripting (XSS) attacks. Ensure no external data
1917
+ reaches here.
1918
+ cwe:
1919
+ - CWE-79
1920
+ owasp:
1921
+ - A07:2017
1922
+ - A03:2021
1923
+ - A05:2025
1924
+ references:
1925
+ - https://github.com/presidentbeef/brakeman/blob/main/docs/warning_types/cross_site_scripting/index.markdown
1926
+ - https://www.netsparker.com/blog/web-security/preventing-xss-ruby-on-rails-web-applications/
1927
+ tags:
1928
+ - rails
1929
+ - id: avoid-link-to
1930
+ name: avoid-link-to
1931
+ description: >-
1932
+ This code includes user input in `link_to`. In Rails 2.x, the body of `link_to` is not escaped. This means that
1933
+ user input which reaches the body will be executed when the HTML is rendered. Even in other versions, values
1934
+ starting with `javascript:` or `data:` are not escaped. It is better to create and use a safer function which
1935
+ checks the body argument.
1936
+ category: security
1937
+ severity: medium
1938
+ confidence: medium
1939
+ languages:
1940
+ - ruby
1941
+ patterns:
1942
+ - regex: .*
1943
+ message: >-
1944
+ This code includes user input in `link_to`. In Rails 2.x, the body of `link_to` is not escaped. This means
1945
+ that user input which reaches the body will be executed when the HTML is rendered. Even in other versions,
1946
+ values starting with `javascript:` or `data:` are not escaped. It is better to create and use a safer function
1947
+ which checks the body argument.
1948
+ cwe:
1949
+ - CWE-79
1950
+ owasp:
1951
+ - A07:2017
1952
+ - A03:2021
1953
+ - A05:2025
1954
+ references:
1955
+ - https://brakemanscanner.org/docs/warning_types/link_to/
1956
+ - https://brakemanscanner.org/docs/warning_types/link_to_href/
1957
+ tags:
1958
+ - rails
1959
+ - id: avoid-raw
1960
+ name: avoid-raw
1961
+ description: >-
1962
+ 'raw()' bypasses HTML escaping. If external data can reach here, this exposes your application to cross-site
1963
+ scripting (XSS) attacks. If you must do this, construct individual strings and mark them as safe for HTML
1964
+ rendering with `html_safe()`.
1965
+ category: security
1966
+ severity: medium
1967
+ confidence: medium
1968
+ languages:
1969
+ - ruby
1970
+ patterns:
1971
+ - pattern: raw(...)
1972
+ message: >-
1973
+ 'raw()' bypasses HTML escaping. If external data can reach here, this exposes your application to cross-site
1974
+ scripting (XSS) attacks. If you must do this, construct individual strings and mark them as safe for HTML
1975
+ rendering with `html_safe()`.
1976
+ cwe:
1977
+ - CWE-79
1978
+ owasp:
1979
+ - A07:2017
1980
+ - A03:2021
1981
+ - A05:2025
1982
+ references:
1983
+ - https://api.rubyonrails.org/classes/ActionView/Helpers/OutputSafetyHelper.html#method-i-raw
1984
+ - https://www.netsparker.com/blog/web-security/preventing-xss-ruby-on-rails-web-applications/
1985
+ tags:
1986
+ - rails
1987
+ - id: avoid-redirect
1988
+ name: avoid-redirect
1989
+ description: >-
1990
+ When a redirect uses user input, a malicious user can spoof a website under a trusted URL or access restricted
1991
+ parts of a site. When using user-supplied values, sanitize the value before using it for the redirect.
1992
+ category: security
1993
+ severity: medium
1994
+ confidence: medium
1995
+ languages:
1996
+ - ruby
1997
+ patterns:
1998
+ - regex: .*
1999
+ message: >-
2000
+ When a redirect uses user input, a malicious user can spoof a website under a trusted URL or access restricted
2001
+ parts of a site. When using user-supplied values, sanitize the value before using it for the redirect.
2002
+ cwe:
2003
+ - CWE-601
2004
+ owasp:
2005
+ - A01:2021
2006
+ - A01:2025
2007
+ references:
2008
+ - https://brakemanscanner.org/docs/warning_types/redirect/
2009
+ tags:
2010
+ - rails
2011
+ - id: avoid-render-dynamic-path
2012
+ name: avoid-render-dynamic-path
2013
+ description: >-
2014
+ Avoid rendering user input. It may be possible for a malicious user to input a path that lets them access a
2015
+ template they shouldn't. To prevent this, check dynamic template paths against a predefined allowlist to make sure
2016
+ it's an allowed template.
2017
+ category: file-ops
2018
+ severity: medium
2019
+ confidence: medium
2020
+ languages:
2021
+ - ruby
2022
+ patterns:
2023
+ - regex: .*
2024
+ message: >-
2025
+ Avoid rendering user input. It may be possible for a malicious user to input a path that lets them access a
2026
+ template they shouldn't. To prevent this, check dynamic template paths against a predefined allowlist to make
2027
+ sure it's an allowed template.
2028
+ cwe:
2029
+ - CWE-22
2030
+ owasp:
2031
+ - A05:2017
2032
+ - A01:2021
2033
+ - A01:2025
2034
+ references:
2035
+ - https://brakemanscanner.org/docs/warning_types/dynamic_render_paths/
2036
+ tags:
2037
+ - rails
2038
+ - id: avoid-render-inline
2039
+ name: avoid-render-inline
2040
+ description: >-
2041
+ 'render inline: ...' renders an entire ERB template inline and is dangerous. If external data can reach here, this
2042
+ exposes your application to server-side template injection (SSTI) or cross-site scripting (XSS) attacks. Instead,
2043
+ consider using a partial or another safe rendering method.
2044
+ category: security
2045
+ severity: medium
2046
+ confidence: medium
2047
+ languages:
2048
+ - ruby
2049
+ patterns:
2050
+ - pattern: 'render inline: ...'
2051
+ message: >-
2052
+ 'render inline: ...' renders an entire ERB template inline and is dangerous. If external data can reach here,
2053
+ this exposes your application to server-side template injection (SSTI) or cross-site scripting (XSS) attacks.
2054
+ Instead, consider using a partial or another safe rendering method.
2055
+ cwe:
2056
+ - CWE-79
2057
+ owasp:
2058
+ - A07:2017
2059
+ - A03:2021
2060
+ - A05:2025
2061
+ references:
2062
+ - https://brakemanpro.com/2017/09/08/cross-site-scripting-in-rails#inline-renders---even-worse-than-xss
2063
+ tags:
2064
+ - rails
2065
+ - id: avoid-render-text
2066
+ name: avoid-render-text
2067
+ description: >-
2068
+ 'render text: ...' actually sets the content-type to 'text/html'. If external data can reach here, this exposes
2069
+ your application to cross-site scripting (XSS) attacks. Instead, use 'render plain: ...' to render non-HTML text.
2070
+ category: security
2071
+ severity: medium
2072
+ confidence: medium
2073
+ languages:
2074
+ - ruby
2075
+ patterns:
2076
+ - pattern: 'render text: ...'
2077
+ message: >-
2078
+ 'render text: ...' actually sets the content-type to 'text/html'. If external data can reach here, this
2079
+ exposes your application to cross-site scripting (XSS) attacks. Instead, use 'render plain: ...' to render
2080
+ non-HTML text.
2081
+ cwe:
2082
+ - CWE-79
2083
+ owasp:
2084
+ - A07:2017
2085
+ - A03:2021
2086
+ - A05:2025
2087
+ references:
2088
+ - https://brakemanpro.com/2017/09/08/cross-site-scripting-in-rails#inline-renders---even-worse-than-xss
2089
+ tags:
2090
+ - rails
2091
+ - id: manual-template-creation
2092
+ name: manual-template-creation
2093
+ description: >-
2094
+ Detected manual creation of an ERB template. Manual creation of templates may expose your application to
2095
+ server-side template injection (SSTI) or cross-site scripting (XSS) attacks if user input is used to create the
2096
+ template. Instead, create a '.erb' template file and use 'render'.
2097
+ category: security
2098
+ severity: medium
2099
+ confidence: medium
2100
+ languages:
2101
+ - ruby
2102
+ patterns:
2103
+ - pattern: ERB.new(...)
2104
+ message: >-
2105
+ Detected manual creation of an ERB template. Manual creation of templates may expose your application to
2106
+ server-side template injection (SSTI) or cross-site scripting (XSS) attacks if user input is used to create
2107
+ the template. Instead, create a '.erb' template file and use 'render'.
2108
+ cwe:
2109
+ - CWE-79
2110
+ owasp:
2111
+ - A07:2017
2112
+ - A03:2021
2113
+ - A05:2025
2114
+ references:
2115
+ - https://github.com/presidentbeef/brakeman/blob/main/docs/warning_types/template_injection/index.markdown
2116
+ tags:
2117
+ - rails
2118
+ - id: libxml-backend
2119
+ name: libxml-backend
2120
+ description: >-
2121
+ This application is using LibXML as the XML backend. LibXML can be vulnerable to XML External Entities (XXE)
2122
+ vulnerabilities. Use the built-in Rails XML parser, REXML, instead.
2123
+ category: security
2124
+ severity: medium
2125
+ confidence: medium
2126
+ languages:
2127
+ - ruby
2128
+ patterns:
2129
+ - pattern: ActiveSupport::XmlMini.backend = "LibXML"
2130
+ message: >-
2131
+ This application is using LibXML as the XML backend. LibXML can be vulnerable to XML External Entities (XXE)
2132
+ vulnerabilities. Use the built-in Rails XML parser, REXML, instead.
2133
+ cwe:
2134
+ - CWE-611
2135
+ owasp:
2136
+ - A04:2017
2137
+ - A05:2021
2138
+ - A02:2025
2139
+ references:
2140
+ - https://www.stackhawk.com/blog/rails-xml-external-entities-xxe-guide-examples-and-prevention/
2141
+ - https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html
2142
+ tags:
2143
+ - rails
2144
+ - libxml
2145
+ - id: xml-external-entities-enabled
2146
+ name: xml-external-entities-enabled
2147
+ description: >-
2148
+ This application is explicitly enabling external entities enabling an attacker to inject malicious XML to exploit
2149
+ an XML External Entities (XXE) vulnerability. This could let the attacker cause a denial-of-service by forcing the
2150
+ parser to parse large files, or at worst, let the attacker download sensitive files or user data. Use the built-in
2151
+ Rails XML parser, REXML, instead.
2152
+ category: security
2153
+ severity: high
2154
+ confidence: medium
2155
+ languages:
2156
+ - ruby
2157
+ patterns:
2158
+ - pattern: XML.default_substitute_entities = true
2159
+ message: >-
2160
+ This application is explicitly enabling external entities enabling an attacker to inject malicious XML to
2161
+ exploit an XML External Entities (XXE) vulnerability. This could let the attacker cause a denial-of-service by
2162
+ forcing the parser to parse large files, or at worst, let the attacker download sensitive files or user data.
2163
+ Use the built-in Rails XML parser, REXML, instead.
2164
+ cwe:
2165
+ - CWE-611
2166
+ owasp:
2167
+ - A04:2017
2168
+ - A05:2021
2169
+ - A02:2025
2170
+ references:
2171
+ - https://www.stackhawk.com/blog/rails-xml-external-entities-xxe-guide-examples-and-prevention/
2172
+ - https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html
2173
+ tags:
2174
+ - rails
2175
+ - libxml
2176
+ - id: check-before-filter
2177
+ name: check-before-filter
2178
+ description: >-
2179
+ Disabled-by-default Rails controller checks make it much easier to introduce access control mistakes. Prefer an
2180
+ allowlist approach with `:only => [...]` rather than `except: => [...]`
2181
+ category: security
2182
+ severity: high
2183
+ confidence: medium
2184
+ languages:
2185
+ - ruby
2186
+ patterns:
2187
+ - regex: .*
2188
+ message: >-
2189
+ Disabled-by-default Rails controller checks make it much easier to introduce access control mistakes. Prefer
2190
+ an allowlist approach with `:only => [...]` rather than `except: => [...]`
2191
+ cwe:
2192
+ - CWE-284
2193
+ owasp:
2194
+ - A05:2017
2195
+ - A01:2021
2196
+ - A01:2025
2197
+ references:
2198
+ - https://owasp.org/Top10/A01_2021-Broken_Access_Control
2199
+ tags:
2200
+ - ruby
2201
+ - rails
2202
+ - id: check-cookie-store-session-security-attributes
2203
+ name: check-cookie-store-session-security-attributes
2204
+ description: >-
2205
+ Found a Rails `cookie_store` session configuration setting the `$KEY` attribute to `false`. If using a
2206
+ cookie-based session store, the HttpOnly and Secure flags should be set.
2207
+ category: auth
2208
+ severity: medium
2209
+ confidence: medium
2210
+ languages:
2211
+ - ruby
2212
+ patterns:
2213
+ - regex: .*
2214
+ message: >-
2215
+ Found a Rails `cookie_store` session configuration setting the `$KEY` attribute to `false`. If using a
2216
+ cookie-based session store, the HttpOnly and Secure flags should be set.
2217
+ cwe:
2218
+ - CWE-1004
2219
+ owasp:
2220
+ - A05:2021
2221
+ - A02:2025
2222
+ references:
2223
+ - >-
2224
+ https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/06-Session_Management_Testing/02-Testing_for_Cookies_Attributes
2225
+ tags:
2226
+ - ruby
2227
+ - rails
2228
+ - id: check-http-verb-confusion
2229
+ name: check-http-verb-confusion
2230
+ description: >-
2231
+ Found an improperly constructed control flow block with `request.get?`. Rails will route HEAD requests as GET
2232
+ requests but they will fail the `request.get?` check, potentially causing unexpected behavior unless an `elif`
2233
+ condition is used.
2234
+ category: security
2235
+ severity: high
2236
+ confidence: medium
2237
+ languages:
2238
+ - ruby
2239
+ patterns:
2240
+ - pattern: |
2241
+ if request.get?
2242
+ ...
2243
+ else
2244
+ ...
2245
+ end
2246
+ message: >-
2247
+ Found an improperly constructed control flow block with `request.get?`. Rails will route HEAD requests as GET
2248
+ requests but they will fail the `request.get?` check, potentially causing unexpected behavior unless an `elif`
2249
+ condition is used.
2250
+ cwe:
2251
+ - CWE-650
2252
+ owasp:
2253
+ - A04:2021
2254
+ - A06:2025
2255
+ references:
2256
+ - https://github.com/presidentbeef/brakeman/blob/main/test/apps/rails6/app/controllers/accounts_controller.rb
2257
+ tags:
2258
+ - ruby
2259
+ - rails
2260
+ - id: check-permit-attributes-high
2261
+ name: check-permit-attributes-high
2262
+ description: >-
2263
+ Calling `permit` on security-critical properties like `$ATTRIBUTE` may leave your application vulnerable to mass
2264
+ assignment.
2265
+ category: security
2266
+ severity: high
2267
+ confidence: medium
2268
+ languages:
2269
+ - ruby
2270
+ patterns:
2271
+ - pattern: $P.permit($ATTRIBUTE)
2272
+ message: >-
2273
+ Calling `permit` on security-critical properties like `$ATTRIBUTE` may leave your application vulnerable to
2274
+ mass assignment.
2275
+ cwe:
2276
+ - CWE-915
2277
+ owasp:
2278
+ - A08:2021
2279
+ - A08:2025
2280
+ references:
2281
+ - https://cheatsheetseries.owasp.org/cheatsheets/Mass_Assignment_Cheat_Sheet.html
2282
+ tags:
2283
+ - ruby
2284
+ - rails
2285
+ - id: check-permit-attributes-medium
2286
+ name: check-permit-attributes-medium
2287
+ description: >-
2288
+ Calling `permit` on security-critical properties like `$ATTRIBUTE` may leave your application vulnerable to mass
2289
+ assignment.
2290
+ category: security
2291
+ severity: medium
2292
+ confidence: medium
2293
+ languages:
2294
+ - ruby
2295
+ patterns:
2296
+ - pattern: $P.permit($ATTRIBUTE)
2297
+ message: >-
2298
+ Calling `permit` on security-critical properties like `$ATTRIBUTE` may leave your application vulnerable to
2299
+ mass assignment.
2300
+ cwe:
2301
+ - CWE-915
2302
+ owasp:
2303
+ - A08:2021
2304
+ - A08:2025
2305
+ references:
2306
+ - https://cheatsheetseries.owasp.org/cheatsheets/Mass_Assignment_Cheat_Sheet.html
2307
+ tags:
2308
+ - ruby
2309
+ - rails
2310
+ - id: check-rails-session-secret-handling
2311
+ name: check-rails-session-secret-handling
2312
+ description: >-
2313
+ Found a string literal assignment to a Rails session secret `$KEY`. Do not commit secret values to source control!
2314
+ Any user in possession of this value may falsify arbitrary session data in your application. Read this value from
2315
+ an environment variable, KMS, or file on disk outside of source control.
2316
+ category: secrets
2317
+ severity: medium
2318
+ confidence: medium
2319
+ languages:
2320
+ - ruby
2321
+ patterns:
2322
+ - regex: .*
2323
+ message: >-
2324
+ Found a string literal assignment to a Rails session secret `$KEY`. Do not commit secret values to source
2325
+ control! Any user in possession of this value may falsify arbitrary session data in your application. Read
2326
+ this value from an environment variable, KMS, or file on disk outside of source control.
2327
+ cwe:
2328
+ - CWE-540
2329
+ owasp:
2330
+ - A01:2021
2331
+ - A01:2025
2332
+ references:
2333
+ - >-
2334
+ https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/06-Session_Management_Testing/02-Testing_for_Cookies_Attributes
2335
+ - >-
2336
+ https://github.com/presidentbeef/brakeman/blob/main/test/apps/rails4_with_engines/config/initializers/secret_token.rb
2337
+ - https://github.com/presidentbeef/brakeman/blob/main/test/apps/rails3/config/initializers/secret_token.rb
2338
+ tags:
2339
+ - ruby
2340
+ - rails
2341
+ - id: check-redirect-to
2342
+ name: check-redirect-to
2343
+ description: >-
2344
+ Found potentially unsafe handling of redirect behavior $X. Do not pass `params` to `redirect_to` without the
2345
+ `:only_path => true` hash value.
2346
+ category: security
2347
+ severity: medium
2348
+ confidence: medium
2349
+ languages:
2350
+ - ruby
2351
+ patterns:
2352
+ - regex: .*
2353
+ message: >-
2354
+ Found potentially unsafe handling of redirect behavior $X. Do not pass `params` to `redirect_to` without the
2355
+ `:only_path => true` hash value.
2356
+ cwe:
2357
+ - CWE-601
2358
+ owasp:
2359
+ - A01:2021
2360
+ - A01:2025
2361
+ references:
2362
+ - https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html
2363
+ tags:
2364
+ - ruby
2365
+ - rails
2366
+ - id: check-regex-dos
2367
+ name: check-regex-dos
2368
+ description: >-
2369
+ Found a potentially user-controllable argument in the construction of a regular expressions. This may result in
2370
+ excessive resource consumption when applied to certain inputs, or when the user is allowed to control the match
2371
+ target. Avoid allowing users to specify regular expressions processed by the server. If you must support
2372
+ user-controllable input in a regular expression, use an allow-list to restrict the expressions users may supply to
2373
+ limit catastrophic backtracking.
2374
+ category: security
2375
+ severity: high
2376
+ confidence: medium
2377
+ languages:
2378
+ - ruby
2379
+ patterns:
2380
+ - regex: .*
2381
+ message: >-
2382
+ Found a potentially user-controllable argument in the construction of a regular expressions. This may result
2383
+ in excessive resource consumption when applied to certain inputs, or when the user is allowed to control the
2384
+ match target. Avoid allowing users to specify regular expressions processed by the server. If you must support
2385
+ user-controllable input in a regular expression, use an allow-list to restrict the expressions users may
2386
+ supply to limit catastrophic backtracking.
2387
+ cwe:
2388
+ - CWE-1333
2389
+ owasp:
2390
+ - A03:2017
2391
+ references:
2392
+ - https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
2393
+ tags:
2394
+ - ruby
2395
+ - rails
2396
+ - id: check-render-local-file-include
2397
+ name: check-render-local-file-include
2398
+ description: >-
2399
+ Found request parameters in a call to `render`. This can allow end users to request arbitrary local files which
2400
+ may result in leaking sensitive information persisted on disk. Where possible, avoid letting users specify
2401
+ template paths for `render`. If you must allow user input, use an allow-list of known templates or normalize the
2402
+ user-supplied value with `File.basename(...)`.
2403
+ category: file-ops
2404
+ severity: medium
2405
+ confidence: medium
2406
+ languages:
2407
+ - ruby
2408
+ patterns:
2409
+ - regex: .*
2410
+ message: >-
2411
+ Found request parameters in a call to `render`. This can allow end users to request arbitrary local files
2412
+ which may result in leaking sensitive information persisted on disk. Where possible, avoid letting users
2413
+ specify template paths for `render`. If you must allow user input, use an allow-list of known templates or
2414
+ normalize the user-supplied value with `File.basename(...)`.
2415
+ cwe:
2416
+ - CWE-22
2417
+ owasp:
2418
+ - A05:2017
2419
+ - A01:2021
2420
+ - A01:2025
2421
+ references:
2422
+ - >-
2423
+ https://owasp.org/www-project-web-security-testing-guide/v42/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.1-Testing_for_Local_File_Inclusion
2424
+ - >-
2425
+ https://github.com/presidentbeef/brakeman/blob/f74cb53/test/apps/rails2/app/controllers/home_controller.rb#L48-L60
2426
+ tags:
2427
+ - ruby
2428
+ - rails
2429
+ - id: check-secrets
2430
+ name: check-secrets
2431
+ description: >-
2432
+ Found a Brakeman-style secret - a variable with the name password/secret/api_key/rest_auth_site_key and a
2433
+ non-empty string literal value.
2434
+ category: secrets
2435
+ severity: medium
2436
+ confidence: medium
2437
+ languages:
2438
+ - ruby
2439
+ patterns:
2440
+ - pattern: $VAR = "$VALUE"
2441
+ message: >-
2442
+ Found a Brakeman-style secret - a variable with the name password/secret/api_key/rest_auth_site_key and a
2443
+ non-empty string literal value.
2444
+ cwe:
2445
+ - CWE-200
2446
+ owasp:
2447
+ - A01:2021
2448
+ - A01:2025
2449
+ references:
2450
+ - https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
2451
+ - >-
2452
+ https://github.com/presidentbeef/brakeman/blob/3f5d5d5f00864cdf7769c50f5bd26f1769a4ba75/test/apps/rails3.1/app/controllers/users_controller.rb
2453
+ tags:
2454
+ - ruby
2455
+ - rails
2456
+ - id: check-send-file
2457
+ name: check-send-file
2458
+ description: >-
2459
+ Allowing user input to `send_file` allows a malicious user to potentially read arbitrary files from the server.
2460
+ Avoid accepting user input in `send_file` or normalize with `File.basename(...)`
2461
+ category: file-ops
2462
+ severity: high
2463
+ confidence: medium
2464
+ languages:
2465
+ - ruby
2466
+ patterns:
2467
+ - regex: .*
2468
+ message: >-
2469
+ Allowing user input to `send_file` allows a malicious user to potentially read arbitrary files from the
2470
+ server. Avoid accepting user input in `send_file` or normalize with `File.basename(...)`
2471
+ cwe:
2472
+ - CWE-73
2473
+ owasp:
2474
+ - A04:2021
2475
+ - A06:2025
2476
+ references:
2477
+ - https://owasp.org/www-community/attacks/Path_Traversal
2478
+ - https://owasp.org/Top10/A01_2021-Broken_Access_Control/
2479
+ tags:
2480
+ - ruby
2481
+ - rails
2482
+ - id: check-sql
2483
+ name: check-sql
2484
+ description: >-
2485
+ Found potential SQL injection due to unsafe SQL query construction via $X. Where possible, prefer parameterized
2486
+ queries.
2487
+ category: injection
2488
+ severity: high
2489
+ confidence: medium
2490
+ languages:
2491
+ - ruby
2492
+ patterns:
2493
+ - regex: .*
2494
+ message: >-
2495
+ Found potential SQL injection due to unsafe SQL query construction via $X. Where possible, prefer
2496
+ parameterized queries.
2497
+ cwe:
2498
+ - CWE-89
2499
+ owasp:
2500
+ - A01:2017
2501
+ - A03:2021
2502
+ - A05:2025
2503
+ references:
2504
+ - https://owasp.org/www-community/attacks/SQL_Injection
2505
+ - https://github.com/presidentbeef/brakeman/blob/main/test/apps/rails3.1/app/models/product.rb
2506
+ tags:
2507
+ - ruby
2508
+ - rails
2509
+ - id: check-unsafe-reflection-methods
2510
+ name: check-unsafe-reflection-methods
2511
+ description: >-
2512
+ Found user-controllable input to a reflection method. This may allow a user to alter program behavior and
2513
+ potentially execute arbitrary instructions in the context of the process. Do not provide arbitrary user input to
2514
+ `tap`, `method`, or `to_proc`
2515
+ category: security
2516
+ severity: high
2517
+ confidence: medium
2518
+ languages:
2519
+ - ruby
2520
+ patterns:
2521
+ - regex: .*
2522
+ message: >-
2523
+ Found user-controllable input to a reflection method. This may allow a user to alter program behavior and
2524
+ potentially execute arbitrary instructions in the context of the process. Do not provide arbitrary user input
2525
+ to `tap`, `method`, or `to_proc`
2526
+ cwe:
2527
+ - CWE-94
2528
+ owasp:
2529
+ - A03:2021
2530
+ - A05:2025
2531
+ references:
2532
+ - https://github.com/presidentbeef/brakeman/blob/main/test/apps/rails6/app/controllers/groups_controller.rb
2533
+ tags:
2534
+ - ruby
2535
+ - rails
2536
+ - id: check-unsafe-reflection
2537
+ name: check-unsafe-reflection
2538
+ description: >-
2539
+ Found user-controllable input to Ruby reflection functionality. This allows a remote user to influence runtime
2540
+ behavior, up to and including arbitrary remote code execution. Do not provide user-controllable input to
2541
+ reflection functionality. Do not call symbol conversion on user-controllable input.
2542
+ category: security
2543
+ severity: high
2544
+ confidence: medium
2545
+ languages:
2546
+ - ruby
2547
+ patterns:
2548
+ - regex: .*
2549
+ message: >-
2550
+ Found user-controllable input to Ruby reflection functionality. This allows a remote user to influence runtime
2551
+ behavior, up to and including arbitrary remote code execution. Do not provide user-controllable input to
2552
+ reflection functionality. Do not call symbol conversion on user-controllable input.
2553
+ cwe:
2554
+ - CWE-94
2555
+ owasp:
2556
+ - A03:2021
2557
+ - A05:2025
2558
+ references:
2559
+ - https://github.com/presidentbeef/brakeman/blob/main/test/apps/rails2/app/controllers/application_controller.rb
2560
+ tags:
2561
+ - ruby
2562
+ - rails
2563
+ - id: check-unscoped-find
2564
+ name: check-unscoped-find
2565
+ description: >-
2566
+ Found an unscoped `find(...)` with user-controllable input. If the ActiveRecord model being searched against is
2567
+ sensitive, this may lead to Insecure Direct Object Reference (IDOR) behavior and allow users to read arbitrary
2568
+ records. Scope the find to the current user, e.g. `current_user.accounts.find(params[:id])`.
2569
+ category: security
2570
+ severity: medium
2571
+ confidence: medium
2572
+ languages:
2573
+ - ruby
2574
+ patterns:
2575
+ - regex: .*
2576
+ message: >-
2577
+ Found an unscoped `find(...)` with user-controllable input. If the ActiveRecord model being searched against
2578
+ is sensitive, this may lead to Insecure Direct Object Reference (IDOR) behavior and allow users to read
2579
+ arbitrary records. Scope the find to the current user, e.g. `current_user.accounts.find(params[:id])`.
2580
+ cwe:
2581
+ - CWE-639
2582
+ owasp:
2583
+ - A05:2017
2584
+ - A01:2021
2585
+ - A01:2025
2586
+ references:
2587
+ - https://brakemanscanner.org/docs/warning_types/unscoped_find/
2588
+ - https://github.com/presidentbeef/brakeman/blob/main/test/apps/rails3.1/app/controllers/users_controller.rb
2589
+ tags:
2590
+ - ruby
2591
+ - rails
2592
+ - id: check-validation-regex
2593
+ name: check-validation-regex
2594
+ description: >-
2595
+ $V Found an incorrectly-bounded regex passed to `validates_format_of` or `validate ... format => ...`. Ruby regex
2596
+ behavior is multiline by default and lines should be terminated by `\A` for beginning of line and `\Z` for end of
2597
+ line, respectively.
2598
+ category: security
2599
+ severity: high
2600
+ confidence: medium
2601
+ languages:
2602
+ - ruby
2603
+ patterns:
2604
+ - regex: .*
2605
+ message: >-
2606
+ $V Found an incorrectly-bounded regex passed to `validates_format_of` or `validate ... format => ...`. Ruby
2607
+ regex behavior is multiline by default and lines should be terminated by `\A` for beginning of line and `\Z`
2608
+ for end of line, respectively.
2609
+ cwe:
2610
+ - CWE-185
2611
+ owasp:
2612
+ - A05:2017
2613
+ - A01:2021
2614
+ - A01:2025
2615
+ references:
2616
+ - https://brakemanscanner.org/docs/warning_types/format_validation/
2617
+ - >-
2618
+ https://github.com/presidentbeef/brakeman/blob/aef6253a8b7bcb97116f2af1ed2a561a6ae35bd5/test/apps/rails3/app/models/account.rb
2619
+ - https://github.com/presidentbeef/brakeman/blob/main/test/apps/rails3.1/app/models/account.rb
2620
+ tags:
2621
+ - ruby
2622
+ - rails
2623
+ - id: raw-html-format
2624
+ name: raw-html-format
2625
+ description: >-
2626
+ Detected user input flowing into a manually constructed HTML string. You may be accidentally bypassing secure
2627
+ methods of rendering HTML by manually constructing HTML and this could create a cross-site scripting
2628
+ vulnerability, which could let attackers steal sensitive user data. Use the `render template` and make template
2629
+ files which will safely render HTML instead, or inspect that the HTML is absolutely rendered safely with a
2630
+ function like `sanitize`.
2631
+ category: security
2632
+ severity: medium
2633
+ confidence: medium
2634
+ languages:
2635
+ - ruby
2636
+ patterns:
2637
+ - regex: .*
2638
+ message: >-
2639
+ Detected user input flowing into a manually constructed HTML string. You may be accidentally bypassing secure
2640
+ methods of rendering HTML by manually constructing HTML and this could create a cross-site scripting
2641
+ vulnerability, which could let attackers steal sensitive user data. Use the `render template` and make
2642
+ template files which will safely render HTML instead, or inspect that the HTML is absolutely rendered safely
2643
+ with a function like `sanitize`.
2644
+ cwe:
2645
+ - CWE-79
2646
+ owasp:
2647
+ - A07:2017
2648
+ - A03:2021
2649
+ - A05:2025
2650
+ references:
2651
+ - https://www.netsparker.com/blog/web-security/preventing-xss-ruby-on-rails-web-applications/
2652
+ - https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html
2653
+ tags:
2654
+ - rails
2655
+ - id: tainted-url-host
2656
+ name: tainted-url-host
2657
+ description: >-
2658
+ User data flows into the host portion of this manually-constructed URL. This could allow an attacker to send data
2659
+ to their own server, potentially exposing sensitive data such as cookies or authorization information sent with
2660
+ this request. They could also probe internal servers or other resources that the server running this code can
2661
+ access. (This is called server-side request forgery, or SSRF.) Do not allow arbitrary hosts. Use the `ssrf_filter`
2662
+ gem and guard the url construction with `SsrfFilter(...)`, or create an allowlist for approved hosts.
2663
+ category: security
2664
+ severity: medium
2665
+ confidence: medium
2666
+ languages:
2667
+ - ruby
2668
+ patterns:
2669
+ - regex: .*
2670
+ message: >-
2671
+ User data flows into the host portion of this manually-constructed URL. This could allow an attacker to send
2672
+ data to their own server, potentially exposing sensitive data such as cookies or authorization information
2673
+ sent with this request. They could also probe internal servers or other resources that the server running this
2674
+ code can access. (This is called server-side request forgery, or SSRF.) Do not allow arbitrary hosts. Use the
2675
+ `ssrf_filter` gem and guard the url construction with `SsrfFilter(...)`, or create an allowlist for approved
2676
+ hosts.
2677
+ cwe:
2678
+ - CWE-79
2679
+ owasp:
2680
+ - A07:2017
2681
+ - A03:2021
2682
+ - A05:2025
2683
+ references:
2684
+ - https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
2685
+ - https://github.com/arkadiyt/ssrf_filter
2686
+ tags:
2687
+ - rails