Skip to content

Commit 9ce1bf8

Browse files
committed
merge revision(s) 50829: [Backport ruby#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
1 parent 911ade3 commit 9ce1bf8

File tree

5 files changed

+66
-6
lines changed

5 files changed

+66
-6
lines changed

ChangeLog

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Tue Aug 18 21:40:43 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
2+
3+
* lib/rubygems.rb: bump version to 2.4.5.1. this version fixed
4+
CVE-2015-3900.
5+
6+
* lib/rubygems/remote_fetcher.rb: ditto.
7+
8+
* test/rubygems/test_gem_remote_fetcher.rb: added testcase for CVE-2015-3900
9+
110
Mon Aug 17 23:27:45 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
211

312
* ext/win32/lib/win32/registry.rb (API#SetValue): data size should

lib/rubygems.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require 'rbconfig'
99

1010
module Gem
11-
VERSION = '2.2.3'
11+
VERSION = '2.2.5'
1212
end
1313

1414
# Must be first since it unloads the prelude from 1.9.2

lib/rubygems/remote_fetcher.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ def api_endpoint(uri)
9090
rescue Resolv::ResolvError
9191
uri
9292
else
93-
URI.parse "#{uri.scheme}://#{res.target}#{uri.path}"
93+
target = res.target.to_s.strip
94+
95+
if /\.#{Regexp.quote(host)}\z/ =~ target
96+
return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
97+
end
98+
99+
uri
94100
end
95101
end
96102

test/rubygems/test_gem_remote_fetcher.rb

+46-1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,21 @@ def test_no_proxy
163163
end
164164

165165
def test_api_endpoint
166+
uri = URI.parse "http://example.com/foo"
167+
target = MiniTest::Mock.new
168+
target.expect :target, "gems.example.com"
169+
170+
dns = MiniTest::Mock.new
171+
dns.expect :getresource, target, [String, Object]
172+
173+
fetch = Gem::RemoteFetcher.new nil, dns
174+
assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
175+
176+
target.verify
177+
dns.verify
178+
end
179+
180+
def test_api_endpoint_ignores_trans_domain_values
166181
uri = URI.parse "http://gems.example.com/foo"
167182
target = MiniTest::Mock.new
168183
target.expect :target, "blah.com"
@@ -171,7 +186,37 @@ def test_api_endpoint
171186
dns.expect :getresource, target, [String, Object]
172187

173188
fetch = Gem::RemoteFetcher.new nil, dns
174-
assert_equal URI.parse("http://blah.com/foo"), fetch.api_endpoint(uri)
189+
assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
190+
191+
target.verify
192+
dns.verify
193+
end
194+
195+
def test_api_endpoint_ignores_trans_domain_values_that_starts_with_original
196+
uri = URI.parse "http://example.com/foo"
197+
target = MiniTest::Mock.new
198+
target.expect :target, "example.combadguy.com"
199+
200+
dns = MiniTest::Mock.new
201+
dns.expect :getresource, target, [String, Object]
202+
203+
fetch = Gem::RemoteFetcher.new nil, dns
204+
assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
205+
206+
target.verify
207+
dns.verify
208+
end
209+
210+
def test_api_endpoint_ignores_trans_domain_values_that_end_with_original
211+
uri = URI.parse "http://example.com/foo"
212+
target = MiniTest::Mock.new
213+
target.expect :target, "badexample.com"
214+
215+
dns = MiniTest::Mock.new
216+
dns.expect :getresource, target, [String, Object]
217+
218+
fetch = Gem::RemoteFetcher.new nil, dns
219+
assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
175220

176221
target.verify
177222
dns.verify

version.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.1.7"
2-
#define RUBY_RELEASE_DATE "2015-08-17"
3-
#define RUBY_PATCHLEVEL 399
2+
#define RUBY_RELEASE_DATE "2015-08-18"
3+
#define RUBY_PATCHLEVEL 400
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 8
7-
#define RUBY_RELEASE_DAY 17
7+
#define RUBY_RELEASE_DAY 18
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)