[前][次][番号順一覧][スレッド一覧]

ruby-changes:39546

From: usa <ko1@a...>
Date: Tue, 18 Aug 2015 21:57:16 +0900 (JST)
Subject: [ruby-changes:39546] usa:r51627 (ruby_2_1): merge revision(s) 50829: [Backport #11248]

usa	2015-08-18 21:56:58 +0900 (Tue, 18 Aug 2015)

  New Revision: 51627

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51627

  Log:
    merge revision(s) 50829: [Backport #11248]
    
    * lib/rubygems.rb: bump version to 2.4.5.1. this version fixed
      CVE-2015-3900.
    
    * lib/rubygems/remote_fetcher.rb: ditto.
    
    * test/rubygems/test_gem_remote_fetcher.rb: added testcase for CVE-2015-3900

  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/lib/rubygems/remote_fetcher.rb
    branches/ruby_2_1/lib/rubygems.rb
    branches/ruby_2_1/test/rubygems/test_gem_remote_fetcher.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 51626)
+++ ruby_2_1/ChangeLog	(revision 51627)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Tue Aug 18 21:40:43 2015  SHIBATA Hiroshi  <hsbt@r...>
+
+	* lib/rubygems.rb: bump version to 2.4.5.1. this version fixed
+	  CVE-2015-3900.
+
+	* lib/rubygems/remote_fetcher.rb: ditto.
+
+	* test/rubygems/test_gem_remote_fetcher.rb: added testcase for CVE-2015-3900
+
 Mon Aug 17 23:27:45 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/win32/lib/win32/registry.rb (API#SetValue): data size should
Index: ruby_2_1/lib/rubygems/remote_fetcher.rb
===================================================================
--- ruby_2_1/lib/rubygems/remote_fetcher.rb	(revision 51626)
+++ ruby_2_1/lib/rubygems/remote_fetcher.rb	(revision 51627)
@@ -90,7 +90,13 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_1/lib/rubygems/remote_fetcher.rb#L90
     rescue Resolv::ResolvError
       uri
     else
-      URI.parse "#{uri.scheme}://#{res.target}#{uri.path}"
+      target = res.target.to_s.strip
+
+      if /\.#{Regexp.quote(host)}\z/ =~ target
+        return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
+      end
+
+      uri
     end
   end
 
Index: ruby_2_1/lib/rubygems.rb
===================================================================
--- ruby_2_1/lib/rubygems.rb	(revision 51626)
+++ ruby_2_1/lib/rubygems.rb	(revision 51627)
@@ -8,7 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/lib/rubygems.rb#L8
 require 'rbconfig'
 
 module Gem
-  VERSION = '2.2.3'
+  VERSION = '2.2.5'
 end
 
 # Must be first since it unloads the prelude from 1.9.2
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 51626)
+++ ruby_2_1/version.h	(revision 51627)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.7"
-#define RUBY_RELEASE_DATE "2015-08-17"
-#define RUBY_PATCHLEVEL 399
+#define RUBY_RELEASE_DATE "2015-08-18"
+#define RUBY_PATCHLEVEL 400
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 8
-#define RUBY_RELEASE_DAY 17
+#define RUBY_RELEASE_DAY 18
 
 #include "ruby/version.h"
 
Index: ruby_2_1/test/rubygems/test_gem_remote_fetcher.rb
===================================================================
--- ruby_2_1/test/rubygems/test_gem_remote_fetcher.rb	(revision 51626)
+++ ruby_2_1/test/rubygems/test_gem_remote_fetcher.rb	(revision 51627)
@@ -163,6 +163,21 @@ gems: https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/rubygems/test_gem_remote_fetcher.rb#L163
   end
 
   def test_api_endpoint
+    uri = URI.parse "http://example.com/foo"
+    target = MiniTest::Mock.new
+    target.expect :target, "gems.example.com"
+
+    dns = MiniTest::Mock.new
+    dns.expect :getresource, target, [String, Object]
+
+    fetch = Gem::RemoteFetcher.new nil, dns
+    assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
+
+    target.verify
+    dns.verify
+  end
+
+  def test_api_endpoint_ignores_trans_domain_values
     uri = URI.parse "http://gems.example.com/foo"
     target = MiniTest::Mock.new
     target.expect :target, "blah.com"
@@ -171,7 +186,37 @@ gems: https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/rubygems/test_gem_remote_fetcher.rb#L186
     dns.expect :getresource, target, [String, Object]
 
     fetch = Gem::RemoteFetcher.new nil, dns
-    assert_equal URI.parse("http://blah.com/foo"), fetch.api_endpoint(uri)
+    assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
+
+    target.verify
+    dns.verify
+  end
+
+  def test_api_endpoint_ignores_trans_domain_values_that_starts_with_original
+    uri = URI.parse "http://example.com/foo"
+    target = MiniTest::Mock.new
+    target.expect :target, "example.combadguy.com"
+
+    dns = MiniTest::Mock.new
+    dns.expect :getresource, target, [String, Object]
+
+    fetch = Gem::RemoteFetcher.new nil, dns
+    assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
+
+    target.verify
+    dns.verify
+  end
+
+  def test_api_endpoint_ignores_trans_domain_values_that_end_with_original
+    uri = URI.parse "http://example.com/foo"
+    target = MiniTest::Mock.new
+    target.expect :target, "badexample.com"
+
+    dns = MiniTest::Mock.new
+    dns.expect :getresource, target, [String, Object]
+
+    fetch = Gem::RemoteFetcher.new nil, dns
+    assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
 
     target.verify
     dns.verify

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]