提交 6b3991dd 编写于 作者: J Justin Collins

Merge branch 'fix_mail_to_vuln_check'

...@@ -23,7 +23,8 @@ class Brakeman::CheckMailTo < Brakeman::BaseCheck ...@@ -23,7 +23,8 @@ class Brakeman::CheckMailTo < Brakeman::BaseCheck
:warning_type => "Mail Link", :warning_type => "Mail Link",
:message => message, :message => message,
:confidence => CONFIDENCE[:high], :confidence => CONFIDENCE[:high],
:file => gemfile_or_environment :file => gemfile_or_environment,
:link_path => "https://groups.google.com/d/topic/rubyonrails-security/8CpI7egxX4E/discussion"
end end
end end
...@@ -33,13 +34,10 @@ class Brakeman::CheckMailTo < Brakeman::BaseCheck ...@@ -33,13 +34,10 @@ class Brakeman::CheckMailTo < Brakeman::BaseCheck
Brakeman.debug "Checking calls to mail_to for javascript encoding" Brakeman.debug "Checking calls to mail_to for javascript encoding"
tracker.find_call(:target => false, :method => :mail_to).each do |result| tracker.find_call(:target => false, :method => :mail_to).each do |result|
call = result[:call] result[:call].arglist.each do |arg|
args = call.args
args.each do |arg|
if hash? arg if hash? arg
if hash_access(arg, :javascript) if option = hash_access(arg, :encode)
return result return result if symbol? option and option.value == :javascript
end end
end end
end end
......
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'rails', '3.0.5' gem 'rails', '3.0.3'
# Bundle edge Rails instead: # Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git' # gem 'rails', :git => 'git://github.com/rails/rails.git'
......
...@@ -2,12 +2,12 @@ GEM ...@@ -2,12 +2,12 @@ GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
abstract (1.0.0) abstract (1.0.0)
actionmailer (3.0.5) actionmailer (3.0.3)
actionpack (= 3.0.5) actionpack (= 3.0.3)
mail (~> 2.2.15) mail (~> 2.2.15)
actionpack (3.0.5) actionpack (3.0.3)
activemodel (= 3.0.5) activemodel (= 3.0.3)
activesupport (= 3.0.5) activesupport (= 3.0.3)
builder (~> 2.1.2) builder (~> 2.1.2)
erubis (~> 2.6.6) erubis (~> 2.6.6)
i18n (~> 0.4) i18n (~> 0.4)
...@@ -15,19 +15,19 @@ GEM ...@@ -15,19 +15,19 @@ GEM
rack-mount (~> 0.6.13) rack-mount (~> 0.6.13)
rack-test (~> 0.5.7) rack-test (~> 0.5.7)
tzinfo (~> 0.3.23) tzinfo (~> 0.3.23)
activemodel (3.0.5) activemodel (3.0.3)
activesupport (= 3.0.5) activesupport (= 3.0.3)
builder (~> 2.1.2) builder (~> 2.1.2)
i18n (~> 0.4) i18n (~> 0.4)
activerecord (3.0.5) activerecord (3.0.3)
activemodel (= 3.0.5) activemodel (= 3.0.3)
activesupport (= 3.0.5) activesupport (= 3.0.3)
arel (~> 2.0.2) arel (~> 2.0.2)
tzinfo (~> 0.3.23) tzinfo (~> 0.3.23)
activeresource (3.0.5) activeresource (3.0.3)
activemodel (= 3.0.5) activemodel (= 3.0.3)
activesupport (= 3.0.5) activesupport (= 3.0.3)
activesupport (3.0.5) activesupport (3.0.3)
arel (2.0.10) arel (2.0.10)
builder (2.1.2) builder (2.1.2)
erubis (2.6.6) erubis (2.6.6)
...@@ -45,17 +45,17 @@ GEM ...@@ -45,17 +45,17 @@ GEM
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (0.5.7) rack-test (0.5.7)
rack (>= 1.0) rack (>= 1.0)
rails (3.0.5) rails (3.0.3)
actionmailer (= 3.0.5) actionmailer (= 3.0.3)
actionpack (= 3.0.5) actionpack (= 3.0.3)
activerecord (= 3.0.5) activerecord (= 3.0.3)
activeresource (= 3.0.5) activeresource (= 3.0.3)
activesupport (= 3.0.5) activesupport (= 3.0.3)
bundler (~> 1.0) bundler (~> 1.0)
railties (= 3.0.5) railties (= 3.0.3)
railties (3.0.5) railties (3.0.3)
actionpack (= 3.0.5) actionpack (= 3.0.3)
activesupport (= 3.0.5) activesupport (= 3.0.3)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (~> 0.14.4) thor (~> 0.14.4)
rake (0.9.2) rake (0.9.2)
...@@ -70,5 +70,5 @@ PLATFORMS ...@@ -70,5 +70,5 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
rails (= 3.0.5) rails (= 3.0.3)
sqlite3 sqlite3
...@@ -39,4 +39,8 @@ class OtherController < ApplicationController ...@@ -39,4 +39,8 @@ class OtherController < ApplicationController
def test_render_with_nonsymbol_key def test_render_with_nonsymbol_key
render x => :y render x => :y
end end
def test_mail_to
@user = User.find(current_user)
end
end end
<%= mail_to @user.email, @user.name, :encode => :javascript %>
Should not warn:
<%= mail_to @user.email, @user.name, :encode => :hex %>
...@@ -11,6 +11,8 @@ Rails3::Application.routes.draw do ...@@ -11,6 +11,8 @@ Rails3::Application.routes.draw do
get "other/test_send_file" get "other/test_send_file"
get "other/test_mail_to"
get "home/index" get "home/index"
get "home/test_params" get "home/test_params"
......
...@@ -14,7 +14,7 @@ class Rails3Tests < Test::Unit::TestCase ...@@ -14,7 +14,7 @@ class Rails3Tests < Test::Unit::TestCase
@expected ||= { @expected ||= {
:controller => 1, :controller => 1,
:model => 5, :model => 5,
:template => 29, :template => 30,
:warning => 30 :warning => 30
} }
end end
...@@ -532,7 +532,7 @@ class Rails3Tests < Test::Unit::TestCase ...@@ -532,7 +532,7 @@ class Rails3Tests < Test::Unit::TestCase
def test_default_routes def test_default_routes
assert_warning :warning_type => "Default Routes", assert_warning :warning_type => "Default Routes",
:line => 95, :line => 97,
:message => /All public methods in controllers are available as actions/, :message => /All public methods in controllers are available as actions/,
:file => /routes\.rb/ :file => /routes\.rb/
end end
...@@ -572,7 +572,7 @@ class Rails3Tests < Test::Unit::TestCase ...@@ -572,7 +572,7 @@ class Rails3Tests < Test::Unit::TestCase
def test_string_buffer_manipulation_bug def test_string_buffer_manipulation_bug
assert_warning :type => :warning, assert_warning :type => :warning,
:warning_type => "Cross Site Scripting", :warning_type => "Cross Site Scripting",
:message => /^Rails 3.0.5 has a vulnerabilty in SafeBuffer. Upgrade to 3.0.12/, :message => /^Rails 3\.\d\.\d has a vulnerabilty in SafeBuffer. Upgrade to 3.0.12/,
:confidence => 1, :confidence => 1,
:file => /Gemfile/ :file => /Gemfile/
end end
...@@ -653,7 +653,7 @@ class Rails3Tests < Test::Unit::TestCase ...@@ -653,7 +653,7 @@ class Rails3Tests < Test::Unit::TestCase
assert_warning :type => :template, assert_warning :type => :template,
:warning_type => "Cross Site Scripting", :warning_type => "Cross Site Scripting",
:line => 3, :line => 3,
:message => /^Upgrade\ to\ Rails\ 3\.0\.17,\ 3\.0\.5\ select_ta/, :message => /^Upgrade\ to\ Rails\ 3\.0\.17,\ 3\.0\.3\ select_ta/,
:confidence => 0, :confidence => 0,
:file => /test_select_tag\.html\.erb/ :file => /test_select_tag\.html\.erb/
end end
...@@ -661,7 +661,7 @@ class Rails3Tests < Test::Unit::TestCase ...@@ -661,7 +661,7 @@ class Rails3Tests < Test::Unit::TestCase
def test_cross_site_scripting_single_quotes_CVE_2012_3464 def test_cross_site_scripting_single_quotes_CVE_2012_3464
assert_warning :type => :warning, assert_warning :type => :warning,
:warning_type => "Cross Site Scripting", :warning_type => "Cross Site Scripting",
:message => /^Rails\ 3\.0\.5\ does\ not\ escape\ single\ quote/, :message => /^Rails\ 3\.0\.3\ does\ not\ escape\ single\ quote/,
:confidence => 1, :confidence => 1,
:file => /Gemfile/ :file => /Gemfile/
end end
...@@ -681,4 +681,13 @@ class Rails3Tests < Test::Unit::TestCase ...@@ -681,4 +681,13 @@ class Rails3Tests < Test::Unit::TestCase
:confidence => 0, :confidence => 0,
:file => /Gemfile/ :file => /Gemfile/
end end
def test_mail_link_CVE_2011_0446
assert_warning :type => :template,
:warning_type => "Mail Link",
:line => 1,
:message => /^Vulnerability\ in\ mail_to\ using\ javascrip/,
:confidence => 0,
:file => /Gemfile/
end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册