Skip to content

Commit 8d0533a

Browse files
(PA-6507) Gem install rexml to 3.3.2 for CVE-2024-35176 and CVE-2024-39908
- The CVEs were fixed from rexml version 3.2.7 (CVE-2024-35176) and 3.3.2 (CVE-2024-39908). - Patching for the CVE wasn't getting applied cleanly and had a lot of conflicts. So updated the gem version to 3.3.2 in the rexml component file. - Added the change to _shared-agent-components since the CVEs impacts both agent-runtime-main (ruby 3.2.4 using rexml 3.2.6) and agent-runtime-7.x (ruby 2.7.8 using rexml 3.2.3) - For solaris-10-sparc and solaris-11-sparc, we ignore dependency when installing rexml since the ruby in these platforms tries to install strscan (rexml's dependency) but fails while building native extensions. We can ignore installing str scan since it is shipped with ruby 2.7.8 as its default gem. - rexml is a bundled gem in ruby 3. - When we gem install rexml version 3.3.2 to resolve CVEs, we end up having two versions of rexml -- rexml 3.2.5 which is shipped with ruby as its bundled gem and rexml 3.3.2 which we manually installed. - This causes 'Gem::Specification.reset:rexml' warning to go to stderr each time puppet runs. - Run 'gem cleanup rexml' so that it removes the 3.2.5 version for both agent-runtimes and pe-bolt-server-runtime-main, the impacted projects requiring the rexml component.
1 parent 311535a commit 8d0533a

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

configs/components/_base-rubygem.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,22 @@
4040
# If a gem needs more command line options to install set the :gem_install_options
4141
# in its component file rubygem-<compoment>, before the instance_eval of this file.
4242
gem_install_options = settings["#{pkg.get_name}_gem_install_options".to_sym]
43-
if gem_install_options.nil?
44-
pkg.install do
45-
"#{settings[:gem_install]} #{name}-#{version}.gem"
43+
pkg.install do
44+
steps = []
45+
if gem_install_options.nil?
46+
steps << "#{settings[:gem_install]} #{name}-#{version}.gem"
47+
else
48+
steps << "#{settings[:gem_install]} #{name}-#{version}.gem #{gem_install_options}"
4649
end
47-
else
48-
pkg.install do
49-
"#{settings[:gem_install]} #{name}-#{version}.gem #{gem_install_options}"
50+
51+
# We gem installed rexml to 3.3.2 in ruby 3 for CVE-2024-35176 and CVE-2024-39908. Since rexml is a bundled gem in ruby 3, we end up having
52+
# two versions of rexml -- 1) the bundled version shipped with ruby 3 (3.2.5) and 2) the one we manually installed with
53+
# the above gem install command.
54+
# So, we run gem cleanup so that it deletes the older version 3.2.5.
55+
# Note: We won't need to cleanup and install rexml once we upgrade to ruby >= 3.3.3
56+
if name == 'rexml' && settings[:ruby_version].to_i == 3
57+
steps << "#{settings[:gem_cleanup]} #{name}"
5058
end
59+
steps
5160
end
5261

configs/components/rubygem-rexml.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
component 'rubygem-rexml' do |pkg, settings, platform|
2-
pkg.version '3.2.6'
3-
pkg.md5sum 'a57288ae5afed07dd08c9f1302da7b25'
2+
pkg.version '3.3.2'
3+
pkg.md5sum '55d213401f5e6a7a83ff3d2cd64a23fe'
44

5+
# If the platform is solaris with sparc architecture in agent-runtime-7.x project, we want to gem install rexml
6+
# ignoring the dependencies, this is because the pl-ruby version used in these platforms is ancient so it gets
7+
# confused when installing rexml. It tries to install rexml's dependency 'strscan' by building native extensions
8+
# but fails. We can ignore insalling that since strscan is already shipped with ruby 2 as its default gem.
9+
if platform.name =~ /solaris-(10|11)-sparc/ && settings[:ruby_version].to_i < 3
10+
settings["#{pkg.get_name}_gem_install_options".to_sym] = "--ignore-dependencies"
11+
end
12+
513
instance_eval File.read('configs/components/_base-rubygem.rb')
614
end

configs/projects/_shared-agent-components.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
proj.component 'rubygem-fast_gettext'
6363
proj.component 'rubygem-ffi'
6464

65+
# Note: We won't need to explicitly add 'rubygem-rexml' to agent-runtimes once ruby is upgraded 3.3.3 or higher (CVE-2024-35176 and CVE-2024-39908).
66+
# This is because the bundled rexml gem version shipped with ruby itself will be free from these CVEs.
67+
proj.component 'rubygem-rexml'
68+
6569
if platform.is_windows? || platform.is_solaris? || platform.is_aix?
6670
proj.component 'rubygem-minitar'
6771
end

configs/projects/_shared-pe-bolt-server_with_ruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
proj.setting(:gem_install, "#{proj.host_gem} install --no-rdoc --no-ri --local --bindir=#{proj.bindir}")
6969
end
7070

71+
proj.setting(:gem_cleanup, "#{proj.host_gem} cleanup")
7172

7273
proj.setting(:datadir, File.join(proj.prefix, "share"))
7374
proj.setting(:mandir, File.join(proj.datadir, "man"))

configs/projects/agent-runtime-main.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
# platforms that use older rubies.
4444
proj.setting(:gem_install, "#{proj.host_gem} install --no-document --local")
4545

46+
proj.setting(:gem_cleanup, "#{proj.host_gem} cleanup")
47+
4648
########
4749
# Load shared agent components
4850
########

0 commit comments

Comments
 (0)