Skip to content

Commit 5f2195a

Browse files
committed
Regression test for rendering file from absolute path
Test that we are not allowing you to grab a file with an absolute path outside of your application directory. This is dangerous because it could be used to retrieve files from the server like `/etc/passwd`.
1 parent 8cbf301 commit 5f2195a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

actionpack/test/controller/render_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,17 @@ def test_dynamic_render_with_file
278278
response.body
279279
end
280280

281+
def test_dynamic_render_with_absolute_path
282+
file = Tempfile.new
283+
file.write "secrets!"
284+
file.flush
285+
assert_raises ActionView::MissingTemplate do
286+
response = get :dynamic_render, { id: file.path }
287+
end
288+
ensure
289+
file.unlink
290+
end
291+
281292
def test_dynamic_render
282293
assert File.exist?(File.join(File.dirname(__FILE__), '../../test/abstract_unit.rb'))
283294
assert_raises ActionView::MissingTemplate do

0 commit comments

Comments
 (0)