Blame SOURCES/rubygem-sprockets-3.7.2-CVE-2018-3760-Fix-Path-traversal-in-sprockets-server.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
 lib/sprockets/server.rb | 2 +-
dea975
 1 files changed, 1 insertion(+), 1 deletion(-)
dea975
dea975
diff --git a/lib/sprockets/server.rb b/lib/sprockets/server.rb
dea975
index 795bdec7..2ad2c9ab 100644
dea975
--- a/lib/sprockets/server.rb
dea975
+++ b/lib/sprockets/server.rb
dea975
@@ -115,7 +115,7 @@ def forbidden_request?(path)
dea975
         #
dea975
         #     http://example.org/assets/../../../etc/passwd
dea975
         #
dea975
-        path.include?("..") || absolute_path?(path)
dea975
+        path.include?("..") || absolute_path?(path) || path.include?("://")
dea975
       end
dea975
 
dea975
       def head_request?(env)