summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-devtools/ruby/ruby/CVE-2023-36617_1.patch56
-rw-r--r--meta/recipes-devtools/ruby/ruby/CVE-2023-36617_2.patch52
-rw-r--r--meta/recipes-devtools/ruby/ruby_3.2.2.bb2
3 files changed, 110 insertions, 0 deletions
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2023-36617_1.patch b/meta/recipes-devtools/ruby/ruby/CVE-2023-36617_1.patch
new file mode 100644
index 0000000000..17c7e30176
--- /dev/null
+++ b/meta/recipes-devtools/ruby/ruby/CVE-2023-36617_1.patch
@@ -0,0 +1,56 @@
1From 2ebb50d2dc302917a6f57c1239dc9e700dfe0e34 Mon Sep 17 00:00:00 2001
2From: Nobuyoshi Nakada <nobu@ruby-lang.org>
3Date: Thu, 27 Jul 2023 15:53:01 +0800
4Subject: [PATCH] Fix quadratic backtracking on invalid relative URI
5
6https://hackerone.com/reports/1958260
7
8CVE: CVE-2023-36617
9
10Upstream-Status: Backport [https://github.com/ruby/uri/commit/9010ee2536adda10a0555ae1ed6fe2f5808e6bf1]
11
12Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
13---
14 lib/uri/rfc2396_parser.rb | 4 ++--
15 test/uri/test_parser.rb | 12 ++++++++++++
16 2 files changed, 14 insertions(+), 2 deletions(-)
17
18diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb
19index 76a8f99..00c66cf 100644
20--- a/lib/uri/rfc2396_parser.rb
21+++ b/lib/uri/rfc2396_parser.rb
22@@ -497,8 +497,8 @@ module URI
23 ret = {}
24
25 # for URI::split
26- ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
27- ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
28+ ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
29+ ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
30
31 # for URI::extract
32 ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
33diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb
34index 72fb590..721e05e 100644
35--- a/test/uri/test_parser.rb
36+++ b/test/uri/test_parser.rb
37@@ -79,4 +79,16 @@ class URI::TestParser < Test::Unit::TestCase
38 assert_equal([nil, nil, "example.com", nil, nil, "", nil, nil, nil], URI.split("//example.com"))
39 assert_equal([nil, nil, "[0::0]", nil, nil, "", nil, nil, nil], URI.split("//[0::0]"))
40 end
41+
42+ def test_rfc2822_parse_relative_uri
43+ pre = ->(length) {
44+ " " * length + "\0"
45+ }
46+ parser = URI::RFC2396_Parser.new
47+ assert_linear_performance((1..5).map {|i| 10**i}, pre: pre) do |uri|
48+ assert_raise(URI::InvalidURIError) do
49+ parser.split(uri)
50+ end
51+ end
52+ end
53 end
54--
552.25.1
56
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2023-36617_2.patch b/meta/recipes-devtools/ruby/ruby/CVE-2023-36617_2.patch
new file mode 100644
index 0000000000..7c51deaa42
--- /dev/null
+++ b/meta/recipes-devtools/ruby/ruby/CVE-2023-36617_2.patch
@@ -0,0 +1,52 @@
1From eea5868120509c245216c4b5c2d4b5db1c593d0e Mon Sep 17 00:00:00 2001
2From: Nobuyoshi Nakada <nobu@ruby-lang.org>
3Date: Thu, 27 Jul 2023 16:16:30 +0800
4Subject: [PATCH] Fix quadratic backtracking on invalid port number
5
6https://hackerone.com/reports/1958260
7
8CVE: CVE-2023-36617
9
10Upstream-Status: Backport [https://github.com/ruby/uri/commit/9d7bcef1e6ad23c9c6e4932f297fb737888144c8]
11
12Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
13---
14 lib/uri/rfc3986_parser.rb | 2 +-
15 test/uri/test_parser.rb | 10 ++++++++++
16 2 files changed, 11 insertions(+), 1 deletion(-)
17
18diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb
19index dd24a40..9b1663d 100644
20--- a/lib/uri/rfc3986_parser.rb
21+++ b/lib/uri/rfc3986_parser.rb
22@@ -100,7 +100,7 @@ module URI
23 QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
24 FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
25 OPAQUE: /\A(?:[^\/].*)?\z/,
26- PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
27+ PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
28 }
29 end
30
31diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb
32index 721e05e..cee0acb 100644
33--- a/test/uri/test_parser.rb
34+++ b/test/uri/test_parser.rb
35@@ -91,4 +91,14 @@ class URI::TestParser < Test::Unit::TestCase
36 end
37 end
38 end
39+
40+ def test_rfc3986_port_check
41+ pre = ->(length) {"\t" * length + "a"}
42+ uri = URI.parse("http://my.example.com")
43+ assert_linear_performance((1..5).map {|i| 10**i}, pre: pre) do |port|
44+ assert_raise(URI::InvalidComponentError) do
45+ uri.port = port
46+ end
47+ end
48+ end
49 end
50--
512.25.1
52
diff --git a/meta/recipes-devtools/ruby/ruby_3.2.2.bb b/meta/recipes-devtools/ruby/ruby_3.2.2.bb
index 481fe7c23d..d1359e388c 100644
--- a/meta/recipes-devtools/ruby/ruby_3.2.2.bb
+++ b/meta/recipes-devtools/ruby/ruby_3.2.2.bb
@@ -31,6 +31,8 @@ SRC_URI = "http://cache.ruby-lang.org/pub/ruby/${SHRT_VER}/ruby-${PV}.tar.gz \
31 file://0006-Make-gemspecs-reproducible.patch \ 31 file://0006-Make-gemspecs-reproducible.patch \
32 file://0001-vm_dump.c-Define-REG_S1-and-REG_S2-for-musl-riscv.patch \ 32 file://0001-vm_dump.c-Define-REG_S1-and-REG_S2-for-musl-riscv.patch \
33 file://0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch \ 33 file://0001-fiddle-Use-C11-_Alignof-to-define-ALIGN_OF-when-poss.patch \
34 file://CVE-2023-36617_1.patch \
35 file://CVE-2023-36617_2.patch \
34 " 36 "
35UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" 37UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/"
36 38