Skip to content

Commit 1de07b4

Browse files
ruby and rubygem-rexml: patch CVE-2024-49761 (#10929)
Signed-off-by: Saul Paredes <[email protected]> Co-authored-by: jslobodzian <[email protected]>
1 parent 8ed9a40 commit 1de07b4

File tree

4 files changed

+91
-2
lines changed

4 files changed

+91
-2
lines changed

SPECS/ruby/CVE-2024-49761.patch

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
From 42ab972c3b93321be351539a24ee95d31523a35d Mon Sep 17 00:00:00 2001
2+
From: Saul Paredes <[email protected]>
3+
Date: Mon, 4 Nov 2024 12:40:10 -0800
4+
Subject: [PATCH] ruby: patch CVE-2024-49761
5+
6+
Patch adapted from https://github.com/ruby/rexml/commit/ce59f2eb1aeb371fe1643414f06618dbe031979f
7+
which fixes CVE-2024-49761 per https://nvd.nist.gov/vuln/detail/CVE-2024-49761
8+
9+
Needed for ruby versions < 3.2.0
10+
11+
Signed-off-by: Saul Paredes <[email protected]>
12+
---
13+
.../gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb | 10 +++++++---
14+
1 file changed, 7 insertions(+), 3 deletions(-)
15+
16+
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
17+
index 305b120..4944074 100644
18+
--- a/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb
19+
+++ b/.bundle/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb
20+
@@ -467,10 +467,14 @@ module REXML
21+
rv.gsub!( /\r\n?/, "\n" )
22+
matches = rv.scan( REFERENCE_RE )
23+
return rv if matches.size == 0
24+
- rv.gsub!( /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {
25+
+ rv.gsub!( /&#((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {
26+
m=$1
27+
- m = "0#{m}" if m[0] == ?x
28+
- [Integer(m)].pack('U*')
29+
+ if m.start_with?("x")
30+
+ code_point = Integer(m[1..-1], 16)
31+
+ else
32+
+ code_point = Integer(m, 10)
33+
+ end
34+
+ [code_point].pack('U*')
35+
}
36+
matches.collect!{|x|x[0]}.compact!
37+
if matches.size > 0
38+
--
39+
2.25.1
40+

SPECS/ruby/ruby.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Name: ruby
8383
# provides should be versioned according to the ruby version.
8484
# More info: https://stdgems.org/
8585
Version: 3.1.4
86-
Release: 7%{?dist}
86+
Release: 8%{?dist}
8787
License: (Ruby OR BSD) AND Public Domain AND MIT AND CC0 AND zlib AND UCD
8888
Vendor: Microsoft Corporation
8989
Distribution: Mariner
@@ -106,6 +106,8 @@ Patch3: CVE-2024-27282.patch
106106
Patch4: CVE-2024-35176.patch
107107
# Patch no longer needed if REXML gem is 3.3.3 or later. Now is 3.2.5
108108
Patch5: CVE-2024-41946.patch
109+
# Patch no longer needed if REXML gem is 3.3.9 or later. Now is 3.2.5
110+
Patch6: CVE-2024-49761.patch
109111
BuildRequires: openssl-devel
110112
BuildRequires: readline
111113
BuildRequires: readline-devel
@@ -408,6 +410,9 @@ sudo -u test make test TESTS="-v"
408410
%{_rpmconfigdir}/rubygems.con
409411

410412
%changelog
413+
* Mon Nov 04 2024 Saul Paredes <[email protected]> - 3.1.4-8
414+
- Patch CVE-2024-49761
415+
411416
* Thu Sep 19 2024 Harshit Gupta <[email protected]> - 3.1.4-7
412417
- Patch CVE-2024-41946
413418

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
From 73938fa3d122d9110b6128711af90667ecc7321a Mon Sep 17 00:00:00 2001
2+
From: Saul Paredes <[email protected]>
3+
Date: Mon, 4 Nov 2024 12:37:13 -0800
4+
Subject: [PATCH] rubygem-rexml: patch CVE-2024-49761
5+
6+
Patch adapted from https://github.com/ruby/rexml/commit/ce59f2eb1aeb371fe1643414f06618dbe031979f
7+
which fixes CVE-2024-49761 per https://nvd.nist.gov/vuln/detail/CVE-2024-49761
8+
9+
Needed for rubygem-rexml versions < 3.3.9
10+
11+
Signed-off-by: Saul Paredes <[email protected]>
12+
---
13+
lib/rexml/parsers/baseparser.rb | 10 +++++++---
14+
1 file changed, 7 insertions(+), 3 deletions(-)
15+
16+
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb
17+
index d09237c..99e375c 100644
18+
--- a/lib/rexml/parsers/baseparser.rb
19+
+++ b/lib/rexml/parsers/baseparser.rb
20+
@@ -474,10 +474,14 @@ module REXML
21+
rv = string.gsub( /\r\n?/, "\n" )
22+
matches = rv.scan( REFERENCE_RE )
23+
return rv if matches.size == 0
24+
- rv.gsub!( /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {
25+
+ rv.gsub!( /&#((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {
26+
m=$1
27+
- m = "0#{m}" if m[0] == ?x
28+
- [Integer(m)].pack('U*')
29+
+ if m.start_with?("x")
30+
+ code_point = Integer(m[1..-1], 16)
31+
+ else
32+
+ code_point = Integer(m, 10)
33+
+ end
34+
+ [code_point].pack('U*')
35+
}
36+
matches.collect!{|x|x[0]}.compact!
37+
if matches.size > 0
38+
--
39+
2.25.1
40+

SPECS/rubygem-rexml/rubygem-rexml.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
Summary: REXML is an XML toolkit for Ruby
44
Name: rubygem-%{gem_name}
55
Version: 3.2.7
6-
Release: 2%{?dist}
6+
Release: 3%{?dist}
77
License: BSD
88
Vendor: Microsoft Corporation
99
Distribution: Mariner
1010
Group: Development/Languages
1111
URL: https://github.com/ruby/rexml
1212
Source0: https://github.com/ruby/rexml/archive/refs/tags/v%{version}.tar.gz#/%{gem_name}-%{version}.tar.gz
1313
Patch0: CVE-2024-41946.patch
14+
Patch1: CVE-2024-49761.patch
1415
BuildRequires: git
1516
BuildRequires: ruby
1617
Requires: ruby(release)
@@ -35,6 +36,9 @@ gem install -V --local --force --install-dir %{buildroot}/%{gemdir} %{gem_name}-
3536
%{gemdir}
3637

3738
%changelog
39+
* Mon Nov 04 2024 Saul Paredes <[email protected]> - 3.2.7-3
40+
- Add patch for CVE-2024-49761
41+
3842
* Thu Sep 19 2024 Harshit Gupta <[email protected]> - 3.2.7-2
3943
- Add patch for CVE-2024-41946
4044

0 commit comments

Comments
 (0)