dawnscanner 1.3.1 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/BUGS.md +14 -0
  5. data/Changelog.md +27 -1
  6. data/KnowledgeBase.md +19 -2
  7. data/LICENSE.txt +2 -2
  8. data/README.md +2 -2
  9. data/Rakefile +100 -0
  10. data/Roadmap.md +25 -11
  11. data/VERSION +16 -0
  12. data/bin/dawn +9 -5
  13. data/checksum/dawnscanner-1.3.1.gem.sha1 +1 -0
  14. data/dawnscanner.gemspec +5 -6
  15. data/lib/dawn/kb/basic_check.rb +25 -10
  16. data/lib/dawn/kb/cve_2004_0755.rb +3 -0
  17. data/lib/dawn/kb/cve_2004_0983.rb +3 -0
  18. data/lib/dawn/kb/cve_2005_1992.rb +3 -0
  19. data/lib/dawn/kb/cve_2005_2337.rb +3 -0
  20. data/lib/dawn/kb/cve_2006_3694.rb +2 -0
  21. data/lib/dawn/kb/cve_2007_0469.rb +2 -0
  22. data/lib/dawn/kb/cve_2007_5380.rb +2 -0
  23. data/lib/dawn/kb/cve_2007_6077.rb +2 -0
  24. data/lib/dawn/kb/cve_2007_6612.rb +2 -0
  25. data/lib/dawn/kb/cve_2013_6416.rb +1 -1
  26. data/lib/dawn/kb/cve_2015_1840/cve_2015_1840_a.rb +28 -0
  27. data/lib/dawn/kb/cve_2015_1840/cve_2015_1840_b.rb +28 -0
  28. data/lib/dawn/kb/cve_2015_2963.rb +27 -0
  29. data/lib/dawn/kb/cve_2015_3224.rb +26 -0
  30. data/lib/dawn/kb/cve_2015_3225.rb +28 -0
  31. data/lib/dawn/kb/cve_2015_3226.rb +27 -0
  32. data/lib/dawn/kb/cve_2015_3227.rb +27 -0
  33. data/lib/dawn/kb/osvdb_118579.rb +31 -0
  34. data/lib/dawn/kb/osvdb_118830.rb +32 -0
  35. data/lib/dawn/kb/osvdb_118954.rb +31 -0
  36. data/lib/dawn/kb/osvdb_119878.rb +32 -0
  37. data/lib/dawn/kb/osvdb_119927.rb +33 -0
  38. data/lib/dawn/kb/owasp_ror_cheatsheet/session_stored_in_database.rb +1 -1
  39. data/lib/dawn/knowledge_base.rb +34 -0
  40. data/lib/dawn/logger.rb +16 -0
  41. data/lib/dawn/reporter.rb +19 -19
  42. data/lib/dawn/utils.rb +2 -2
  43. data/lib/dawn/version.rb +5 -24
  44. data/lib/dawnscanner.rb +2 -1
  45. data/spec/lib/dawn/codesake_knowledgebase_spec.rb +66 -15
  46. data/spec/lib/kb/cve_2015_1840_spec.rb +35 -0
  47. data/spec/lib/kb/cve_2015_2963_spec.rb +17 -0
  48. data/spec/lib/kb/cve_2015_3224_spec.rb +16 -0
  49. data/spec/lib/kb/cve_2015_3225_spec.rb +23 -0
  50. data/spec/lib/kb/cve_2015_3226_spec.rb +29 -0
  51. data/spec/lib/kb/cve_2015_3227_spec.rb +23 -0
  52. data/spec/lib/kb/osvdb_118579_spec.rb +8 -0
  53. data/spec/lib/kb/osvdb_118830_spec.rb +16 -0
  54. data/spec/lib/kb/osvdb_118954_spec.rb +8 -0
  55. data/spec/lib/kb/osvdb_119878_spec.rb +17 -0
  56. data/spec/lib/kb/osvdb_119927_spec.rb +16 -0
  57. data/spec/spec_helper.rb +3 -2
  58. metadata +63 -21
  59. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f0312208553d247840f6a71da2e0ef95c8c223d
4
- data.tar.gz: 5122a815d28cc9d701374407d04cf0c0b78e1b48
3
+ metadata.gz: 05b506c1430295b474c31984bc9a1b9a155b5d51
4
+ data.tar.gz: 7e0417a90ad9c5a2a054d1579b26ac0ce25747ff
5
5
  SHA512:
6
- metadata.gz: aef798632ca975c2c04b67a434a69e3ce5852ef83fc28ecf4e1e781b3f7e79adde54c6bb20459bcf7249acfe3968c77ef02cf4c87183c497c186fb6794f1cabe
7
- data.tar.gz: 14f385eb24b0745a67eaa8fd7e177e6a456b2c298434f794f54b2c952417f49ed728fdab3dc5592face49983de1e485b986905931bc6556d05be96019c4959e1
6
+ metadata.gz: fa103df76aeb6f50084803cd653aa328eb29734ac123ec06a4dd5a5d3cb2bb2600318c26ae36ab5669e06dd7d052197d1ca68a1c80594231e6be073832f58ed9
7
+ data.tar.gz: 8a8a0fe09ba77ec3d69433a33ed4cf75f9fbb469f6e3e9fd43f05841b38095ffe43d6b5b1d201f97de2d041214435f9c1361166762fc877a37e6a52d84a1a393
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/BUGS.md ADDED
@@ -0,0 +1,14 @@
1
+ # Dawnscanner - BUGS
2
+
3
+ In this file you will find bugs I (thesp0nge) will find during development
4
+ tests. This is a memo file for [github
5
+ issues](https://github.com/thesp0nge/dawnscanner/issues) opened by myself, I
6
+ can use when I'm offline.
7
+
8
+ | ID | Description | Status |
9
+ |----|------------------------|--------|
10
+ | B1 | when reviewing a Rails app, Source checks are not wired up. We must understand how to enable source checks in engines: source_check.rb:77:in `is_this_precondition_met?': undefined method `deep_each' for nil:NilClass | open |
11
+ | B2 | when reviewing a Sinatra app, we've got this error: engine.rb:42:in `[]': no implicit conversion of Symbol into Integer (TypeError) | open |
12
+ |----|------------------------|--------|
13
+
14
+ _last updated: Tue Jan 13 17:19:05 CET 2015_
data/Changelog.md CHANGED
@@ -5,7 +5,33 @@ It supports [Sinatra](http://www.sinatrarb.com),
5
5
  [Padrino](http://www.padrinorb.com) and [Ruby on Rails](http://rubyonrails.org)
6
6
  frameworks.
7
7
 
8
- _latest update: Thu Jan 8 17:19:37 CET 2015_
8
+ _latest update: Wed Jul 29 23:10:24 CEST 2015_
9
+
10
+ ## Version 1.3.5 - codename: Lightning McQueen (2015-07-29)
11
+
12
+ * Adding a check for CVE-2015-293: XSS in the paperclip gem (issue #139)
13
+ * Adding a check for CVE-2015-1840: CSRF in jquery-rails and jquery-ujs gems.
14
+ Please note that this is the first (and I hope the only) dependency check
15
+ splitted in two parts. People from NVD assigned a single CVE to a
16
+ vulnerability affecting two related but different gems. (issue #135)
17
+ * Adding a check for CVE-2015-3224: Whitelist bypass rack gem (issue #133)
18
+ * Adding a check for CVE-2015-3225: DoS in rack gem (issue #136)
19
+ * Adding a check for CVE-2015-3226: XSS in activesupport gem (issue #134)
20
+ * Adding a check for CVE-2015-3227: DoS in activesupport gem (issue #137)
21
+ * Adding a check for OSVDB-119927: MITM attack for http gem (issue #131)
22
+ * Adding a check for OSVDB-119878: Session Fixation for rest-client gem (issue #130)
23
+ * Adding a check for OSVDB-118954: Denial of service for rails gem (issue #129)
24
+ * Adding a check for OSVDB-118579: MySQL credentials disclosure due to a flaw
25
+ * Adding a check for OSVDB-118830: Sensitive information stored in production logs (issue #127)
26
+
27
+ ## Version 1.3.1 - codename: Lightning McQueen (2015-02-19)
28
+
29
+ * Fixed last namespace pollution errors. Codesake namespace went away (issue
30
+ #101)
31
+
32
+ ## Version 1.3.0 - codename: Lightning McQueen (2015-02-18)
33
+
34
+ * Renewing digital signing certificate (issue #100)
9
35
 
10
36
  ## Version 1.2.99 - codename: Lightning McQueen (2015-01-07)
11
37
 
data/KnowledgeBase.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Dawn Knowledge base
2
2
 
3
- The knowledge base library for Dawn version 1.2.0 contains 180 security checks.
3
+ The knowledge base library for Dawn version 1.3.5 contains 192 security checks.
4
4
  ---
5
5
  * Simple Form XSS - 20131129: There is a XSS vulnerability on Simple Form's label, hint and error options. When Simple Form creates a label, hint or error message it marks the text as being HTML safe, even though it may contain HTML tags. In applications where the text of these helpers can be provided by the users, malicious values can be provided and Simple Form will mark it as safe.
6
6
  * [CVE-2004-0755](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-0755): The FileStore capability in CGI::Session for Ruby before 1.8.1, and possibly PStore, creates files with insecure permissions, which can allow local users to steal session information and hijack sessions.
@@ -172,6 +172,13 @@ XML documents with carefully crafted entity expansion strings which can cause th
172
172
  * [CVE-2014-2538](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-2538): rack-ssl Gem for Ruby contains a flaw that allows a reflected cross-site scripting (XSS) attack. This flaw exists because the program does not validate input passed via error messages before returning it to users. This may allow a context-dependent attacker to create a specially crafted request that would execute arbitrary script code in a user's browser session within the trust relationship between their browser and the server.
173
173
  * [CVE-2014-3482](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3482): Ruby on Rails contains a flaw that may allow carrying out an SQL injection attack. The issue is due to the PostgreSQL adapter for Active Record not properly sanitizing user-supplied input when quoting bitstrings. This may allow a remote attacker to inject or manipulate SQL queries in the back-end database, allowing for the manipulation or disclosure of arbitrary data.
174
174
  * [CVE-2014-3483](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3483): Ruby on Rails contains a flaw that may allow carrying out an SQL injection attack. The issue is due to the PostgreSQL adapter for Active Record not properly sanitizing user-supplied input when quoting ranges. This may allow a remote attacker to inject or manipulate SQL queries in the back-end database, allowing for the manipulation or disclosure of arbitrary data.
175
+ * [CVE-2015-1849](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-1849): jquery_ujs.js in jquery-rails before 3.1.3 and 4.x before 4.0.4 and rails.js in jquery-ujs before 1.0.4, as used with Ruby on Rails 3.x and 4.x, allow remote attackers to bypass the Same Origin Policy, and trigger transmission of a CSRF token to a different-domain web server, via a leading space character in a URL within an attribute value.
176
+ * [CVE-2015-1849](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-1849): jquery_ujs.js in jquery-rails before 3.1.3 and 4.x before 4.0.4 and rails.js in jquery-ujs before 1.0.4, as used with Ruby on Rails 3.x and 4.x, allow remote attackers to bypass the Same Origin Policy, and trigger transmission of a CSRF token to a different-domain web server, via a leading space character in a URL within an attribute value.
177
+ * [CVE-2015-2963](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-2963): The thoughtbot paperclip gem before 4.2.2 for Ruby does not consider the content-type value during media-type validation, which allows remote attackers to upload HTML documents and conduct cross-site scripting (XSS) attacks via a spoofed value, as demonstrated by image/jpeg.
178
+ * [CVE-2015-3224](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-3224): request.rb in Web Console before 2.1.3, as used with Ruby on Rails 3.x and 4.x, does not properly restrict the use of X-Forwarded-For headers in determining a client's IP address, which allows remote attackers to bypass the whitelisted_ips protection mechanism via a crafted request.
179
+ * [CVE-2015-3225](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-3225): lib/rack/utils.rb in Rack before 1.5.4 and 1.6.x before 1.6.2, as used with Ruby on Rails 3.x and 4.x and other products, allows remote attackers to cause a denial of service (SystemStackError) via a request with a large parameter depth.
180
+ * [CVE-2015-3226](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-3226): Cross-site scripting (XSS) vulnerability in json/encoding.rb in Active Support in Ruby on Rails 3.x and 4.1.x before 4.1.11 and 4.2.x before 4.2.2 allows remote attackers to inject arbitrary web script or HTML via a crafted Hash that is mishandled during JSON encoding.
181
+ * [CVE-2015-3227](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-3227): The (1) jdom.rb and (2) rexml.rb components in Active Support in Ruby on Rails before 4.1.11 and 4.2.x before 4.2.2, when JDOM or REXML is enabled, allow remote attackers to cause a denial of service (SystemStackError) via a large XML document depth.
175
182
  * [OSVDB-105971](http://osvdb.org/show/osvdb/105971): sfpagent Gem for Ruby contains a flaw that is triggered as JSON[body] input is not properly sanitized when handling module names with shell metacharacters. This may allow a context-dependent attacker to execute arbitrary commands.
176
183
  * OSVDB-105971: sfpagent Gem for Ruby contains a flaw that is triggered as JSON[body] input is not properly sanitized when handling module names with shell metacharacters. This may allow a context-dependent attacker to execute arbitrary commands.
177
184
  * [OSVDB-108569](http://osvdb.org/show/osvdb/108569): backup_checksum Gem for Ruby contains a flaw in /lib/backup/cli/utility.rb that is triggered as the program displays password information in plaintext in the process list. This may allow a local attacker to gain access to password information.
@@ -182,6 +189,16 @@ XML documents with carefully crafted entity expansion strings which can cause th
182
189
  * OSVDB-108530: kajam Gem for Ruby contains a flaw in /dataset/lib/dataset/database/postgresql.rb that is triggered when handling metacharacters. This may allow a remote attacker to execute arbitrary commands.
183
190
  * [OSVDB-108563](http://osvdb.org/show/osvdb/108563): gyazo Gem for Ruby contains a flaw in client.rb that is triggered when handling metacharacters. This may allow a remote attacker to execute arbitrary commands.
184
191
  * OSVDB-108563: gyazo Gem for Ruby contains a flaw in client.rb that is triggered when handling metacharacters. This may allow a remote attacker to execute arbitrary commands.
192
+ * [OSVDB_118579](http://osvdb.org/show/osvdb/118579): xaviershay-dm-rails Gem for Ruby contains a flaw in the execute() function in /datamapper/dm-rails/blob/master/lib/dm-rails/storage.rb. The issue is due to the function exposing sensitive information via the process table. This may allow a local attack to gain access to MySQL credential information.
193
+ * OSVDB_118579: xaviershay-dm-rails Gem for Ruby contains a flaw in the execute() function in /datamapper/dm-rails/blob/master/lib/dm-rails/storage.rb. The issue is due to the function exposing sensitive information via the process table. This may allow a local attack to gain access to MySQL credential information.
194
+ * [OSVDB_118830](http://osvdb.org/show/osvdb/118830): Doorkeeper Gem for Ruby contains a flaw in lib/doorkeeper/engine.rb. The issue is due to the program storing sensitive information in production logs. This may allow a local attacker to gain access to sensitive information.
195
+ * OSVDB_118830: Doorkeeper Gem for Ruby contains a flaw in lib/doorkeeper/engine.rb. The issue is due to the program storing sensitive information in production logs. This may allow a local attacker to gain access to sensitive information.
196
+ * [OSVDB_118954](http://osvdb.org/show/osvdb/118954): Ruby on Rails contains a flaw that is triggered when handling a to_json call to ActiveModel::Name, which can cause an infinite loop. This may allow a remote attacker to cause a denial of service.
197
+ * OSVDB_118954: Ruby on Rails contains a flaw that is triggered when handling a to_json call to ActiveModel::Name, which can cause an infinite loop. This may allow a remote attacker to cause a denial of service.
198
+ * [OSVDB_119878](http://osvdb.org/show/osvdb/119878): rest-client Gem for Ruby contains a flaw in abstract_response.rb related to the handling of set-cookie headers in redirection responses that allows a remote, user-assisted attacker to conduct a session fixation attack. This flaw exists because the application, when establishing a new session, does not invalidate an existing session identifier and assign a new one. With a specially crafted request fixating the session identifier, a context-dependent attacker can ensure a user authenticates with the known session identifier, allowing the session to be subsequently hijacked.
199
+ * OSVDB_119878: rest-client Gem for Ruby contains a flaw in abstract_response.rb related to the handling of set-cookie headers in redirection responses that allows a remote, user-assisted attacker to conduct a session fixation attack. This flaw exists because the application, when establishing a new session, does not invalidate an existing session identifier and assign a new one. With a specially crafted request fixating the session identifier, a context-dependent attacker can ensure a user authenticates with the known session identifier, allowing the session to be subsequently hijacked.
200
+ * [OSVDB_119927](http://osvdb.org/show/osvdb/119927): http Gem for Ruby contains a flaw related to certificate validation. The issue is due to a failure to call the OpenSSL::SSL::SSLSocket#post_connection_check method, leading to hostnames not being properly verified. By spoofing the TLS/SSL server via a certificate that appears valid, an attacker with the ability to intercept network traffic (e.g. MiTM, DNS cache poisoning) can disclose and optionally manipulate transmitted data.
201
+ * OSVDB_119927: http Gem for Ruby contains a flaw related to certificate validation. The issue is due to a failure to call the OpenSSL::SSL::SSLSocket#post_connection_check method, leading to hostnames not being properly verified. By spoofing the TLS/SSL server via a certificate that appears valid, an attacker with the ability to intercept network traffic (e.g. MiTM, DNS cache poisoning) can disclose and optionally manipulate transmitted data.
185
202
  * Owasp Ror CheatSheet: Command Injection: Ruby offers a function called "eval" which will dynamically build new Ruby code based on Strings. It also has a number of ways to call system commands. While the power of these commands is quite useful, extreme care should be taken when using them in a Rails based application. Usually, its just a bad idea. If need be, a whitelist of possible values should be used and any input should be validated as thoroughly as possible. The Ruby Security Reviewer's Guide has a section on injection and there are a number of OWASP references for it, starting at the top: Command Injection.
186
203
  * Owasp Ror CheatSheet: Cross Site Request Forgery: Ruby on Rails has specific, built in support for CSRF tokens. To enable it, or ensure that it is enabled, find the base ApplicationController and look for the protect_from_forgery directive. Note that by default Rails does not provide CSRF protection for any HTTP GET request.
187
204
  * Owasp Ror CheatSheet: Session management: By default, Ruby on Rails uses a Cookie based session store. What that means is that unless you change something, the session will not expire on the server. That means that some default applications may be vulnerable to replay attacks. It also means that sensitive information should never be put in the session.
@@ -210,4 +227,4 @@ Setting this to true will essentially strip out any host information.
210
227
  This check will analyze the source code looking for the following patterns: XXX, TO_CHECK, CHECKME, CHECK and FIXME
211
228
 
212
229
 
213
- _Last updated: Tue 08 Jul 17:59:10 CEST 2014_
230
+ _Last updated: Wed 29 Jul 23:06:16 CEST 2015_
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Paolo Perego
1
+ Copyright (c) 2013-2015 Paolo Perego
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -23,7 +23,7 @@ box:
23
23
 
24
24
  ---
25
25
 
26
- Dawn version 1.3 has 180 security checks loaded in its knowledge
26
+ Dawn version 1.3.5 has 192 security checks loaded in its knowledge
27
27
  base. Most of them are CVE bulletins applying to gems or the ruby interpreter
28
28
  itself. There are also some check coming from Owasp Ruby on Rails cheatsheet.
29
29
 
@@ -88,7 +88,7 @@ And then upgrade your bundle
88
88
  You may want to build it from source, so you have to check it out from github first:
89
89
 
90
90
  $ git clone https://github.com/thesp0nge/dawnscanner.git
91
- $ cd dawn
91
+ $ cd dawnscanner
92
92
  $ bundle install
93
93
  $ rake install
94
94
 
data/Rakefile CHANGED
@@ -24,6 +24,44 @@ task :test => :spec
24
24
  task :prepare => [:build, :'checksum:calculate', :'checksum:commit']
25
25
  task :release => [:prepare]
26
26
 
27
+ namespace :version do
28
+ desc 'Calculate some infos you want to put in version.rb'
29
+ task :update do
30
+ build_number = `git describe --tags --long | cut -d \'-\' -f 2`
31
+ commit_hash = `git describe --tags --long | cut -d \'-\' -f 3`
32
+ release = Time.now.strftime("%Y%m%d")
33
+ branch = `git symbolic-ref HEAD 2> /dev/null`
34
+ branch_name = branch.split('/')[2].chomp
35
+ a=[]
36
+ File.open("VERSION", "r") do |f|
37
+ a = f.readlines
38
+ end
39
+ version = a[a.length - 1].split('-')[0]# .chomp
40
+ codename = a[a.length - 1].split('-')[1]
41
+
42
+ File.open("./lib/dawn/version.rb", "w") do |f|
43
+
44
+ f.puts("module Dawn")
45
+
46
+ puts "#{branch_name}|"
47
+ if branch_name != "master"
48
+ av = version.split('.')
49
+ f.puts " VERSION = \"#{av[0]}.#{av[1]}.#{commit_hash.chop}\""
50
+ f.puts " CODENAME = \"#{codename.lstrip!.chop}\""
51
+ f.puts " RELEASE = \"(development)\""
52
+ else
53
+ puts "here"
54
+ f.puts " VERSION = \"#{version.rstrip!}\""
55
+ f.puts " CODENAME = \"#{codename.lstrip!.chop}\""
56
+ f.puts " RELEASE = \"#{release}\""
57
+ end
58
+ f.puts " BUILD = \"#{build_number.chop}\""
59
+ f.puts " COMMIT = \"#{commit_hash.chop}\""
60
+ f.puts "end"
61
+ end
62
+ end
63
+ end
64
+
27
65
  # namespace :check do
28
66
  # desc "Create a dependency check"
29
67
  # task :dependency, :name do |t, args|
@@ -90,6 +128,68 @@ task :cve, :name do |t,args|
90
128
 
91
129
  end
92
130
 
131
+ desc "Create a new OSVDB security check"
132
+ task :osvdb, :name do |t,args|
133
+ name = args.name
134
+ SRC_DIR = "./lib/dawn/kb/"
135
+ SPEC_DIR = "./spec/lib/kb/"
136
+
137
+ raise "### It seems that #{name} is already in Dawn knowledge base" unless Dawn::KnowledgeBase.find(nil, name).nil?
138
+ raise "### Invalid OSVDB identifier: #{name}" if name.nil? or name.empty? or /\d{6}/.match(name).nil?
139
+ raise "### No target directory: #{SRC_DIR}" unless Dir.exists?(SRC_DIR)
140
+ raise "### No rspec directory: #{SPEC_DIR}" unless Dir.exists?(SPEC_DIR)
141
+
142
+ puts "Adding #{name} to knowledge base..."
143
+
144
+ name = "OSVDB_"+name
145
+
146
+ rb_filename = SRC_DIR+name.downcase.gsub("-", "_")+".rb"
147
+ spec_filename = SPEC_DIR+name.downcase.gsub("-", "_")+"_spec.rb"
148
+ class_name = name.gsub("-", "_")
149
+
150
+ open(rb_filename, "w") do |file|
151
+ file.puts "module Dawn"
152
+ file.puts "\t\tmodule Kb"
153
+ file.puts "\t\t\t# Automatically created with rake on #{Time.now.strftime('%Y-%m-%d')}"
154
+ file.puts "\t\t\tclass #{class_name}"
155
+ file.puts "\t\t\t\t# Include the testing skeleton for this Security Check"
156
+ file.puts "\t\t\t\t# include PatternMatchCheck"
157
+ file.puts "\t\t\t\t# include DependencyCheck"
158
+ file.puts "\t\t\t\t# include RubyVersionCheck"
159
+ file.puts ""
160
+ file.puts "\t\t\t\tdef initialize"
161
+ file.puts "\t\t\t\tend"
162
+ file.puts "\t\t\tend"
163
+ file.puts "\t\tend"
164
+ file.puts "end"
165
+ end
166
+ puts "#{rb_filename} created"
167
+
168
+ open(spec_filename, "w") do |file|
169
+ file.puts "require 'spec_helper'"
170
+
171
+ file.puts "describe \"The #{name} vulnerability\" do"
172
+ file.puts "\tbefore(:all) do"
173
+ file.puts "\t\t@check = Dawn::Kb::#{class_name}.new"
174
+ file.puts "\t\t# @check.debug = true"
175
+ file.puts "\tend"
176
+ file.puts "\tit \"is reported when...\""
177
+ file.puts "end"
178
+ end
179
+ puts "#{spec_filename} created"
180
+
181
+
182
+ puts "*** PLEASE IMPLEMENT TEST FOR #{name} IN spec/lib/dawn/codesake_knowledgebase_spec.rb in order to reflect changes"
183
+ puts "*** PLEASE ADD THIS CODE IN lib/dawn/knowledge_base.rb in order to reflect changes"
184
+ puts "require \"dawn/kb/#{class_name.downcase}\""
185
+ puts "it \"must have test for #{name}\" do"
186
+ puts " sc = kb.find(\"#{name}\")"
187
+ puts " sc.should_not be_nil"
188
+ puts " sc.class.should == Dawn::Kb::#{class_name}"
189
+ puts "end"
190
+
191
+ end
192
+
93
193
 
94
194
 
95
195
  desc "Create a new Generic security check"
data/Roadmap.md CHANGED
@@ -1,4 +1,4 @@
1
- # Codesake Dawn - roadmap
1
+ # Dawnscanner - roadmap
2
2
 
3
3
  Dawnscanner is a static analysis security scanner for ruby written web applications.
4
4
  It supports [Sinatra](http://www.sinatrarb.com),
@@ -7,10 +7,14 @@ frameworks.
7
7
 
8
8
  This is an ongoing roadmap for the Dawnscanner source code review tool.
9
9
 
10
- _latest update: Mon Mar 31 13:01:21 CEST 2014_
10
+ _latest update: Tue Feb 24 08:02:56 CET 2015_
11
11
 
12
- ## Version 1.2.0
12
+ ## Version 1.4.0
13
13
 
14
+ * clear Codesake:Commons dependency mess. This will dramatically simplify
15
+ dawnscanner installation
16
+ * Add a --github option to Dawnscanner to clone a remote repository, perform
17
+ a bundle install and do a code review.
14
18
  * create a task to check for new CVE in NVD website
15
19
  * SQLite3 integration for saving data. Each project will have its own SQLite
16
20
  database containing reviews, findings and all. A table with Dawnscanner version it
@@ -18,33 +22,38 @@ _latest update: Mon Mar 31 13:01:21 CEST 2014_
18
22
  * add a language check. It will handle a ruby script as input and a
19
23
  ruby\_parser line as unsafe pattern. It will compile the ruby and look for
20
24
  the unsafe pattern
21
- * Add preliminary Cross Site Scripting detection for Ruby on Rails.
22
25
  * Issue #7: Improving HTML output and let the user the capability to provide a
23
26
  basic layout to customize report
24
- * Add a ruby deprecation check, accordingly to
25
- https://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
27
+ * adding test for CVE-2011-4969 XSS in jquery < 1.6.2
28
+ * add source code metrics gathering (lines of code, lines of comments,
29
+ cyclomatic complexity index, ...)
30
+
26
31
 
27
- ## Version 1.3.0
32
+ ## Version 1.5.0
28
33
 
34
+ * Add a ruby deprecation check, accordingly to
35
+ https://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
36
+ * Add preliminary Cross Site Scripting detection for Ruby on Rails.
29
37
  * Add support for ERB for in detect\_views
30
38
  * Add preliminary javascript support
31
- * adding test for CVE-2011-4969 XSS in jquery < 1.6.2
32
39
  * add support for pure Rack applications
33
40
  * Cross Site Scripting detection: it must be done for all MVC frameworks
34
41
  (including Rack) and it must cover either reflected than stored attack
35
42
  patterns
36
- * Add a --github option to Dawnscanner to clone a remote repository, perform
37
- a bundle install and do a code review.
38
43
  * Add support for github hooks
39
44
  * Add premilinary SQL injection detection for Ruby on Rails
40
45
 
41
- ## Version 1.5.0
46
+ ## Version 1.6.0
42
47
 
43
48
  * Add insecure direct object reference detection for all MVC frameworks (including Rack)
44
49
  * SQL Injection detection: it must be done for all MVC frameworks (including Rack)
45
50
  * Add automatic mitigation patch generation
46
51
  * Add support for Javascript
47
52
 
53
+ ## Version 1.7.0
54
+
55
+ * Add automatic mitigation patch generation
56
+
48
57
  # Spinoff projects
49
58
 
50
59
  Dawnscanner is a security scanner for ruby code. Modern web applications
@@ -57,3 +66,8 @@ Dawnscanner can be wrote also to support them:
57
66
  Initially they were in the Dawnscanner roadmap for a 2.0.0 version. However
58
67
  we decide to drop this in the name of being focused on ruby programming
59
68
  language.
69
+
70
+ PHP has a good open source code scanners ecosystem, instead JAVA has not.
71
+ Players started open and eventually they turned in big commercial bloatware
72
+ GUIs that are useless from the security specialist perspective. A simple
73
+ bytecode analyzer, with some checks, can be a possible spinoff project.
data/VERSION ADDED
@@ -0,0 +1,16 @@
1
+ # Each dawnscanner major release will have a Disney Pixar Cars / Cars2
2
+ # character as codename. My son Daniele loves those films and since I love
3
+ # him too, this is a kinda sort of tribute of my son's passion.
4
+ #
5
+ # Future releases
6
+ #
7
+ # | Character | Release |
8
+ # |-----------------|----------|
9
+ # | "Tow Mater" | 1.4.0 |
10
+ # | "Finn McMissile"| 1.6.0 |
11
+ # | "Fillmore" | 1.8.0 |
12
+ # |"Holly Shiftwell"| 1.10.0 |
13
+ # | "Guido" | 1.12.0 |
14
+ # | "Luigi" | 1.14.0 |
15
+ # | "Doc Hudson" | 1.16.0 |
16
+ 1.3.5 - Lightning McQueen
data/bin/dawn CHANGED
@@ -6,14 +6,18 @@ require 'terminal-table'
6
6
 
7
7
  require 'justify'
8
8
 
9
- require 'codesake-commons'
9
+ # require 'codesake-commons'
10
10
  require 'dawnscanner'
11
11
 
12
12
  APPNAME = File.basename($0)
13
13
  LIST_KNOWN_FRAMEWORK = %w(rails sinatra padrino)
14
14
  VALID_OUTPUT_FORMAT = %w(console json csv html)
15
15
 
16
- $logger = Codesake::Commons::Logging.instance
16
+ # $logger = Codesake::Commons::Logging.instance
17
+ require 'logger'
18
+ $logger = Logger.new(STDOUT)
19
+ $logger.datetime_format = '%Y-%m-%d %H:%M:%S'
20
+
17
21
  opts = GetoptLong.new(
18
22
  # report formatting options
19
23
  [ '--ascii-tabular-report', '-a', GetoptLong::NO_ARGUMENT],
@@ -144,7 +148,7 @@ end
144
148
  rescue GetoptLong::InvalidOption => e
145
149
 
146
150
  $logger.helo APPNAME, Dawn::VERSION
147
- $logger.err e.message
151
+ $logger.error e.message
148
152
  Kernel.exit(Dawn::Core.help)
149
153
  end
150
154
 
@@ -155,7 +159,7 @@ trap("INT") { $logger.die('[INTERRUPTED]') }
155
159
  $logger.die("missing target") if target.nil? && options[:gemfile_name].empty?
156
160
  $logger.die("invalid directory (#{target})") if options[:gemfile_name].empty? &&! Dawn::Core.is_good_target?(target)
157
161
  $logger.die("if scanning Gemfile.lock file you must not force target MVC using one from -r, -s or -p flag") if ! options[:mvc].empty? && options[:gemfile_scan]
158
- $logger.log("security check enabled: #{options[:enabled_checks]}") if options[:debug]
162
+ $logger.debug("security check enabled: #{options[:enabled_checks]}") if options[:debug]
159
163
 
160
164
 
161
165
  ## MVC auto detect.
@@ -165,7 +169,7 @@ unless options[:gemfile_scan]
165
169
  begin
166
170
  if options[:mvc].empty?
167
171
  engine = Dawn::Core.detect_mvc(target)
168
- $logger.log("using #{engine.class.name} engine via autodect") if options[:debug]
172
+ $logger.debug("using #{engine.class.name} engine via autodect") if options[:debug]
169
173
  else
170
174
  engine = Dawn::Rails.new(target) if options[:mvc] == :rails
171
175
  engine = Dawn::Sinatra.new(target) if options[:mvc] == :sinatra
@@ -0,0 +1 @@
1
+ 06aee0b1bba7922a459aca13c5668fc938b120d7
data/dawnscanner.gemspec CHANGED
@@ -7,11 +7,10 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "dawnscanner"
8
8
  gem.version = Dawn::VERSION
9
9
  gem.authors = ["Paolo Perego"]
10
- gem.email = ["paolo@codesake.com"]
11
- gem.description = %q{Dawn is a security source code scanner for ruby powered code.}
12
- gem.summary = %q{Codesake::Dawn is a security source code scanner for ruby powered code.}
13
- gem.homepage = "http://dawn.codesake.com"
14
-
10
+ gem.email = ["paolo@dawnscanner.org"]
11
+ gem.description = %q{Dawn is a security source code scanner for ruby powered code. It is especially designed for web applications, but it works also with general purpose ruby scripts. Dawn supports all major MVC frameworks like ruby on rails, padrino and sinatra; it provides more than 150 security checks with their own mitigation suggestion.}
12
+ gem.summary = %q{Dawn is a security source code scanner for ruby powered code. It is crafted with love to make your sinatra, padrino and ruby on rails web applications secure.}
13
+ gem.homepage = "http://dawnscanner.org"
15
14
  gem.files = `git ls-files`.split($/)
16
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -22,7 +21,6 @@ Gem::Specification.new do |gem|
22
21
 
23
22
  gem.required_ruby_version = '>= 1.9.2'
24
23
 
25
- gem.add_dependency "codesake-commons", "~> 1.0.0"
26
24
  gem.add_dependency 'cvss'
27
25
  gem.add_dependency 'haml'
28
26
  gem.add_dependency 'parser'
@@ -32,6 +30,7 @@ Gem::Specification.new do |gem|
32
30
  gem.add_dependency 'grit'
33
31
  gem.add_dependency 'terminal-table'
34
32
  gem.add_dependency 'justify'
33
+ gem.add_dependency 'logger-colors'
35
34
 
36
35
  gem.add_dependency ('coveralls')
37
36
 
@@ -121,8 +121,18 @@ module Dawn
121
121
  @check_family = :cve if !options[:name].nil? && options[:name].start_with?('CVE-')
122
122
 
123
123
  if $logger.nil?
124
- require 'codesake-commons'
125
- $logger = Codesake::Commons::Logging.instance
124
+ # This is the old codesake-commons logging.
125
+ #
126
+ # Starting from 20150720 we will use the standard library Logger
127
+ # class. This is mainly to remove codesake-commons dependency and to
128
+ # have a clean API
129
+ #
130
+ # require 'codesake-commons'
131
+ # $logger = Codesake::Commons::Logging.instance
132
+ # $logger.helo "dawn-basic-check", Dawn::VERSION
133
+
134
+ require 'dawn/logger'
135
+ $logger = Logger.new(STDOUT)
126
136
  $logger.helo "dawn-basic-check", Dawn::VERSION
127
137
  end
128
138
  end
@@ -151,6 +161,11 @@ module Dawn
151
161
  return "Unknown"
152
162
  end
153
163
 
164
+ def cve
165
+ return @cve unless @cve.nil?
166
+ return @name.gsub("CVE-", "") if @cve.nil? && @name.start_with?("CVE-")
167
+ end
168
+
154
169
  def priority
155
170
  return (@priority == :none)? "unknown" : @priority.to_s
156
171
  end
@@ -166,13 +181,13 @@ module Dawn
166
181
  return "critical"
167
182
  when 7..9
168
183
  return "high"
169
- when 4..6
184
+ when 4..7
170
185
  return "medium"
171
- when 2..3
186
+ when 2..4
172
187
  return "low"
173
- when 0..1
188
+ when 0..2
174
189
  return "info"
175
- else
190
+ else
176
191
  return "unknown"
177
192
  end
178
193
  else
@@ -213,11 +228,11 @@ module Dawn
213
228
  # @return an Array with attributes with a nil value
214
229
  def lint
215
230
  ret = []
216
- ret << :cve if @cve.nil?
231
+ ret << :cve if self.cve.nil?
217
232
  ret << :osvdb if @osvdb.nil?
218
- ret << :cvss if @cvss.nil?
219
- ret << :severity if @severity == :none
220
- ret << :priority if @priority == :none
233
+ ret << :cvss if self.cvss.nil? || self.cvss.empty? || self.cvss == "not assigned"
234
+ ret << :severity if self.severity == "unknown"
235
+ ret << :priority if self.priority == "unknown"
221
236
 
222
237
  ret
223
238
  end