Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVE-2023-36617 for Ruby 3.2 #7995

Merged
merged 2 commits into from Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
Expand Up @@ -497,8 +497,8 @@ def initialize_regexp(pattern)
ret = {}

# for Bundler::URI::split
ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)

# for Bundler::URI::extract
ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
Expand Up @@ -100,7 +100,7 @@ def default_regexp # :nodoc:
QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
OPAQUE: /\A(?:[^\/].*)?\z/,
PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/uri/lib/uri/version.rb
@@ -1,6 +1,6 @@
module Bundler::URI
# :stopdoc:
VERSION_CODE = '001201'.freeze
VERSION_CODE = '001202'.freeze
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
# :startdoc:
end
4 changes: 2 additions & 2 deletions lib/uri/rfc2396_parser.rb
Expand Up @@ -497,8 +497,8 @@ def initialize_regexp(pattern)
ret = {}

# for URI::split
ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)

# for URI::extract
ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
Expand Down
2 changes: 1 addition & 1 deletion lib/uri/rfc3986_parser.rb
Expand Up @@ -100,7 +100,7 @@ def default_regexp # :nodoc:
QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
OPAQUE: /\A(?:[^\/].*)?\z/,
PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/uri/version.rb
@@ -1,6 +1,6 @@
module URI
# :stopdoc:
VERSION_CODE = '001201'.freeze
VERSION_CODE = '001202'.freeze
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
# :startdoc:
end
22 changes: 22 additions & 0 deletions test/uri/test_parser.rb
Expand Up @@ -79,4 +79,26 @@ def test_split
assert_equal([nil, nil, "example.com", nil, nil, "", nil, nil, nil], URI.split("//example.com"))
assert_equal([nil, nil, "[0::0]", nil, nil, "", nil, nil, nil], URI.split("//[0::0]"))
end

def test_rfc2822_parse_relative_uri
pre = ->(length) {
" " * length + "\0"
}
parser = URI::RFC2396_Parser.new
assert_linear_performance((1..5).map {|i| 10**i}, pre: pre) do |uri|
assert_raise(URI::InvalidURIError) do
parser.split(uri)
end
end
end

def test_rfc3986_port_check
pre = ->(length) {"\t" * length + "a"}
uri = URI.parse("http://my.example.com")
assert_linear_performance((1..5).map {|i| 10**i}, pre: pre) do |port|
assert_raise(URI::InvalidComponentError) do
uri.port = port
end
end
end
end