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

ruby-changes:39547

From: usa <ko1@a...>
Date: Tue, 18 Aug 2015 22:01:12 +0900 (JST)
Subject: [ruby-changes:39547] usa:r51628 (ruby_2_0_0): merge revision(s) 50829: [Backport #11248]

usa	2015-08-18 22:01:02 +0900 (Tue, 18 Aug 2015)

  New Revision: 51628

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

  Log:
    merge revision(s) 50829: [Backport #11248]
    
    * lib/rubygems.rb: bump version to 2.0.14.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_0_0/ChangeLog
    branches/ruby_2_0_0/lib/rubygems/remote_fetcher.rb
    branches/ruby_2_0_0/lib/rubygems.rb
    branches/ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 51627)
+++ ruby_2_0_0/ChangeLog	(revision 51628)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Tue Aug 18 22:00:12 2015  SHIBATA Hiroshi  <hsbt@r...>
+
+	* lib/rubygems.rb: bump version to 2.0.14.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
+
 Tue Jun  2 00:10:14 2015  NAKAMURA Usaku  <usa@r...>
 
 	* lib/resolv.rb (Requester#request): typo, regression introduced at
Index: ruby_2_0_0/lib/rubygems/remote_fetcher.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/remote_fetcher.rb	(revision 51627)
+++ ruby_2_0_0/lib/rubygems/remote_fetcher.rb	(revision 51628)
@@ -103,7 +103,13 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/remote_fetcher.rb#L103
     rescue Resolv::ResolvError
       uri
     else
-      URI.parse "#{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_0_0/lib/rubygems.rb
===================================================================
--- ruby_2_0_0/lib/rubygems.rb	(revision 51627)
+++ ruby_2_0_0/lib/rubygems.rb	(revision 51628)
@@ -8,7 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems.rb#L8
 require 'rbconfig'
 
 module Gem
-  VERSION = '2.0.14'
+  VERSION = '2.0.14.1'
 end
 
 # Must be first since it unloads the prelude from 1.9.2
Index: ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb
===================================================================
--- ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb	(revision 51627)
+++ ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb	(revision 51628)
@@ -177,15 +177,60 @@ gems: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb#L177
   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, "http://blah.com"
+    target.expect :target, "blah.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_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://blah.com/foo"), fetch.api_endpoint(uri)
+    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/

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