summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-18 12:56:58 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-18 12:56:58 +0000
commit9ce1bf8f3da8a37cea7112b3cb5859da80343b0b (patch)
tree1fb9007e5bb58df9b675dcad67a5169006f95f88
parent911ade36df679fbc816456d5d58b5fc8fb1e0db4 (diff)
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/remote_fetcher.rb8
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb47
-rw-r--r--version.h6
5 files changed, 66 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 06b5029527..a1a45d5458 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Aug 18 21:40:43 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* ext/win32/lib/win32/registry.rb (API#SetValue): data size should
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index ea1893046f..73d063e7a0 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
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
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 58991caeda..ed2e171d2c 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -90,7 +90,13 @@ class Gem::RemoteFetcher
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
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index 2fabd509ce..d391b90739 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -163,6 +163,21 @@ gems:
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:
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
diff --git a/version.h b/version.h
index 4f8c2a8516..3ab5c1274f 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#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"