brakeman-min 4.3.1 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +24 -1
- data/README.md +35 -6
- data/bin/brakeman +2 -0
- data/lib/brakeman.rb +5 -3
- data/lib/brakeman/app_tree.rb +15 -1
- data/lib/brakeman/call_index.rb +7 -4
- data/lib/brakeman/checks.rb +16 -8
- data/lib/brakeman/checks/base_check.rb +2 -19
- data/lib/brakeman/checks/check_basic_auth_timing_attack.rb +1 -1
- data/lib/brakeman/checks/check_content_tag.rb +4 -4
- data/lib/brakeman/checks/check_create_with.rb +1 -1
- data/lib/brakeman/checks/check_cross_site_scripting.rb +3 -3
- data/lib/brakeman/checks/check_default_routes.rb +3 -3
- data/lib/brakeman/checks/check_deserialize.rb +1 -1
- data/lib/brakeman/checks/check_detailed_exceptions.rb +1 -1
- data/lib/brakeman/checks/check_digest_dos.rb +4 -4
- data/lib/brakeman/checks/check_escape_function.rb +1 -1
- data/lib/brakeman/checks/check_execute.rb +5 -4
- data/lib/brakeman/checks/check_file_access.rb +13 -3
- data/lib/brakeman/checks/check_file_disclosure.rb +1 -1
- data/lib/brakeman/checks/check_filter_skipping.rb +1 -1
- data/lib/brakeman/checks/check_forgery_setting.rb +3 -3
- data/lib/brakeman/checks/check_header_dos.rb +3 -3
- data/lib/brakeman/checks/check_i18n_xss.rb +3 -3
- data/lib/brakeman/checks/check_jruby_xml.rb +1 -1
- data/lib/brakeman/checks/check_json_encoding.rb +3 -3
- data/lib/brakeman/checks/check_json_parsing.rb +8 -11
- data/lib/brakeman/checks/check_link_to.rb +3 -3
- data/lib/brakeman/checks/check_link_to_href.rb +2 -2
- data/lib/brakeman/checks/check_mail_to.rb +3 -3
- data/lib/brakeman/checks/check_mime_type_dos.rb +1 -1
- data/lib/brakeman/checks/check_model_attributes.rb +4 -4
- data/lib/brakeman/checks/check_model_serialize.rb +1 -1
- data/lib/brakeman/checks/check_nested_attributes.rb +3 -3
- data/lib/brakeman/checks/check_nested_attributes_bypass.rb +1 -1
- data/lib/brakeman/checks/check_number_to_currency.rb +4 -4
- data/lib/brakeman/checks/check_quote_table_name.rb +2 -2
- data/lib/brakeman/checks/check_regex_dos.rb +1 -1
- data/lib/brakeman/checks/check_render.rb +2 -2
- data/lib/brakeman/checks/check_render_dos.rb +1 -1
- data/lib/brakeman/checks/check_render_inline.rb +1 -1
- data/lib/brakeman/checks/check_response_splitting.rb +1 -1
- data/lib/brakeman/checks/check_route_dos.rb +1 -1
- data/lib/brakeman/checks/check_safe_buffer_manipulation.rb +1 -1
- data/lib/brakeman/checks/check_sanitize_methods.rb +3 -3
- data/lib/brakeman/checks/check_secrets.rb +1 -1
- data/lib/brakeman/checks/check_select_tag.rb +1 -1
- data/lib/brakeman/checks/check_select_vulnerability.rb +1 -1
- data/lib/brakeman/checks/check_session_manipulation.rb +1 -1
- data/lib/brakeman/checks/check_session_settings.rb +1 -1
- data/lib/brakeman/checks/check_simple_format.rb +2 -2
- data/lib/brakeman/checks/check_single_quotes.rb +14 -10
- data/lib/brakeman/checks/check_skip_before_filter.rb +2 -2
- data/lib/brakeman/checks/check_sprockets_path_traversal.rb +39 -0
- data/lib/brakeman/checks/check_sql.rb +1 -1
- data/lib/brakeman/checks/check_sql_cves.rb +2 -2
- data/lib/brakeman/checks/check_strip_tags.rb +10 -8
- data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
- data/lib/brakeman/checks/check_symbol_dos_cve.rb +1 -1
- data/lib/brakeman/checks/check_translate_bug.rb +7 -7
- data/lib/brakeman/checks/check_unsafe_reflection.rb +1 -1
- data/lib/brakeman/checks/check_unscoped_find.rb +1 -1
- data/lib/brakeman/checks/check_validation_regex.rb +1 -1
- data/lib/brakeman/checks/check_weak_hash.rb +18 -19
- data/lib/brakeman/checks/check_xml_dos.rb +1 -1
- data/lib/brakeman/checks/check_yaml_parsing.rb +1 -1
- data/lib/brakeman/format/style.css +8 -0
- data/lib/brakeman/messages.rb +220 -0
- data/lib/brakeman/options.rb +13 -0
- data/lib/brakeman/parsers/template_parser.rb +2 -2
- data/lib/brakeman/processors/alias_processor.rb +7 -0
- data/lib/brakeman/processors/config_processor.rb +4 -1
- data/lib/brakeman/processors/gem_processor.rb +30 -2
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -1
- data/lib/brakeman/processors/lib/rails3_route_processor.rb +0 -2
- data/lib/brakeman/processors/lib/rails4_config_processor.rb +18 -0
- data/lib/brakeman/processors/lib/render_helper.rb +5 -0
- data/lib/brakeman/processors/lib/render_path.rb +15 -0
- data/lib/brakeman/processors/library_processor.rb +1 -1
- data/lib/brakeman/report/report_base.rb +17 -161
- data/lib/brakeman/report/report_csv.rb +17 -0
- data/lib/brakeman/report/report_html.rb +34 -31
- data/lib/brakeman/report/report_json.rb +21 -0
- data/lib/brakeman/report/report_markdown.rb +13 -6
- data/lib/brakeman/report/report_table.rb +157 -0
- data/lib/brakeman/report/report_tabs.rb +3 -1
- data/lib/brakeman/report/report_text.rb +16 -0
- data/lib/brakeman/scanner.rb +5 -1
- data/lib/brakeman/tracker/config.rb +1 -1
- data/lib/brakeman/util.rb +0 -17
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman/warning.rb +9 -4
- data/lib/brakeman/warning_codes.rb +1 -0
- metadata +9 -6
@@ -39,7 +39,7 @@ class Brakeman::CheckDetailedExceptions < Brakeman::BaseCheck
|
|
39
39
|
|
40
40
|
warn :warning_type => "Information Disclosure",
|
41
41
|
:warning_code => :detailed_exceptions,
|
42
|
-
:message => "Detailed exceptions may be enabled in
|
42
|
+
:message => msg("Detailed exceptions may be enabled in ", msg_code("show_detailed_exceptions?")),
|
43
43
|
:confidence => confidence,
|
44
44
|
:code => src,
|
45
45
|
:file => definition[:file]
|
@@ -6,14 +6,14 @@ class Brakeman::CheckDigestDoS < Brakeman::BaseCheck
|
|
6
6
|
@description = "Checks for digest authentication DoS vulnerability"
|
7
7
|
|
8
8
|
def run_check
|
9
|
-
message = "Vulnerability in digest authentication (CVE-2012-3424). Upgrade to
|
9
|
+
message = msg("Vulnerability in digest authentication ", msg_cve("CVE-2012-3424"), ". Upgrade to ")
|
10
10
|
|
11
11
|
if version_between? "3.0.0", "3.0.15"
|
12
|
-
message << "3.0.16"
|
12
|
+
message << msg_version("3.0.16")
|
13
13
|
elsif version_between? "3.1.0", "3.1.6"
|
14
|
-
message << "3.1.7"
|
14
|
+
message << msg_version("3.1.7")
|
15
15
|
elsif version_between? "3.2.0", "3.2.5"
|
16
|
-
message << "3.2.7"
|
16
|
+
message << msg_version("3.2.7")
|
17
17
|
else
|
18
18
|
return
|
19
19
|
end
|
@@ -12,7 +12,7 @@ class Brakeman::CheckEscapeFunction < Brakeman::BaseCheck
|
|
12
12
|
|
13
13
|
warn :warning_type => 'Cross-Site Scripting',
|
14
14
|
:warning_code => :CVE_2011_2932,
|
15
|
-
:message =>
|
15
|
+
:message => msg("Rails versions before 2.3.14 have a vulnerability in the ", msg_code("escape"), " method when used with Ruby 1.8 ", msg_cve("CVE-2011-2932")),
|
16
16
|
:confidence => :high,
|
17
17
|
:gem_info => gemfile_or_environment,
|
18
18
|
:link_path => "https://groups.google.com/d/topic/rubyonrails-security/Vr_7WSOrEZU/discussion"
|
@@ -18,7 +18,8 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
|
|
18
18
|
s(:call, s(:const, :Rails), :env),
|
19
19
|
s(:call, s(:const, :Process), :pid)]
|
20
20
|
|
21
|
-
|
21
|
+
SHELL_ESCAPE_MODULE_METHODS = Set[:escape, :join, :shellescape, :shelljoin]
|
22
|
+
SHELL_ESCAPE_MIXIN_METHODS = Set[:shellescape, :shelljoin]
|
22
23
|
|
23
24
|
SHELLWORDS = s(:const, :Shellwords)
|
24
25
|
|
@@ -82,7 +83,7 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
|
|
82
83
|
warn :result => result,
|
83
84
|
:warning_type => "Command Injection",
|
84
85
|
:warning_code => :command_injection,
|
85
|
-
:message => "Possible command injection in open
|
86
|
+
:message => msg("Possible command injection in ", msg_code("open")),
|
86
87
|
:user_input => match,
|
87
88
|
:confidence => :high
|
88
89
|
end
|
@@ -178,9 +179,9 @@ class Brakeman::CheckExecute < Brakeman::BaseCheck
|
|
178
179
|
def shell_escape? exp
|
179
180
|
return false unless call? exp
|
180
181
|
|
181
|
-
if exp.target == SHELLWORDS and
|
182
|
+
if exp.target == SHELLWORDS and SHELL_ESCAPE_MODULE_METHODS.include? exp.method
|
182
183
|
true
|
183
|
-
elsif exp.method
|
184
|
+
elsif SHELL_ESCAPE_MIXIN_METHODS.include?(exp.method)
|
184
185
|
true
|
185
186
|
else
|
186
187
|
false
|
@@ -29,8 +29,11 @@ class Brakeman::CheckFileAccess < Brakeman::BaseCheck
|
|
29
29
|
def process_result result
|
30
30
|
return unless original? result
|
31
31
|
call = result[:call]
|
32
|
+
|
32
33
|
file_name = call.first_arg
|
33
34
|
|
35
|
+
return if called_on_tempfile?(file_name)
|
36
|
+
|
34
37
|
if match = has_immediate_user_input?(file_name)
|
35
38
|
confidence = :high
|
36
39
|
elsif match = has_immediate_model?(file_name)
|
@@ -47,9 +50,9 @@ class Brakeman::CheckFileAccess < Brakeman::BaseCheck
|
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
|
-
if match and not
|
53
|
+
if match and not temp_file_method? match.match
|
51
54
|
|
52
|
-
message =
|
55
|
+
message = msg(msg_input(match), " used in file name")
|
53
56
|
|
54
57
|
warn :result => result,
|
55
58
|
:warning_type => "File Access",
|
@@ -61,7 +64,14 @@ class Brakeman::CheckFileAccess < Brakeman::BaseCheck
|
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
64
|
-
|
67
|
+
# When using Tempfile, there is no risk of unauthorized file access, since
|
68
|
+
# Tempfile adds a unique string onto the end of every provided filename, and
|
69
|
+
# ensures that the filename does not already exist in the system.
|
70
|
+
def called_on_tempfile? file_name
|
71
|
+
call?(file_name) && file_name.target == s(:const, :Tempfile)
|
72
|
+
end
|
73
|
+
|
74
|
+
def temp_file_method? exp
|
65
75
|
if call? exp
|
66
76
|
return true if exp.call_chain.include? :tempfile
|
67
77
|
|
@@ -22,7 +22,7 @@ class Brakeman::CheckFileDisclosure < Brakeman::BaseCheck
|
|
22
22
|
if fix_version and serves_static_assets?
|
23
23
|
warn :warning_type => "File Access",
|
24
24
|
:warning_code => :CVE_2014_7829,
|
25
|
-
:message => "
|
25
|
+
:message => msg(msg_version(rails_version), " has a file existence disclosure vulnerability. Upgrade to ", msg_version(fix_version), " or disable serving static assets"),
|
26
26
|
:confidence => :high,
|
27
27
|
:gem_info => gemfile_or_environment,
|
28
28
|
:link_path => "https://groups.google.com/d/msg/rubyonrails-security/23fiuwb1NBA/MQVM1-5GkPMJ"
|
@@ -12,7 +12,7 @@ class Brakeman::CheckFilterSkipping < Brakeman::BaseCheck
|
|
12
12
|
|
13
13
|
warn :warning_type => "Default Routes",
|
14
14
|
:warning_code => :CVE_2011_2929,
|
15
|
-
:message => "
|
15
|
+
:message => msg("Rails versions before 3.0.10 have a vulnerability which allows filters to be bypassed", msg_cve("CVE-2011-2929")),
|
16
16
|
:confidence => :high,
|
17
17
|
:gem_info => gemfile_or_environment,
|
18
18
|
:link_path => "https://groups.google.com/d/topic/rubyonrails-security/NCCsca7TEtY/discussion"
|
@@ -18,7 +18,7 @@ class Brakeman::CheckForgerySetting < Brakeman::BaseCheck
|
|
18
18
|
if controller and not controller.protect_from_forgery?
|
19
19
|
csrf_warning :controller => name,
|
20
20
|
:warning_code => :csrf_protection_missing,
|
21
|
-
:message => "
|
21
|
+
:message => msg(msg_code("protect_from_forgery"), " should be called in ", msg_code(name)),
|
22
22
|
:file => controller.file,
|
23
23
|
:line => controller.top_line
|
24
24
|
elsif version_between? "4.0.0", "100.0.0" and forgery_opts = controller.options[:protect_from_forgery]
|
@@ -30,7 +30,7 @@ class Brakeman::CheckForgerySetting < Brakeman::BaseCheck
|
|
30
30
|
:controller => name,
|
31
31
|
:warning_type => "Cross-Site Request Forgery",
|
32
32
|
:warning_code => :csrf_not_protected_by_raising_exception,
|
33
|
-
:message => "protect_from_forgery should be configured with
|
33
|
+
:message => msg(msg_code("protect_from_forgery"), " should be configured with ", msg_code("with: :exception")),
|
34
34
|
:confidence => :medium,
|
35
35
|
:file => controller.file
|
36
36
|
}
|
@@ -73,7 +73,7 @@ class Brakeman::CheckForgerySetting < Brakeman::BaseCheck
|
|
73
73
|
@warned_cve_2011_0447 = true # only warn once
|
74
74
|
|
75
75
|
csrf_warning :warning_code => :CVE_2011_0447,
|
76
|
-
:message => "CSRF protection is flawed in unpatched versions of
|
76
|
+
:message => msg("CSRF protection is flawed in unpatched versions of ", msg_version(rails_version), " ", msg_cve("CVE-2011-0447"), ". Upgrade to ", msg_version(new_version), " or apply patches as needed"),
|
77
77
|
:gem_info => gemfile_or_environment,
|
78
78
|
:file => nil,
|
79
79
|
:link_path => "https://groups.google.com/d/topic/rubyonrails-security/LZWjzCPgNmU/discussion"
|
@@ -7,12 +7,12 @@ class Brakeman::CheckHeaderDoS < Brakeman::BaseCheck
|
|
7
7
|
|
8
8
|
def run_check
|
9
9
|
if (version_between? "3.0.0", "3.2.15" or version_between? "4.0.0", "4.0.1") and not has_workaround?
|
10
|
-
message = "
|
10
|
+
message = msg(msg_version(rails_version), " has a denial of service vulnerability ", msg_cve("CVE-2013-6414"), ". Upgrade to ")
|
11
11
|
|
12
12
|
if version_between? "3.0.0", "3.2.15"
|
13
|
-
message << "3.2.16"
|
13
|
+
message << msg_version("3.2.16")
|
14
14
|
else
|
15
|
-
message << "4.0.2"
|
15
|
+
message << msg_version("4.0.2")
|
16
16
|
end
|
17
17
|
|
18
18
|
warn :warning_type => "Denial of Service",
|
@@ -7,13 +7,13 @@ class Brakeman::CheckI18nXSS < Brakeman::BaseCheck
|
|
7
7
|
|
8
8
|
def run_check
|
9
9
|
if (version_between? "3.0.6", "3.2.15" or version_between? "4.0.0", "4.0.1") and not has_workaround?
|
10
|
-
message = "Rails #{rails_version} has an XSS vulnerability in i18n (CVE-2013-4491). Upgrade to Rails version "
|
11
10
|
i18n_gem = tracker.config.gem_version :i18n
|
11
|
+
message = msg(msg_version(rails_version), " has an XSS vulnerability in ", msg_version(i18n_gem, "i18n"), " ", msg_cve("CVE-2013-4491"), ". Upgrade to ")
|
12
12
|
|
13
13
|
if version_between? "3.0.6", "3.1.99" and version_before i18n_gem, "0.5.1"
|
14
|
-
message << "3.2.16 or i18n 0.5.1"
|
14
|
+
message << msg_version("3.2.16 or i18n 0.5.1")
|
15
15
|
elsif version_between? "3.2.0", "4.0.1" and version_before i18n_gem, "0.6.6"
|
16
|
-
message << "4.0.2 or i18n 0.6.6"
|
16
|
+
message << msg_version("4.0.2 or i18n 0.6.6")
|
17
17
|
else
|
18
18
|
return
|
19
19
|
end
|
@@ -28,7 +28,7 @@ class Brakeman::CheckJRubyXML < Brakeman::BaseCheck
|
|
28
28
|
|
29
29
|
warn :warning_type => "File Access",
|
30
30
|
:warning_code => :CVE_2013_1856,
|
31
|
-
:message => "
|
31
|
+
:message => msg(msg_version(rails_version), " with JRuby has a vulnerability in XML parser. Upgrade to ", msg_version(fix_version), " or patch"),
|
32
32
|
:confidence => :high,
|
33
33
|
:gem_info => gemfile_or_environment,
|
34
34
|
:link => "https://groups.google.com/d/msg/rubyonrails-security/KZwsQbYsOiI/5kUV7dSCJGwJ"
|
@@ -7,12 +7,12 @@ class Brakeman::CheckJSONEncoding < Brakeman::BaseCheck
|
|
7
7
|
|
8
8
|
def run_check
|
9
9
|
if (version_between? "4.1.0", "4.1.10" or version_between? "4.2.0", "4.2.1") and not has_workaround?
|
10
|
-
message = "
|
10
|
+
message = msg(msg_version(rails_version), " does not encode JSON keys ", msg_cve("CVE-2015-3226"), ". Upgrade to ")
|
11
11
|
|
12
12
|
if version_between? "4.1.0", "4.1.10"
|
13
|
-
message << "4.1.11"
|
13
|
+
message << msg_version("4.1.11")
|
14
14
|
else
|
15
|
-
message << "4.2.2"
|
15
|
+
message << msg_version("4.2.2")
|
16
16
|
end
|
17
17
|
|
18
18
|
if tracker.find_call(:methods => [:to_json, :encode]).any?
|
@@ -20,12 +20,8 @@ class Brakeman::CheckJSONParsing < Brakeman::BaseCheck
|
|
20
20
|
"3.0.20"
|
21
21
|
end
|
22
22
|
|
23
|
-
message = "
|
24
|
-
|
25
|
-
gem_info = gemfile_or_environment(:yajl)
|
26
|
-
else
|
27
|
-
gem_info = gemfile_or_environment
|
28
|
-
end
|
23
|
+
message = msg(msg_version(rails_version), " has a serious JSON parsing vulnerability. Upgrade to ", msg_version(new_version), " or patch")
|
24
|
+
gem_info = gemfile_or_environment
|
29
25
|
|
30
26
|
warn :warning_type => "Remote Code Execution",
|
31
27
|
:warning_code => :CVE_2013_0333,
|
@@ -72,19 +68,20 @@ class Brakeman::CheckJSONParsing < Brakeman::BaseCheck
|
|
72
68
|
|
73
69
|
warning_type = "Denial of Service"
|
74
70
|
confidence = :medium
|
75
|
-
|
71
|
+
gem_name = "#{name} gem"
|
72
|
+
message = msg(msg_version(version, gem_name), " has a symbol creation vulnerablity. Upgrade to ")
|
76
73
|
|
77
74
|
if version >= "1.7.0"
|
78
75
|
confidence = :high
|
79
76
|
warning_type = "Remote Code Execution"
|
80
|
-
message = "
|
77
|
+
message = msg(msg_version(version, "json gem"), " has a remote code execution vulnerability. Upgrade to ", msg_version("1.7.7", "json gem"))
|
81
78
|
elsif version >= "1.6.0"
|
82
|
-
message << "1.6.8"
|
79
|
+
message << msg_version("1.6.8", gem_name)
|
83
80
|
elsif version >= "1.5.0"
|
84
|
-
message << "1.5.5"
|
81
|
+
message << msg_version("1.5.5", gem_name)
|
85
82
|
else
|
86
83
|
confidence = :weak
|
87
|
-
message << "1.5.5"
|
84
|
+
message << msg_version("1.5.5", gem_name)
|
88
85
|
end
|
89
86
|
|
90
87
|
if confidence == :medium and uses_json_parse?
|
@@ -68,7 +68,7 @@ class Brakeman::CheckLinkTo < Brakeman::CheckCrossSiteScripting
|
|
68
68
|
input = has_immediate_user_input?(argument)
|
69
69
|
return false unless input
|
70
70
|
|
71
|
-
message = "Unescaped
|
71
|
+
message = msg("Unescaped ", msg_input(input), " in ", msg_code("link_to"))
|
72
72
|
|
73
73
|
warn_xss(result, message, input, :high)
|
74
74
|
end
|
@@ -83,7 +83,7 @@ class Brakeman::CheckLinkTo < Brakeman::CheckCrossSiteScripting
|
|
83
83
|
|
84
84
|
confidence = :medium
|
85
85
|
confidence = :high if likely_model_attribute? match
|
86
|
-
warn_xss(result, "Unescaped model attribute in link_to", match, confidence)
|
86
|
+
warn_xss(result, msg("Unescaped model attribute in ", msg_code("link_to")), match, confidence)
|
87
87
|
end
|
88
88
|
|
89
89
|
# Check if we should warn about the matched result
|
@@ -91,7 +91,7 @@ class Brakeman::CheckLinkTo < Brakeman::CheckCrossSiteScripting
|
|
91
91
|
return false unless matched
|
92
92
|
return false if matched.type == :model and tracker.options[:ignore_model_output]
|
93
93
|
|
94
|
-
message = "Unescaped
|
94
|
+
message = msg("Unescaped ", msg_input(matched), " in ", msg_code("link_to"))
|
95
95
|
|
96
96
|
warn_xss(result, message, @matched, :medium)
|
97
97
|
end
|
@@ -43,7 +43,7 @@ class Brakeman::CheckLinkToHref < Brakeman::CheckLinkTo
|
|
43
43
|
return if call? url_arg and ignore_call? url_arg.target, url_arg.method
|
44
44
|
|
45
45
|
if input = has_immediate_user_input?(url_arg)
|
46
|
-
message = "Unsafe
|
46
|
+
message = msg("Unsafe ", msg_input(input), " in ", msg_code("link_to"), " href")
|
47
47
|
|
48
48
|
unless duplicate? result or call_on_params? url_arg or ignore_interpolation? url_arg, input.match
|
49
49
|
add_result result
|
@@ -59,7 +59,7 @@ class Brakeman::CheckLinkToHref < Brakeman::CheckLinkTo
|
|
59
59
|
return if ignore_model_call? url_arg, input or duplicate? result
|
60
60
|
add_result result
|
61
61
|
|
62
|
-
message = "Potentially unsafe model attribute in link_to href"
|
62
|
+
message = msg("Potentially unsafe model attribute in ", msg_code("link_to"), " href")
|
63
63
|
|
64
64
|
warn :result => result,
|
65
65
|
:warning_type => "Cross-Site Scripting",
|
@@ -11,12 +11,12 @@ class Brakeman::CheckMailTo < Brakeman::BaseCheck
|
|
11
11
|
|
12
12
|
def run_check
|
13
13
|
if (version_between? "2.3.0", "2.3.10" or version_between? "3.0.0", "3.0.3") and result = mail_to_javascript?
|
14
|
-
message = "Vulnerability in mail_to using javascript encoding (CVE-2011-0446). Upgrade to
|
14
|
+
message = msg("Vulnerability in ", msg_code("mail_to"), " using javascript encoding ", msg_cve("CVE-2011-0446"), ". Upgrade to ")
|
15
15
|
|
16
16
|
if version_between? "2.3.0", "2.3.10"
|
17
|
-
message << "2.3.11"
|
17
|
+
message << msg_version("2.3.11")
|
18
18
|
else
|
19
|
-
message << "3.0.4"
|
19
|
+
message << msg_version("3.0.4")
|
20
20
|
end
|
21
21
|
|
22
22
|
warn :result => result,
|
@@ -19,7 +19,7 @@ class Brakeman::CheckMimeTypeDoS < Brakeman::BaseCheck
|
|
19
19
|
|
20
20
|
return if has_workaround?
|
21
21
|
|
22
|
-
message = "
|
22
|
+
message = msg(msg_version(rails_version), " is vulnerable to denial of service via mime type caching ", msg_cve("CVE-2016-0751"), ". Upgrade to ", msg_version(fix_version))
|
23
23
|
|
24
24
|
warn :warning_type => "Denial of Service",
|
25
25
|
:warning_code => :CVE_2016_0751,
|
@@ -30,7 +30,7 @@ class Brakeman::CheckModelAttributes < Brakeman::BaseCheck
|
|
30
30
|
warn :model => no_accessible_names.sort.join(", "),
|
31
31
|
:warning_type => "Attribute Restriction",
|
32
32
|
:warning_code => :no_attr_accessible,
|
33
|
-
:message => "Mass assignment is not restricted using attr_accessible",
|
33
|
+
:message => msg("Mass assignment is not restricted using ", msg_code("attr_accessible")),
|
34
34
|
:confidence => :high
|
35
35
|
end
|
36
36
|
|
@@ -59,7 +59,7 @@ class Brakeman::CheckModelAttributes < Brakeman::BaseCheck
|
|
59
59
|
:line => model.top_line,
|
60
60
|
:warning_type => "Attribute Restriction",
|
61
61
|
:warning_code => :no_attr_accessible,
|
62
|
-
:message => "Mass assignment is not restricted using attr_accessible",
|
62
|
+
:message => msg("Mass assignment is not restricted using ", msg_code("attr_accessible")),
|
63
63
|
:confidence => :high
|
64
64
|
elsif not tracker.options[:ignore_attr_protected]
|
65
65
|
message, confidence, link = check_for_attr_protected_bypass
|
@@ -105,11 +105,11 @@ class Brakeman::CheckModelAttributes < Brakeman::BaseCheck
|
|
105
105
|
end
|
106
106
|
|
107
107
|
if upgrade_version
|
108
|
-
message = "attr_protected is bypassable in
|
108
|
+
message = msg(msg_code("attr_protected"), " is bypassable in ", msg_version(rails_version), ". Use ", msg_code("attr_accessible"), " or upgrade to ", msg_version(upgrade_version))
|
109
109
|
confidence = :high
|
110
110
|
link = "https://groups.google.com/d/topic/rubyonrails-security/AFBKNY7VSH8/discussion"
|
111
111
|
else
|
112
|
-
message = "attr_accessible is recommended over attr_protected"
|
112
|
+
message = msg(msg_code("attr_accessible"), " is recommended over ", msg_code("attr_protected"))
|
113
113
|
confidence = :medium
|
114
114
|
link = nil
|
115
115
|
end
|
@@ -57,7 +57,7 @@ class Brakeman::CheckModelSerialize < Brakeman::BaseCheck
|
|
57
57
|
warn :model => model.name,
|
58
58
|
:warning_type => "Remote Code Execution",
|
59
59
|
:warning_code => :CVE_2013_0277,
|
60
|
-
:message => "Serialized attributes are vulnerable in
|
60
|
+
:message => msg("Serialized attributes are vulnerable in ", msg_version(rails_version), ", upgrade to ", msg_version(@upgrade_version), " or patch"),
|
61
61
|
:confidence => confidence,
|
62
62
|
:link => "https://groups.google.com/d/topic/rubyonrails-security/KtmwSbEpzrU/discussion",
|
63
63
|
:file => model.file,
|
@@ -11,12 +11,12 @@ class Brakeman::CheckNestedAttributes < Brakeman::BaseCheck
|
|
11
11
|
version = rails_version
|
12
12
|
|
13
13
|
if (version == "2.3.9" or version == "3.0.0") and uses_nested_attributes?
|
14
|
-
message = "Vulnerability in nested attributes (CVE-2010-3933). Upgrade to
|
14
|
+
message = msg("Vulnerability in nested attributes ", msg_cve("CVE-2010-3933"), ". Upgrade to ")
|
15
15
|
|
16
16
|
if version == "2.3.9"
|
17
|
-
message << "2.3.10"
|
17
|
+
message << msg_version("2.3.10")
|
18
18
|
else
|
19
|
-
message << "3.0.1"
|
19
|
+
message << msg_version("3.0.1")
|
20
20
|
end
|
21
21
|
|
22
22
|
warn :warning_type => "Nested Attributes",
|
@@ -30,7 +30,7 @@ class Brakeman::CheckNestedAttributesBypass < Brakeman::BaseCheck
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def warn_about_nested_attributes name, model, args
|
33
|
-
message = "
|
33
|
+
message = msg(msg_version(rails_version), " does not call ", msg_code(":reject_if"), " option when ", msg_code(":allow_destroy"), " is ", msg_code("false"), " ", msg_cve("CVE-2015-7577"))
|
34
34
|
|
35
35
|
warn :model => name,
|
36
36
|
:warning_type => "Nested Attributes",
|
@@ -23,12 +23,12 @@ class Brakeman::CheckNumberToCurrency < Brakeman::BaseCheck
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def generic_warning
|
26
|
-
message = "
|
26
|
+
message = msg(msg_version(rails_version), " has a vulnerability in number helpers ", msg_cve("CVE-2014-0081"), ". Upgrade to ")
|
27
27
|
|
28
28
|
if version_between? "2.3.0", "3.2.16"
|
29
|
-
message << "3.2.17"
|
29
|
+
message << msg_version("3.2.17")
|
30
30
|
else
|
31
|
-
message << "4.0.3"
|
31
|
+
message << msg_version("4.0.3")
|
32
32
|
end
|
33
33
|
|
34
34
|
warn :warning_type => "Cross-Site Scripting",
|
@@ -66,7 +66,7 @@ class Brakeman::CheckNumberToCurrency < Brakeman::BaseCheck
|
|
66
66
|
warn :result => result,
|
67
67
|
:warning_type => "Cross-Site Scripting",
|
68
68
|
:warning_code => :CVE_2014_0081_call,
|
69
|
-
:message => "Format options in
|
69
|
+
:message => msg("Format options in ", msg_code(result[:call].method), " are not safe in ", msg_version(rails_version)),
|
70
70
|
:confidence => :high,
|
71
71
|
:link_path => "https://groups.google.com/d/msg/ruby-security-ann/9WiRn2nhfq0/2K2KRB4LwCMJ",
|
72
72
|
:user_input => match
|
@@ -18,9 +18,9 @@ class Brakeman::CheckQuoteTableName < Brakeman::BaseCheck
|
|
18
18
|
end
|
19
19
|
|
20
20
|
if rails_version =~ /^3/
|
21
|
-
message = "
|
21
|
+
message = msg("Rails versions before 3.0.10 have a vulnerability in ", msg_code("quote_table_name"), " ", msg_cve("CVE-2011-2930"))
|
22
22
|
else
|
23
|
-
message = "
|
23
|
+
message = msg("Rails versions before 2.3.14 have a vulnerability in ", msg_code("quote_table_name"), " ", msg_cve("CVE-2011-2930"))
|
24
24
|
end
|
25
25
|
|
26
26
|
warn :warning_type => "SQL Injection",
|
@@ -44,7 +44,7 @@ class Brakeman::CheckRegexDoS < Brakeman::BaseCheck
|
|
44
44
|
end
|
45
45
|
|
46
46
|
if match
|
47
|
-
message =
|
47
|
+
message = msg(msg_input(match), " used in regular expression")
|
48
48
|
|
49
49
|
warn :result => result,
|
50
50
|
:warning_type => "Denial of Service",
|
@@ -49,7 +49,7 @@ class Brakeman::CheckRender < Brakeman::BaseCheck
|
|
49
49
|
return if input.type == :model #skip models
|
50
50
|
return if safe_param? input.match
|
51
51
|
|
52
|
-
message = "Render path contains
|
52
|
+
message = msg("Render path contains ", msg_input(input))
|
53
53
|
|
54
54
|
warn :result => result,
|
55
55
|
:warning_type => "Dynamic Render Path",
|
@@ -75,7 +75,7 @@ class Brakeman::CheckRender < Brakeman::BaseCheck
|
|
75
75
|
warn :result => result,
|
76
76
|
:warning_type => "Remote Code Execution",
|
77
77
|
:warning_code => :dynamic_render_path_rce,
|
78
|
-
:message => "Passing query parameters to render
|
78
|
+
:message => msg("Passing query parameters to ", msg_code("render"), " is vulnerable in ", msg_version(rails_version), " ", msg_cve("CVE-2016-0752")),
|
79
79
|
:user_input => view,
|
80
80
|
:confidence => :high
|
81
81
|
end
|