summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDivya Chellam <divya.chellam@windriver.com>2025-04-15 11:11:27 +0000
committerSteve Sakoman <steve@sakoman.com>2025-04-18 08:30:51 -0700
commit6eba29d9462a5833fbd49064ea32502c8da6405c (patch)
tree919a7b5f51499d04bd48d9e49ac794afb450de38
parent0a3231570d7ac206d022c455fb8e8e1f8db6f1d5 (diff)
downloadpoky-6eba29d9462a5833fbd49064ea32502c8da6405c.tar.gz
ruby: fix CVE-2024-43398
REXML is an XML toolkit for Ruby. The REXML gem before 3.3.6 has a DoS vulnerability when it parses an XML that has many deep elements that have same local name attributes. If you need to parse untrusted XMLs with tree parser API like REXML::Document.new, you may be impacted to this vulnerability. If you use other parser APIs such as stream parser API and SAX2 parser API, this vulnerability is not affected. The REXML gem 3.3.6 or later include the patch to fix the vulnerability. Reference: https://security-tracker.debian.org/tracker/CVE-2024-43398 Upstream-patch: https://github.com/ruby/rexml/commit/7cb5eaeb221c322b9912f724183294d8ce96bae3 (From OE-Core rev: f23d1bfca0ea57150c397bc2e495191fb61423d0) Signed-off-by: Divya Chellam <divya.chellam@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-devtools/ruby/ruby/CVE-2024-43398.patch81
-rw-r--r--meta/recipes-devtools/ruby/ruby_3.1.3.bb1
2 files changed, 82 insertions, 0 deletions
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2024-43398.patch b/meta/recipes-devtools/ruby/ruby/CVE-2024-43398.patch
new file mode 100644
index 0000000000..02dc0a20be
--- /dev/null
+++ b/meta/recipes-devtools/ruby/ruby/CVE-2024-43398.patch
@@ -0,0 +1,81 @@
1From 7cb5eaeb221c322b9912f724183294d8ce96bae3 Mon Sep 17 00:00:00 2001
2From: Sutou Kouhei <kou@clear-code.com>
3Date: Sat, 17 Aug 2024 17:45:52 +0900
4Subject: [PATCH] parser tree: improve namespace conflicted attribute check
5 performance
6
7It was slow for deep element.
8
9Reported by l33thaxor. Thanks!!!
10
11The changes to the test folder files are not included in this patch
12because the test folder was not generated during the devtool source build.
13
14CVE: CVE-2024-43398
15
16Upstream-Status: Backport [https://github.com/ruby/rexml/commit/7cb5eaeb221c322b9912f724183294d8ce96bae3]
17
18Signed-off-by: Divya Chellam <divya.chellam@windriver.com>
19---
20 .bundle/gems/rexml-3.2.5/lib/rexml/element.rb | 11 -----------
21 .../rexml-3.2.5/lib/rexml/parsers/baseparser.rb | 15 +++++++++++++++
22 2 files changed, 15 insertions(+), 11 deletions(-)
23
24diff --git a/.bundle/gems/rexml-3.2.5/lib/rexml/element.rb b/.bundle/gems/rexml-3.2.5/lib/rexml/element.rb
25index 4c21dbd..78e78c2 100644
26--- a/.bundle/gems/rexml-3.2.5/lib/rexml/element.rb
27+++ b/.bundle/gems/rexml-3.2.5/lib/rexml/element.rb
28@@ -2388,17 +2388,6 @@ module REXML
29 elsif old_attr.kind_of? Hash
30 old_attr[value.prefix] = value
31 elsif old_attr.prefix != value.prefix
32- # Check for conflicting namespaces
33- if value.prefix != "xmlns" and old_attr.prefix != "xmlns"
34- old_namespace = old_attr.namespace
35- new_namespace = value.namespace
36- if old_namespace == new_namespace
37- raise ParseException.new(
38- "Namespace conflict in adding attribute \"#{value.name}\": "+
39- "Prefix \"#{old_attr.prefix}\" = \"#{old_namespace}\" and "+
40- "prefix \"#{value.prefix}\" = \"#{new_namespace}\"")
41- end
42- end
43 store value.name, {old_attr.prefix => old_attr,
44 value.prefix => value}
45 else
46diff --git a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb
47index e32c7f4..154f2ac 100644
48--- a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb
49+++ b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb
50@@ -634,6 +634,7 @@ module REXML
51
52 def parse_attributes(prefixes, curr_ns)
53 attributes = {}
54+ expanded_names = {}
55 closed = false
56 match_data = @source.match(/^(.*?)(\/)?>/um, true)
57 if match_data.nil?
58@@ -641,6 +642,20 @@ module REXML
59 raise REXML::ParseException.new(message, @source)
60 end
61
62+ unless prefix == "xmlns"
63+ uri = @namespaces[prefix]
64+ expanded_name = [uri, local_part]
65+ existing_prefix = expanded_names[expanded_name]
66+ if existing_prefix
67+ message = "Namespace conflict in adding attribute " +
68+ "\"#{local_part}\": " +
69+ "Prefix \"#{existing_prefix}\" = \"#{uri}\" and " +
70+ "prefix \"#{prefix}\" = \"#{uri}\""
71+ raise REXML::ParseException.new(message, @source, self)
72+ end
73+ expanded_names[expanded_name] = prefix
74+ end
75+
76 raw_attributes = match_data[1]
77 closed = !match_data[2].nil?
78 return attributes, closed if raw_attributes.nil?
79--
802.40.0
81
diff --git a/meta/recipes-devtools/ruby/ruby_3.1.3.bb b/meta/recipes-devtools/ruby/ruby_3.1.3.bb
index 76e5ac81ed..ca061e7f70 100644
--- a/meta/recipes-devtools/ruby/ruby_3.1.3.bb
+++ b/meta/recipes-devtools/ruby/ruby_3.1.3.bb
@@ -48,6 +48,7 @@ SRC_URI = "http://cache.ruby-lang.org/pub/ruby/${SHRT_VER}/ruby-${PV}.tar.gz \
48 file://CVE-2024-41946.patch \ 48 file://CVE-2024-41946.patch \
49 file://CVE-2025-27220.patch \ 49 file://CVE-2025-27220.patch \
50 file://CVE-2025-27219.patch \ 50 file://CVE-2025-27219.patch \
51 file://CVE-2024-43398.patch \
51 " 52 "
52UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" 53UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/"
53 54