diff options
-rw-r--r-- | meta/recipes-devtools/ruby/ruby/CVE-2024-41946.patch | 117 | ||||
-rw-r--r-- | meta/recipes-devtools/ruby/ruby_3.1.3.bb | 1 |
2 files changed, 118 insertions, 0 deletions
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2024-41946.patch b/meta/recipes-devtools/ruby/ruby/CVE-2024-41946.patch new file mode 100644 index 0000000000..0da383f9b9 --- /dev/null +++ b/meta/recipes-devtools/ruby/ruby/CVE-2024-41946.patch | |||
@@ -0,0 +1,117 @@ | |||
1 | From 033d1909a8f259d5a7c53681bcaf14f13bcf0368 Mon Sep 17 00:00:00 2001 | ||
2 | From: NAITOH Jun <naitoh@gmail.com> | ||
3 | Date: Thu, 1 Aug 2024 09:20:31 +0900 | ||
4 | Subject: [PATCH] Add support for XML entity expansion limitation in SAX and | ||
5 | pull parsers (#187) | ||
6 | |||
7 | - Supported `REXML::Security.entity_expansion_limit=` in SAX and pull parsers | ||
8 | - Supported `REXML::Security.entity_expansion_text_limit=` in SAX and pull parsers | ||
9 | |||
10 | CVE: CVE-2024-41946 | ||
11 | |||
12 | Upstream-Status: Backport [https://github.com/ruby/rexml/commit/033d1909a8f259d5a7c53681bcaf14f13bcf0368] | ||
13 | |||
14 | Signed-off-by: Divya Chellam <divya.chellam@windriver.com> | ||
15 | --- | ||
16 | .../lib/rexml/parsers/baseparser.rb | 19 ++++++++++++++++++- | ||
17 | .../lib/rexml/parsers/pullparser.rb | 4 ++++ | ||
18 | .../lib/rexml/parsers/sax2parser.rb | 4 ++++ | ||
19 | 3 files changed, 26 insertions(+), 1 deletion(-) | ||
20 | |||
21 | diff --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 | ||
22 | index 661f0e2..e32c7f4 100644 | ||
23 | --- a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb | ||
24 | +++ b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb | ||
25 | @@ -135,6 +135,7 @@ module REXML | ||
26 | def initialize( source ) | ||
27 | self.stream = source | ||
28 | @listeners = [] | ||
29 | + @entity_expansion_count = 0 | ||
30 | @attributes_scanner = StringScanner.new('') | ||
31 | end | ||
32 | |||
33 | @@ -143,6 +144,7 @@ module REXML | ||
34 | end | ||
35 | |||
36 | attr_reader :source | ||
37 | + attr_reader :entity_expansion_count | ||
38 | |||
39 | def stream=( source ) | ||
40 | @source = SourceFactory.create_from( source ) | ||
41 | @@ -447,7 +449,9 @@ module REXML | ||
42 | def entity( reference, entities ) | ||
43 | value = nil | ||
44 | value = entities[ reference ] if entities | ||
45 | - if not value | ||
46 | + if value | ||
47 | + record_entity_expansion | ||
48 | + else | ||
49 | value = DEFAULT_ENTITIES[ reference ] | ||
50 | value = value[2] if value | ||
51 | end | ||
52 | @@ -486,12 +490,17 @@ module REXML | ||
53 | } | ||
54 | matches.collect!{|x|x[0]}.compact! | ||
55 | if matches.size > 0 | ||
56 | + sum = 0 | ||
57 | matches.each do |entity_reference| | ||
58 | unless filter and filter.include?(entity_reference) | ||
59 | entity_value = entity( entity_reference, entities ) | ||
60 | if entity_value | ||
61 | re = Private::DEFAULT_ENTITIES_PATTERNS[entity_reference] || /&#{entity_reference};/ | ||
62 | rv.gsub!( re, entity_value ) | ||
63 | + sum += rv.bytesize | ||
64 | + if sum > Security.entity_expansion_text_limit | ||
65 | + raise "entity expansion has grown too large" | ||
66 | + end | ||
67 | else | ||
68 | er = DEFAULT_ENTITIES[entity_reference] | ||
69 | rv.gsub!( er[0], er[2] ) if er | ||
70 | @@ -504,6 +513,14 @@ module REXML | ||
71 | end | ||
72 | |||
73 | private | ||
74 | + | ||
75 | + def record_entity_expansion | ||
76 | + @entity_expansion_count += 1 | ||
77 | + if @entity_expansion_count > Security.entity_expansion_limit | ||
78 | + raise "number of entity expansions exceeded, processing aborted." | ||
79 | + end | ||
80 | + end | ||
81 | + | ||
82 | def need_source_encoding_update?(xml_declaration_encoding) | ||
83 | return false if xml_declaration_encoding.nil? | ||
84 | return false if /\AUTF-16\z/i =~ xml_declaration_encoding | ||
85 | diff --git a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/pullparser.rb b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/pullparser.rb | ||
86 | index f8b232a..36b4595 100644 | ||
87 | --- a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/pullparser.rb | ||
88 | +++ b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/pullparser.rb | ||
89 | @@ -47,6 +47,10 @@ module REXML | ||
90 | @listeners << listener | ||
91 | end | ||
92 | |||
93 | + def entity_expansion_count | ||
94 | + @parser.entity_expansion_count | ||
95 | + end | ||
96 | + | ||
97 | def each | ||
98 | while has_next? | ||
99 | yield self.pull | ||
100 | diff --git a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/sax2parser.rb b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/sax2parser.rb | ||
101 | index 6a24ce2..01cb469 100644 | ||
102 | --- a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/sax2parser.rb | ||
103 | +++ b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/sax2parser.rb | ||
104 | @@ -22,6 +22,10 @@ module REXML | ||
105 | @parser.source | ||
106 | end | ||
107 | |||
108 | + def entity_expansion_count | ||
109 | + @parser.entity_expansion_count | ||
110 | + end | ||
111 | + | ||
112 | def add_listener( listener ) | ||
113 | @parser.add_listener( listener ) | ||
114 | end | ||
115 | -- | ||
116 | 2.40.0 | ||
117 | |||
diff --git a/meta/recipes-devtools/ruby/ruby_3.1.3.bb b/meta/recipes-devtools/ruby/ruby_3.1.3.bb index eec7e4684c..96873fd7fa 100644 --- a/meta/recipes-devtools/ruby/ruby_3.1.3.bb +++ b/meta/recipes-devtools/ruby/ruby_3.1.3.bb | |||
@@ -45,6 +45,7 @@ SRC_URI = "http://cache.ruby-lang.org/pub/ruby/${SHRT_VER}/ruby-${PV}.tar.gz \ | |||
45 | file://CVE-2024-49761-0007.patch \ | 45 | file://CVE-2024-49761-0007.patch \ |
46 | file://CVE-2024-49761-0008.patch \ | 46 | file://CVE-2024-49761-0008.patch \ |
47 | file://CVE-2024-49761-0009.patch \ | 47 | file://CVE-2024-49761-0009.patch \ |
48 | file://CVE-2024-41946.patch \ | ||
48 | " | 49 | " |
49 | UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" | 50 | UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" |
50 | 51 | ||