diff --git a/ruby-2.7.8-Fix-CVE-2023-28755-ReDos-vulnerability-in-URI.patch b/ruby-2.7.8-Fix-CVE-2023-28755-ReDos-vulnerability-in-URI.patch new file mode 100644 index 0000000..6837ab3 --- /dev/null +++ b/ruby-2.7.8-Fix-CVE-2023-28755-ReDos-vulnerability-in-URI.patch @@ -0,0 +1,52 @@ +From 61fb466ea0b492c990fcd2d681c08f2001d7a659 Mon Sep 17 00:00:00 2001 +From: Hiroshi SHIBATA +Date: Tue, 28 Mar 2023 17:33:19 +0900 +Subject: [PATCH] Fix CVE-2023-28755 ReDos vulnerability in URI. + +This patch was backported from Ruby 2.7.8 + +Backported from upstream Ruby, commit: +https://github.com/ruby/ruby/commit/6855779d580358a6a0b4c9ee06f20e7cae72955a + +===== Original commit message + +Merge URI-0.10.0.2 +--- + lib/uri/rfc3986_parser.rb | 4 ++-- + test/uri/test_parser.rb | 7 +++++++ + 2 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb +index 8712800..ad32368 100644 +--- a/lib/uri/rfc3986_parser.rb ++++ b/lib/uri/rfc3986_parser.rb +@@ -3,8 +3,8 @@ module URI + class RFC3986_Parser # :nodoc: + # URI defined in RFC3986 + # this regexp is modified not to host is not empty string +- RFC3986_URI = /\A(?(?[A-Za-z][+\-.0-9A-Za-z]*):(?\/\/(?(?:(?(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?(?\[(?:(?(?:\h{1,4}:){6}(?\h{1,4}:\h{1,4}|(?(?[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g\.\g\.\g))|::(?:\h{1,4}:){5}\g|\h{1,4}?::(?:\h{1,4}:){4}\g|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g|(?:(?:\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:\h{1,4}:){2}\g|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?v\h++\.[!$&-.0-;=A-Z_a-z~]++))\])|\g|(?(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])++))?(?::(?\d*+))?)(?(?:\/(?(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*+))*+)|(?\/(?:(?(?:%\h\h|[!$&-.0-;=@-Z_a-z~])++)(?:\/\g)*+)?)|(?(?(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])++)(?:\/\g)*+)|(?))(?:\?(?[^#]*+))?(?:\#(?(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*+))?)\z/ + attr_reader :regexp + + def initialize +diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb +index 757ac86..2f70559 100644 +--- a/test/uri/test_parser.rb ++++ b/test/uri/test_parser.rb +@@ -45,4 +45,11 @@ class URI::TestParser < Test::Unit::TestCase + URI.parse(1) + end + end ++ ++ def test_split ++ assert_equal(["http", nil, "example.com", nil, nil, "", nil, nil, nil], URI.split("http://example.com")) ++ assert_equal(["http", nil, "[0::0]", nil, nil, "", nil, nil, nil], URI.split("http://[0::0]")) ++ 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 + end +-- +2.41.0 + diff --git a/ruby.spec b/ruby.spec index 54d8e96..575bb3b 100644 --- a/ruby.spec +++ b/ruby.spec @@ -220,6 +220,10 @@ Patch39: rubygem-cgi-0.3.6-Loosen-the-domain-regex-to-accept-dot.patch # Backported from: # https://github.com/ruby/ruby/commit/69f9992ed41920389d4185141a14f02f89a4d306 Patch40: ruby-2.6.10-Fix-CVE-2022-28739-Buffer-overrun-in-str2float.patch +# CVE-2023-28755 ReDoS vulnerability in URI. +# Backported from: +# https://github.com/ruby/ruby/commit/6855779d580358a6a0b4c9ee06f20e7cae72955a +Patch41: ruby-2.7.8-Fix-CVE-2023-28755-ReDos-vulnerability-in-URI.patch Requires: %{name}-libs%{?_isa} = %{version}-%{release} @@ -631,6 +635,7 @@ sed -i 's/"evaluation\/incorrect_words.yaml"\.freeze, //' \ %patch38 -p1 %patch39 -p1 %patch40 -p1 +%patch41 -p1 # Provide an example of usage of the tapset: cp -a %{SOURCE3} . @@ -1188,6 +1193,8 @@ OPENSSL_SYSTEM_CIPHERS_OVERRIDE=xyz_nonexistent_file OPENSSL_CONF='' \ Resolves: CVE-2021-33621 - Fix Buffer overrun in String-to-Float conversion. Resolves: CVE-2022-28739 +- Fix ReDoS vulnerability in URI. + Resolves: CVE-2023-28755 * Thu May 25 2023 Todd Zullinger - 2.5.9-111 - Fix rdoc parsing of nil text tokens.