Blame SOURCES/rubygem-sprockets-3.7.2-CVE-2018-3760-Fix-Path-traversal-in-sprockets-server-tests.patch

dea975
From 9c34fa05900b968d74f08ccf40917848a7be9441 Mon Sep 17 00:00:00 2001
dea975
From: schneems <richard.schneeman+foo@gmail.com>
dea975
Date: Tue, 24 Apr 2018 16:32:22 -0500
dea975
Subject: [PATCH] Do not respond to http requests asking for a `file://`
dea975
dea975
Based on CVE-2018-3760 when the Sprockets server is accidentally being used in production, an attacker can pass in a specifically crafted url that will allow them access to view every file on the system. If the file hit contains a compilable extension such as `.erb` then the code in that file will be executed.
dea975
dea975
A Rails app will be using the Sprockets file server in production if they have accidentally configured their app to:
dea975
dea975
```ruby
dea975
config.assets.compile = true # Your app is vulnerable
dea975
```
dea975
dea975
It is highly recommended to not use the Sprockets server in production and to instead precompile assets to disk and serve them through a server such as Nginx or via the static file middleware that ships with rails `config.public_file_server.enabled = true`.
dea975
dea975
This patch mitigates the issue, but explicitly disallowing any requests to any URI resources via the server.
dea975
---
dea975
 test/test_server.rb     | 7 +++++++
dea975
 1 files changed, 7 insertions(+), 0 deletions(-)
dea975
dea975
diff --git a/test/test_server.rb b/test/test_server.rb
dea975
index 66429533..19921e19 100644
dea975
--- a/test/test_server.rb
dea975
+++ b/test/test_server.rb
dea975
@@ -331,6 +331,13 @@ def app
dea975
     assert_equal "", last_response.body
dea975
   end
dea975
 
dea975
+  test "illegal access of a file asset" do
dea975
+    absolute_path = fixture_path("server/app/javascripts")
dea975
+
dea975
+    get "assets/file:%2f%2f//#{absolute_path}/foo.js"
dea975
+    assert_equal 403, last_response.status
dea975
+  end
dea975
+
dea975
   test "add new source to tree" do
dea975
     filename = fixture_path("server/app/javascripts/baz.js")
dea975