-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ruby and rubygem-rexml: patch CVE-2024-49761 #10935
Closed
Redent0r
wants to merge
3
commits into
microsoft:fasttrack/3.0
from
Redent0r:saulparedes/3.0/CVE-2024-49761
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From e4f434feea921a17031eb8ff09790c2952b7e7c5 Mon Sep 17 00:00:00 2001 | ||
From: Saul Paredes <[email protected]> | ||
Date: Tue, 5 Nov 2024 12:01:30 -0800 | ||
Subject: [PATCH] ruby: patch CVE-2024-49761 Patch adapted from | ||
https://github.com/ruby/rexml/commit/ce59f2eb1aeb371fe1643414f06618dbe031979f | ||
which fixes CVE-2024-49761 per | ||
https://nvd.nist.gov/vuln/detail/CVE-2024-49761 | ||
|
||
Needed for rubygem-rexml versions < 3.3.9 | ||
|
||
Signed-off-by: Saul Paredes <[email protected]> | ||
--- | ||
.../gems/rexml-3.2.8/lib/rexml/parsers/baseparser.rb | 10 +++++++--- | ||
1 file changed, 7 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/.bundle/gems/rexml-3.2.8/lib/rexml/parsers/baseparser.rb b/.bundle/gems/rexml-3.2.8/lib/rexml/parsers/baseparser.rb | ||
index d09237c..99e375c 100644 | ||
--- a/.bundle/gems/rexml-3.2.8/lib/rexml/parsers/baseparser.rb | ||
+++ b/.bundle/gems/rexml-3.2.8/lib/rexml/parsers/baseparser.rb | ||
@@ -474,10 +474,14 @@ module REXML | ||
rv = string.gsub( /\r\n?/, "\n" ) | ||
matches = rv.scan( REFERENCE_RE ) | ||
return rv if matches.size == 0 | ||
- rv.gsub!( /�*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) { | ||
+ rv.gsub!( /&#((?:\d+)|(?:x[a-fA-F0-9]+));/ ) { | ||
m=$1 | ||
- m = "0#{m}" if m[0] == ?x | ||
- [Integer(m)].pack('U*') | ||
+ if m.start_with?("x") | ||
+ code_point = Integer(m[1..-1], 16) | ||
+ else | ||
+ code_point = Integer(m, 10) | ||
+ end | ||
+ [code_point].pack('U*') | ||
} | ||
matches.collect!{|x|x[0]}.compact! | ||
if matches.size > 0 | ||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ Name: ruby | |
# provides should be versioned according to the ruby version. | ||
# More info: https://stdgems.org/ | ||
Version: %{ruby_version} | ||
Release: 2%{?dist} | ||
Release: 3%{?dist} | ||
License: (Ruby OR BSD) AND Public Domain AND MIT AND CC0 AND zlib AND UCD | ||
Vendor: Microsoft Corporation | ||
Distribution: Azure Linux | ||
|
@@ -104,6 +104,8 @@ Source6: rubygems.req | |
Source7: macros.rubygems | ||
Patch0: CVE-2024-41946.patch | ||
# Updates default ruby-uri to 0.12.2 and vendored one to 0.10.3. Remove once ruby gets updated to a version that comes with both lib/uri/version.rb and lib/bundler/vendor/uri/lib/uri/version.rb versions >= 0.12.2 or == 0.10.3 | ||
# Patch no longer needed if REXML gem is 3.3.9 or later. Now is 3.2.8 | ||
Patch1: CVE-2024-49761.patch | ||
BuildRequires: openssl-devel | ||
# Pkgconfig(yaml-0.1) is needed to build the 'psych' gem. | ||
BuildRequires: pkgconfig(yaml-0.1) | ||
|
@@ -408,6 +410,9 @@ sudo -u test make test TESTS="-v" | |
%{_rpmconfigdir}/rubygems.con | ||
|
||
%changelog | ||
* Tue Nov 05 2024 Saul Paredes <[email protected]> - 3.1.4-3 | ||
- Patch CVE-2024-49761 | ||
|
||
* Wed Sep 18 2024 Harshit Gupta <[email protected]> - 3.3.3-2 | ||
- Revert ruby back to 3.3.3 to avoid build failure of rubygems-* packages | ||
- Add patch for CVE-2024-41946 for bundled gem rexml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
From 67d11906da922cf0a9a5917f2f66c3cfb1472e4d Mon Sep 17 00:00:00 2001 | ||
From: Saul Paredes <[email protected]> | ||
Date: Tue, 5 Nov 2024 09:55:45 -0800 | ||
Subject: [PATCH] rubygem-rexml: patch CVE-2024-49761 | ||
|
||
Patch adapted from https://github.com/ruby/rexml/commit/ce59f2eb1aeb371fe1643414f06618dbe031979f | ||
which fixes CVE-2024-49761 per https://nvd.nist.gov/vuln/detail/CVE-2024-49761 | ||
|
||
Needed for rubygem-rexml versions < 3.3.9 | ||
|
||
Signed-off-by: Saul Paredes <[email protected]> | ||
--- | ||
lib/rexml/parsers/baseparser.rb | 10 +++++++--- | ||
1 file changed, 7 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb | ||
index 28810bf..7a7d370 100644 | ||
--- a/lib/rexml/parsers/baseparser.rb | ||
+++ b/lib/rexml/parsers/baseparser.rb | ||
@@ -133,7 +133,7 @@ module REXML | ||
PEDECL_PATTERN = "\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>" | ||
ENTITYDECL_PATTERN = /(?:#{GEDECL_PATTERN})|(?:#{PEDECL_PATTERN})/um | ||
CARRIAGE_RETURN_NEWLINE_PATTERN = /\r\n?/ | ||
- CHARACTER_REFERENCES = /�*((?:\d+)|(?:x[a-fA-F0-9]+));/ | ||
+ CHARACTER_REFERENCES = /&#((?:\d+)|(?:x[a-fA-F0-9]+));/ | ||
DEFAULT_ENTITIES_PATTERNS = {} | ||
default_entities = ['gt', 'lt', 'quot', 'apos', 'amp'] | ||
default_entities.each do |term| | ||
@@ -543,8 +543,12 @@ module REXML | ||
return rv if matches.size == 0 | ||
rv.gsub!( Private::CHARACTER_REFERENCES ) { | ||
m=$1 | ||
- m = "0#{m}" if m[0] == ?x | ||
- [Integer(m)].pack('U*') | ||
+ if m.start_with?("x") | ||
+ code_point = Integer(m[1..-1], 16) | ||
+ else | ||
+ code_point = Integer(m, 10) | ||
+ end | ||
+ [code_point].pack('U*') | ||
} | ||
matches.collect!{|x|x[0]}.compact! | ||
if matches.size > 0 | ||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ | |
Summary: REXML is an XML toolkit for Ruby | ||
Name: rubygem-%{gem_name} | ||
Version: 3.3.4 | ||
Release: 1%{?dist} | ||
Release: 2%{?dist} | ||
License: BSD | ||
Vendor: Microsoft Corporation | ||
Distribution: Azure Linux | ||
Group: Development/Languages | ||
URL: https://github.com/ruby/rexml | ||
Source0: https://github.com/ruby/rexml/archive/refs/tags/v%{version}.tar.gz#/%{gem_name}-%{version}.tar.gz | ||
Patch0: CVE-2024-49761.patch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you fix the indentation here? |
||
BuildRequires: git | ||
BuildRequires: ruby | ||
Requires: ruby(release) | ||
|
@@ -34,6 +35,9 @@ gem install -V --local --force --install-dir %{buildroot}/%{gemdir} %{gem_name}- | |
%{gemdir} | ||
|
||
%changelog | ||
* Tue Nov 05 2024 Saul Paredes <[email protected]> - 3.2.7-2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This version looks wrong - shouldn't it be 3.3.4-2? |
||
- Add patch for CVE-2024-49761 | ||
|
||
* Fri Aug 9 2024 Bhagyashri Pathak <[email protected]> - 3.3.4-1 | ||
- Upgrade to 3.3.4 to resolve CVE-2024-39908 | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this version should be 3.3.3-3