brakeman-llm 0.0.1
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.
- checksums.yaml +7 -0
- data/bin/brakeman-llm +10 -0
- data/docs/warning_types/CVE-2010-3933/index.markdown +17 -0
- data/docs/warning_types/CVE-2011-0446/index.markdown +17 -0
- data/docs/warning_types/CVE-2011-3186/index.markdown +17 -0
- data/docs/warning_types/attribute_restriction/index.markdown +32 -0
- data/docs/warning_types/authentication/index.markdown +23 -0
- data/docs/warning_types/authentication_whitelist/index.markdown +13 -0
- data/docs/warning_types/basic_auth/index.markdown +14 -0
- data/docs/warning_types/basic_authentication/index.markdown +25 -0
- data/docs/warning_types/command_injection/index.markdown +26 -0
- data/docs/warning_types/content_tag/index.markdown +30 -0
- data/docs/warning_types/cross-site_request_forgery/index.markdown +19 -0
- data/docs/warning_types/cross_site_request_forgery/index.markdown +18 -0
- data/docs/warning_types/cross_site_scripting/index.markdown +64 -0
- data/docs/warning_types/cross_site_scripting_to_json/index.markdown +55 -0
- data/docs/warning_types/dangerous_eval/index.markdown +13 -0
- data/docs/warning_types/dangerous_evaluation/index.markdown +14 -0
- data/docs/warning_types/dangerous_send/index.markdown +44 -0
- data/docs/warning_types/default_routes/index.markdown +27 -0
- data/docs/warning_types/denial_of_service/index.markdown +42 -0
- data/docs/warning_types/dynamic_render_path/index.markdown +14 -0
- data/docs/warning_types/dynamic_render_paths/index.markdown +17 -0
- data/docs/warning_types/evaluation/index.markdown +14 -0
- data/docs/warning_types/file_access/index.markdown +23 -0
- data/docs/warning_types/format_validation/index.markdown +15 -0
- data/docs/warning_types/http_verb_confusion/index.markdown +42 -0
- data/docs/warning_types/information_disclosure/index.markdown +20 -0
- data/docs/warning_types/link_to/index.markdown +19 -0
- data/docs/warning_types/link_to_href/index.markdown +19 -0
- data/docs/warning_types/mass_assignment/index.markdown +67 -0
- data/docs/warning_types/model_validation/index.markdown +14 -0
- data/docs/warning_types/path_traversal/index.markdown +57 -0
- data/docs/warning_types/redirect/index.markdown +60 -0
- data/docs/warning_types/remote_code_execution/index.markdown +17 -0
- data/docs/warning_types/remote_code_execution_yaml_load/index.markdown +19 -0
- data/docs/warning_types/session_manipulation/index.markdown +28 -0
- data/docs/warning_types/session_setting/index.markdown +24 -0
- data/docs/warning_types/session_settings/index.markdown +18 -0
- data/docs/warning_types/sql_injection/index.markdown +41 -0
- data/docs/warning_types/ssl_verification_bypass/index.markdown +41 -0
- data/docs/warning_types/unmaintained_dependency/index.markdown +33 -0
- data/docs/warning_types/unsafe_deserialization/index.markdown +17 -0
- data/docs/warning_types/unscoped_find/index.markdown +25 -0
- data/lib/brakeman-llm.rb +226 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ef666ad931136eb76564a777cb88fbae6d82faa923ecd53157b007743eb55168
|
4
|
+
data.tar.gz: 5cbfb90e111f4d2fd70d9e5871707ceb8ec60ac4d1399044786a93b3c1862b00
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0aeef7aade75c790d635c4c89db188d9b4fa210021d02add11cd59e795b3ed15b80a2550460cd33dba0c245d46c1d46bc16bf6c9ef219c80ddcd68c6e58a5500
|
7
|
+
data.tar.gz: 11faf76793129732bc14fbfb40a29fcaf69581ccb7ce21099e9c8682d80a14e0be9837a505d60f41dadc2debccd633326cd9be9103e596b4b7dcc918192c1566
|
data/bin/brakeman-llm
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#Adjust path in case called directly and not through gem
|
3
|
+
$:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
|
4
|
+
|
5
|
+
Encoding.default_external = 'UTF-8'
|
6
|
+
|
7
|
+
require 'brakeman-llm'
|
8
|
+
require 'brakeman/commandline'
|
9
|
+
|
10
|
+
Brakeman::Commandline.start
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Nested Attributes (CVE-2010-3933)"
|
4
|
+
date: 2012-06-19 16:59
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Rails 2.3.9 and 3.0.0 are vulnerable to an attack on nested attributes wherein a malicious user could alter data in any record in the system.
|
11
|
+
|
12
|
+
It is recommended to upgrade to at least 2.3.10 or 3.0.1.
|
13
|
+
|
14
|
+
For more details see [CVE-2011-0446](http://groups.google.com/group/rubyonrails-security/browse_thread/thread/f9f913d328dafe0c).
|
15
|
+
|
16
|
+
---
|
17
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Mail Link (CVE-2011-0446)"
|
4
|
+
date: 2012-06-19 16:55
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Certain versions of Rails were vulnerable to a cross-site scripting vulnerability mail\_to.
|
11
|
+
|
12
|
+
Versions of Rails after 2.3.10 or 3.0.3 are not affected. Updating or removing the mail\_to links is advised.
|
13
|
+
|
14
|
+
For more details see [CVE-2011-0446](http://groups.google.com/group/rubyonrails-security/browse_thread/thread/f02a48ede8315f81).
|
15
|
+
|
16
|
+
---
|
17
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Response Splitting (CVE-2011-3186)"
|
4
|
+
date: 2012-06-19 17:02
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Response splitting is a simple attack that can be used as part or a larger exploit chain. A malicious user sends data that causes the HTTP response header to include unintended newline characters which are interpreted as the end of the header. The attacker may then forge their own response body and an entirely false HTTP response, essentailly hijacking the entire page load.
|
11
|
+
|
12
|
+
Versions of Rails 2 previous to 2.3.13 were vulnerable to this type of attack. The Rails 3 branch is not affected.
|
13
|
+
|
14
|
+
For more details see [CVE-2011-3186](http://groups.google.com/group/rubyonrails-security/browse_thread/thread/6ffc93bde0298768).
|
15
|
+
|
16
|
+
---
|
17
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Attribute Restriction"
|
4
|
+
date: 2011-11-10 12:46
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
This warning type only applies to Ruby on Rails applications which are not using [strong parameters](https://guides.rubyonrails.org/action_controller_overview.html#strong-parameters).
|
11
|
+
|
12
|
+
Note that disabling mass assignment globally will suppress these warnings.
|
13
|
+
|
14
|
+
#### Missing Protection
|
15
|
+
|
16
|
+
This warning comes up if a model does not limit what attributes can be set through [mass assignment](https://guides.rubyonrails.org/v3.2.9/security.html#mass-assignment).
|
17
|
+
|
18
|
+
In particular, this check looks for `attr_accessible` inside model definitions. If it is not found, this warning will be issued.
|
19
|
+
|
20
|
+
#### Use of Blacklist
|
21
|
+
|
22
|
+
Brakeman also warns on use of `attr_protected` - especially since it was found to be [vulnerable to bypass](https://groups.google.com/d/topic/rubyonrails-security/AFBKNY7VSH8/discussion). Warnings for mass assignment on models using `attr_protected` will be reported, but at a lower confidence level.
|
23
|
+
|
24
|
+
#### Suggested Remediation
|
25
|
+
|
26
|
+
For newer Ruby on Rails applications, query parameters should be whitelisted before use via strong parameters.
|
27
|
+
|
28
|
+
For older Ruby on Rails applications, each model should use `attr_accessible` to carefully whitelist which attributes may be set via mass assignment, if any.
|
29
|
+
|
30
|
+
---
|
31
|
+
|
32
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Authentication"
|
4
|
+
date: 2016-06-29 16:15
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
"Authentication" is the act of verifying that a user or client is who they say they are.
|
11
|
+
|
12
|
+
Right now, the only Brakeman warning in the authentication category is regarding hardcoded passwords.
|
13
|
+
Brakeman will warn about constants with literal string values that appear to be passwords.
|
14
|
+
|
15
|
+
Hardcoded passwords are security issues since they imply a single password and that password is stored in the source code.
|
16
|
+
Typically source code is available to a wide number of people inside an organization, and there have been many instances of source
|
17
|
+
code leaking to the public. Passwords and secrets should be stored in a separate, secure location to limit access.
|
18
|
+
|
19
|
+
Additionally, it is recommended not to use a single password for accessing sensitive information.
|
20
|
+
Each user should have their own password to make it easier to audit and revoke access.
|
21
|
+
|
22
|
+
---
|
23
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Authentication Whitelist"
|
4
|
+
date: 2013-03-01 11:33
|
5
|
+
comments: true
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
When skipping `before_filter`s with security implications, a "whitelist" approach using `only` should be used instead of `except`. This ensures actions are protected by default, and unprotected only by exception.
|
11
|
+
|
12
|
+
---
|
13
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Basic Authentication"
|
4
|
+
date: 2011-11-10 12:47
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
<script>
|
11
|
+
window.location.replace("http://brakemanscanner.org/docs/warning_types/basic_authentication/");
|
12
|
+
</script>
|
13
|
+
|
14
|
+
Content moved to [Basic Authentication](basic_authentication/).
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Basic Authentication"
|
4
|
+
date: 2011-11-10 12:52
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
In Rails 3.1, a new feature was added to simplify basic authentication.
|
11
|
+
|
12
|
+
The example provided in the official [Rails Guide](http://guides.rubyonrails.org/getting_started.html) looks like this:
|
13
|
+
|
14
|
+
class PostsController < ApplicationController
|
15
|
+
|
16
|
+
http_basic_authenticate_with :name => "dhh", :password => "secret", :except => :index
|
17
|
+
|
18
|
+
#...
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
This warning will be raised if `http_basic_authenticate_with` is used and the password is found to be a string (i.e., stored somewhere in the code).
|
23
|
+
|
24
|
+
---
|
25
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Command Injection"
|
4
|
+
date: 2011-11-09 14:33
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Injection is #1 on the 2010 [OWASP Top Ten](https://web.archive.org/web/20190223031311/https://www.owasp.org/index.php/Top_10_2010-A1) web security risks. Command injection occurs when shell commands unsafely include user-manipulatable values.
|
11
|
+
|
12
|
+
There are many ways to run commands in Ruby:
|
13
|
+
|
14
|
+
`ls #{params[:file]}`
|
15
|
+
|
16
|
+
system("ls #{params[:dir]}")
|
17
|
+
|
18
|
+
exec("md5sum #{params[:input]}")
|
19
|
+
|
20
|
+
Brakeman will warn on any method like these that uses user input or unsafely interpolates variables.
|
21
|
+
|
22
|
+
See [the Ruby Security Guide](http://guides.rubyonrails.org/security.html#command-line-injection) for details.
|
23
|
+
|
24
|
+
---
|
25
|
+
Back to [Warning Types](/docs/warning_types)
|
26
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Cross Site Scripting (Content Tag)"
|
4
|
+
date: 2012-09-04 12:44
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Cross site scripting (or XSS) is #2 on the 2010 [OWASP Top Ten](https://web.archive.org/web/20190223031311/https://www.owasp.org/index.php/Top_10_2010-A2) web security risks and it pops up nearly everywhere. XSS occurs when a user-manipulatable value is displayed on a web page without escaping it, allowing someone to inject Javascript or HTML into the page.
|
11
|
+
|
12
|
+
[content\_tag](http://apidock.com/rails/ActionView/Helpers/TagHelper/content_tag) is a view helper which generates an HTML tag with some content:
|
13
|
+
|
14
|
+
>> content_tag :p, "Hi!"
|
15
|
+
=> "<p>Hi!</p>"
|
16
|
+
|
17
|
+
In Rails 2, this content is unescaped (although attribute values are escaped):
|
18
|
+
|
19
|
+
>> content_tag :p, "<script>alert(1)</script>"
|
20
|
+
=> "<p><script>alert(1)</script></p>"
|
21
|
+
|
22
|
+
In Rails 3, the content is escaped. However, only the *content* and the tag attribute *values* are escaped. The tag and attribute names are never escaped in Rails 2 or 3.
|
23
|
+
|
24
|
+
This is more dangerous than a typical method call because `content_tag` marks its output as "HTML safe", meaning the `rails_xss` plugin and Rails 3 auto-escaping will not escape its output. Due to this, `content_tag` should be used carefully if user input is provided as an argument.
|
25
|
+
|
26
|
+
Note that while `content_tag` does have an `escape` parameter, this only applies to tag attribute *values* and is true by default.
|
27
|
+
|
28
|
+
---
|
29
|
+
Back to [Warning Types](/docs/warning_types)
|
30
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Cross Site Request Forgery"
|
4
|
+
date: 2011-11-10 12:24
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Cross-site request forgery is #5 on the [OWASP Top Ten](https://web.archive.org/web/20190223031311/https://www.owasp.org/index.php/Top_10_2010-A5). CSRF allows an attacker to perform actions on a website as if they are an authenticated user.
|
11
|
+
|
12
|
+
This warning is raised when no call to `protect_from_forgery` is found in `ApplicationController`. This method prevents CSRF.
|
13
|
+
|
14
|
+
For Rails 4 applications, it is recommended that you use `protect_from_forgery :with => :exception`. This code is inserted into newly generated applications. The default is to `nil` out the session object, which has been a source of many CSRF bypasses due to session memoization.
|
15
|
+
|
16
|
+
See [the Ruby Security Guide](http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf) for details.
|
17
|
+
|
18
|
+
---
|
19
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Cross-Site Request Forgery"
|
4
|
+
date: 2011-11-10 16:15
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
<script>
|
11
|
+
window.location.replace("http://brakemanscanner.org/docs/warning_types/cross-site_request_forgery/");
|
12
|
+
</script>
|
13
|
+
|
14
|
+
Content has moved to [Cross-Site Request Forgery](/docs/warning_types/cross-site_request_forgery/)
|
15
|
+
|
16
|
+
---
|
17
|
+
Back to [Warning Types](/docs/warning_types)
|
18
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Cross Site Scripting"
|
4
|
+
date: 2011-11-09 13:34
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Cross site scripting (or XSS) is #2 on the 2010 [OWASP Top Ten](https://web.archive.org/web/20190223031311/https://www.owasp.org/index.php/Top_10_2010-A2) web security risks and it pops up nearly everywhere.
|
11
|
+
|
12
|
+
XSS occurs when a user-manipulatable value is displayed on a web page without escaping it, allowing someone to inject Javascript or HTML into the page.
|
13
|
+
|
14
|
+
In Rails 2.x, values need to be explicitly escaped (e.g., by using the `h` method). In Rails 3.x, auto-escaping in views is enabled by default. However, one can still use the `raw` method to output a value directly.
|
15
|
+
|
16
|
+
See [the Ruby Security Guide](http://guides.rubyonrails.org/security.html#cross-site-scripting-xss) for more details.
|
17
|
+
|
18
|
+
### Query Parameters and Cookies
|
19
|
+
|
20
|
+
Rails 2.x example in ERB:
|
21
|
+
|
22
|
+
<%= params[:query] %>
|
23
|
+
|
24
|
+
Brakeman looks for several situations that can allow XSS. The simplest is like the example above: a value from the `params` or `cookies` is being directly output to a view. In such cases, it will issue a warning like:
|
25
|
+
|
26
|
+
Unescaped parameter value near line 3: params[:query]
|
27
|
+
|
28
|
+
By default, Brakeman will also warn when a parameter or cookie value is used as an argument to a method, the result of which is output unescaped to a view.
|
29
|
+
|
30
|
+
For example:
|
31
|
+
|
32
|
+
<%= some_method(cookie[:name]) %>
|
33
|
+
|
34
|
+
This raises a warning like:
|
35
|
+
|
36
|
+
Unescaped cookie value near line 5: some_method(cookies[:oreo])
|
37
|
+
|
38
|
+
However, the confidence level for this warning will be weak, because it is not directly outputting the cookie value.
|
39
|
+
|
40
|
+
Some methods are known to Brakeman to either be dangerous (`link_to` is one) or safe (`escape_once`). Users can specify safe methods using the `--safe-methods` option. Alternatively, Brakeman can be set to _only_ warn when values are used directly with the `--report-direct` option.
|
41
|
+
|
42
|
+
### Model Attributes
|
43
|
+
|
44
|
+
Because (many) models come from database values, Brakeman mistrusts them by default.
|
45
|
+
|
46
|
+
For example, if `@user` is an instance of a model set in an action like
|
47
|
+
|
48
|
+
def set_user
|
49
|
+
@user = User.first
|
50
|
+
end
|
51
|
+
|
52
|
+
and there is a view with
|
53
|
+
|
54
|
+
<%= @user.name %>
|
55
|
+
|
56
|
+
Brakeman will raise a warning like
|
57
|
+
|
58
|
+
Unescaped model attribute near line 3: User.first.name
|
59
|
+
|
60
|
+
If you trust all your data (although you probably shouldn't), this can be disabled with `--ignore-model-output`.
|
61
|
+
|
62
|
+
---
|
63
|
+
Back to [Warning Types](/docs/warning_types)
|
64
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Cross Site Scripting (JSON)"
|
4
|
+
date: 2012-08-29 18:09
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Cross site scripting (or XSS) is #2 on the 2010 [OWASP Top Ten](https://web.archive.org/web/20190223031311/https://www.owasp.org/index.php/Top_10_2010-A2) web security risks and it pops up nearly everywhere.
|
11
|
+
|
12
|
+
XSS occurs when a user-manipulatable value is displayed on a web page without escaping it, allowing someone to inject Javascript or HTML into the page. Calls to `Hash#to_json` can be used to trigger XSS. Brakeman will check to see if there are any calls to `Hash#to_json` with `ActiveSupport#escape_html_entities_in_json` set to false (or if you are running Rails < 2.1.0 which did not have this functionality).
|
13
|
+
|
14
|
+
`ActiveSupport#escape_html_entities_in_json` was introduced in the "new\_rails\_defaults" initializer in Rails 2.1.0 which is set to `false` by default. In Rails 3.0.0, `true` became the default setting. Setting this value to `true` will automatically escape '<', '>', '&' which are commonly used to break out of code generated by a to\_json call.
|
15
|
+
|
16
|
+
See [ActiveSupport#escape\_html\_entities\_in\_json](http://rubydoc.info/docs/rails/ActiveSupport/JSON/Encoding.escape_html_entities_in_json=) for more details.
|
17
|
+
|
18
|
+
### Exploiting to\_json
|
19
|
+
|
20
|
+
Consider the following snippet of Rails 2.x ERB:
|
21
|
+
|
22
|
+
# controller
|
23
|
+
@attrs = {:email => 'some@email.com</script><script>alert(document.domain)//'}
|
24
|
+
|
25
|
+
<!-- view -->
|
26
|
+
<script>
|
27
|
+
var attributes = <%= @attrs.to_json %>
|
28
|
+
</script>
|
29
|
+
|
30
|
+
Which generates the following html:
|
31
|
+
|
32
|
+
<script>
|
33
|
+
var attributes = {"email":"some@email.com</script><script>alert(document.domain)//"}
|
34
|
+
</script>
|
35
|
+
|
36
|
+
While the generated Javascript appears valid, the browser parses the script tags first, so it sees something like this:
|
37
|
+
|
38
|
+
<script>
|
39
|
+
var attributes = {"email":"some@email.com
|
40
|
+
</script>
|
41
|
+
<script>
|
42
|
+
alert(document.domain)//"}
|
43
|
+
</script>
|
44
|
+
|
45
|
+
The attribute assignment causes a Javascript error, but the alert triggers just fine!
|
46
|
+
|
47
|
+
With `escape_html_entities_in_json = true`, you will receive the following innocuous output:
|
48
|
+
|
49
|
+
<script>
|
50
|
+
var attributes = {"email":"some@email.com\u003C/script\u003E\u003Cscript\u003Ealert(document.domain)//"}
|
51
|
+
</script>
|
52
|
+
|
53
|
+
---
|
54
|
+
Back to [Warning Types](/docs/warning_types)
|
55
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Dangerous Evaluation"
|
4
|
+
date: 2011-11-10 12:47
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
User input in an `eval` statement is VERY dangerous, so this will always raise a warning. Brakeman looks for calls to `eval`, `instance_eval`, `class_eval`, and `module_eval`.
|
11
|
+
|
12
|
+
---
|
13
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Dangerous Evaluation"
|
4
|
+
date: 2011-11-10 16:04
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
<script>
|
11
|
+
window.location.replace("http://brakemanscanner.org/docs/warning_types/dangerous_eval/");
|
12
|
+
</script>
|
13
|
+
|
14
|
+
Content moved to [Dangerous Eval](dangerous_eval/).
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Dangerous Send"
|
4
|
+
date: 2012-06-19 16:49
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Using unfiltered user data to select a Class or Method to be dynamically sent is dangerous.
|
11
|
+
|
12
|
+
It is much safer to whitelist the desired target or method.
|
13
|
+
|
14
|
+
Unsafe use of method:
|
15
|
+
|
16
|
+
method = params[:method]
|
17
|
+
@result = User.send(method.to_sym)
|
18
|
+
|
19
|
+
Safe:
|
20
|
+
|
21
|
+
method = params[:method] == 1 ? :method_a : :method_b
|
22
|
+
@result = User.send(method, *args)
|
23
|
+
|
24
|
+
Unsafe use of target:
|
25
|
+
|
26
|
+
table = params[:table]
|
27
|
+
model = table.classify.constantize
|
28
|
+
@result = model.send(:method)
|
29
|
+
|
30
|
+
Safe:
|
31
|
+
|
32
|
+
target = params[:target] == 1 ? Account : User
|
33
|
+
@result = target.send(:method, *args)
|
34
|
+
|
35
|
+
Including user data in the arguments passed to an Object#send is safe, as long as the method can properly handle potentially bad data.
|
36
|
+
|
37
|
+
Safe:
|
38
|
+
|
39
|
+
args = params["args"] || []
|
40
|
+
@result = User.send(:method, *args)
|
41
|
+
|
42
|
+
|
43
|
+
---
|
44
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Default Routes"
|
4
|
+
date: 2011-11-10 12:40
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
The general default routes warning means there is a call to
|
11
|
+
|
12
|
+
#Rails 2.x
|
13
|
+
map.connect ":controller/:action/:id"
|
14
|
+
|
15
|
+
or
|
16
|
+
|
17
|
+
Rails 3.x
|
18
|
+
match ':controller(/:action(/:id(.:format)))'
|
19
|
+
|
20
|
+
in `config/routes.rb`. This allows any public method on any controller to be called as an action.
|
21
|
+
|
22
|
+
If this warning is reported for a particular controller, it means there is a route to that controller containing `:action`.
|
23
|
+
|
24
|
+
Default routes can be dangerous if methods are made public which are not intended to be used as URLs or actions.
|
25
|
+
|
26
|
+
---
|
27
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Denial of Service"
|
4
|
+
date: 2013-05-16 12:47
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Denial of Service (DoS) is any attack which causes a service to become unavailable for legitimate clients.
|
11
|
+
|
12
|
+
Denial of Service can be caused by consuming large amounts of network, memory, or CPU resources.
|
13
|
+
|
14
|
+
### Regex DoS
|
15
|
+
|
16
|
+
If an attacker can control the content of a regular expression, they may be able to construct a regular expression that requires exponential time to run.
|
17
|
+
|
18
|
+
Brakeman will warn about dynamic regular expressions that inject user-supplied values.
|
19
|
+
|
20
|
+
For example:
|
21
|
+
|
22
|
+
some.values.any? { |v| v.match /#{params[:query]}/ }
|
23
|
+
|
24
|
+
More information:
|
25
|
+
|
26
|
+
* [ReDoS](https://en.wikipedia.org/wiki/ReDoS)
|
27
|
+
* [Catastrophic Backtracking](https://www.regular-expressions.info/catastrophic.html)
|
28
|
+
* [Regular Expression Matching Can Be Simple And Fast](https://swtch.com/~rsc/regexp/regexp1.html)
|
29
|
+
|
30
|
+
### Symbol DoS
|
31
|
+
|
32
|
+
[Prior to Ruby 2.2](https://www.ruby-lang.org/en/news/2014/12/25/ruby-2-2-0-released/), Symbols were not garbage collected. Creation of large numbers of Symbols could lead to a server running out of memory.
|
33
|
+
|
34
|
+
If the application appears to be using an older version of Ruby, Brakeman checks for code where user input which is converted to a Symbol. When this is not restricted, an attacker could create an unlimited number of Symbols.
|
35
|
+
|
36
|
+
Note: This is an optional check which can be enabled with `--enable SymbolDoS` or `--run-all-checks`.
|
37
|
+
|
38
|
+
---
|
39
|
+
|
40
|
+
[More Information](https://owasp.org/www-community/attacks/Denial_of_Service)
|
41
|
+
|
42
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Dynamic Render Path"
|
4
|
+
date: 2011-11-10 12:47
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
<script>
|
11
|
+
window.location.replace("http://brakemanscanner.org/docs/warning_types/dynamic_render_paths/");
|
12
|
+
</script>
|
13
|
+
|
14
|
+
Content has moved to [Dynamic Render Paths](dynamic_render_paths)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Dynamic Render Path"
|
4
|
+
date: 2011-11-10 12:47
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
When a call to `render` uses a dynamically generated path, template name, file name, or action, there is the possibility that a user can access templates that should be restricted. The issue may be worse if those templates execute code or modify the database.
|
11
|
+
|
12
|
+
This warning is shown whenever the path to be rendered is not a static string or symbol.
|
13
|
+
|
14
|
+
These warnings are often false positives, however, because it can be difficult to manipulate Rails' assumptions about paths to perform malicious behavior. Reports of dynamic render paths should be checked carefully to see if they can actually be manipulated maliciously by the user.
|
15
|
+
|
16
|
+
---
|
17
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Dangerous Evaluation"
|
4
|
+
date: 2011-11-10 12:47
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
<script>
|
11
|
+
window.location.replace("http://brakemanscanner.org/docs/warning_types/dangerous_eval/");
|
12
|
+
</script>
|
13
|
+
|
14
|
+
Content moved to [Dangerous Eval](dangerous_eval/).
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "File Access"
|
4
|
+
date: 2011-11-10 16:06
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Using user input when accessing files (local or remote) will raise a warning in Brakeman.
|
11
|
+
|
12
|
+
For example
|
13
|
+
|
14
|
+
File.open("/tmp/#{cookie[:file]}")
|
15
|
+
|
16
|
+
will raise an error like
|
17
|
+
|
18
|
+
Cookie value used in file name near line 4: File.open("/tmp/#{cookie[:file]}")
|
19
|
+
|
20
|
+
This type of vulnerability can be used to access arbitrary files on a server (including `/etc/passwd`.
|
21
|
+
|
22
|
+
---
|
23
|
+
Back to [Warning Types](/docs/warning_types)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
title: "Format Validation"
|
4
|
+
date: 2011-11-10 12:44
|
5
|
+
comments: false
|
6
|
+
sharing: true
|
7
|
+
footer: true
|
8
|
+
---
|
9
|
+
|
10
|
+
Calls to `validates_format_of ..., :with => //` which do not use `\A` and `\z` as anchors will cause this warning. Using `^` and `$` is not sufficient, as they will only match up to a new line. This allows an attacker to put whatever malicious input they would like before or after a new line character.
|
11
|
+
|
12
|
+
See [the Ruby Security Guide](http://guides.rubyonrails.org/security.html#regular-expressions) for details.
|
13
|
+
|
14
|
+
---
|
15
|
+
Back to [Warning Types](/docs/warning_types)
|