aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/new_base
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-04-17 16:50:39 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-06 13:36:58 -0300
commitbdcd5f94b2efdf661f201917d63476c245aa7c09 (patch)
tree4145ce7fa474621078cdeff798f7b690a98c7f84 /actionpack/test/controller/new_base
parente167a54785e319c526b638d591eaca0c4da93a54 (diff)
downloadrails-bdcd5f94b2efdf661f201917d63476c245aa7c09.tar.gz
rails-bdcd5f94b2efdf661f201917d63476c245aa7c09.tar.bz2
rails-bdcd5f94b2efdf661f201917d63476c245aa7c09.zip
Only accept actions without File::SEPARATOR in the name.
This will avoid directory traversal in implicit render. Fixes: CVE-2014-0130 Conflicts: actionpack/lib/abstract_controller/base.rb
Diffstat (limited to 'actionpack/test/controller/new_base')
-rw-r--r--actionpack/test/controller/new_base/render_implicit_action_test.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/test/controller/new_base/render_implicit_action_test.rb b/actionpack/test/controller/new_base/render_implicit_action_test.rb
index 1e2191d417..5b4885f7e0 100644
--- a/actionpack/test/controller/new_base/render_implicit_action_test.rb
+++ b/actionpack/test/controller/new_base/render_implicit_action_test.rb
@@ -6,7 +6,7 @@ module RenderImplicitAction
"render_implicit_action/simple/hello_world.html.erb" => "Hello world!",
"render_implicit_action/simple/hyphen-ated.html.erb" => "Hello hyphen-ated!",
"render_implicit_action/simple/not_implemented.html.erb" => "Not Implemented"
- )]
+ ), ActionView::FileSystemResolver.new(File.expand_path('../../../controller', __FILE__))]
def hello_world() end
end
@@ -33,10 +33,25 @@ module RenderImplicitAction
assert_status 200
end
+ test "render does not traverse the file system" do
+ assert_raises(AbstractController::ActionNotFound) do
+ action_name = %w(.. .. fixtures shared).join(File::SEPARATOR)
+ SimpleController.action(action_name).call(Rack::MockRequest.env_for("/"))
+ end
+ end
+
test "available_action? returns true for implicit actions" do
assert SimpleController.new.available_action?(:hello_world)
assert SimpleController.new.available_action?(:"hyphen-ated")
assert SimpleController.new.available_action?(:not_implemented)
end
+
+ test "available_action? does not allow File::SEPARATOR on the name" do
+ action_name = %w(evil .. .. path).join(File::SEPARATOR)
+ assert_equal false, SimpleController.new.available_action?(action_name.to_sym)
+
+ action_name = %w(evil path).join(File::SEPARATOR)
+ assert_equal false, SimpleController.new.available_action?(action_name.to_sym)
+ end
end
end