Skip to content
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

(PA-6507)(PA-6736) Gem install rexml to 3.3.2 for CVE-2024-35176 and CVE-2024-… #878

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions configs/components/_base-rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@
# If a gem needs more command line options to install set the :gem_install_options
# in its component file rubygem-<compoment>, before the instance_eval of this file.
gem_install_options = settings["#{pkg.get_name}_gem_install_options".to_sym]
if gem_install_options.nil?
pkg.install do
"#{settings[:gem_install]} #{name}-#{version}.gem"
pkg.install do
steps = []
if gem_install_options.nil?
steps << "#{settings[:gem_install]} #{name}-#{version}.gem"
else
steps << "#{settings[:gem_install]} #{name}-#{version}.gem #{gem_install_options}"
end
else
pkg.install do
"#{settings[:gem_install]} #{name}-#{version}.gem #{gem_install_options}"

# 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
# two versions of rexml -- 1) the bundled version shipped with ruby 3 (3.2.5) and 2) the one we manually installed with
# the above gem install command.
# So, we run gem cleanup so that it deletes the older version 3.2.5.
# Note: We won't need to cleanup and install rexml once we upgrade to ruby >= 3.3.3
if name == 'rexml' && settings[:ruby_version].to_i == 3
steps << "#{settings[:gem_cleanup]} #{name}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this specialized logic belongs in the generalized base rubygems code.

end
steps
end

12 changes: 10 additions & 2 deletions configs/components/rubygem-rexml.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
component 'rubygem-rexml' do |pkg, settings, platform|
pkg.version '3.2.6'
pkg.md5sum 'a57288ae5afed07dd08c9f1302da7b25'
pkg.version '3.3.2'
pkg.md5sum '55d213401f5e6a7a83ff3d2cd64a23fe'

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

instance_eval File.read('configs/components/_base-rubygem.rb')
end
4 changes: 4 additions & 0 deletions configs/projects/_shared-agent-components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
proj.component 'rubygem-fast_gettext'
proj.component 'rubygem-ffi'

# Note: We won't need to explicitly add 'rubygem-rexml' to agent-runtimes once ruby is upgraded to 3.3.3 or higher (CVE-2024-35176 and CVE-2024-39908).
# This is because the bundled rexml gem version shipped with ruby itself will be free from these CVEs.
proj.component 'rubygem-rexml'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want this in both streams?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, sorry i see that in the commit message. So for ruby 2.7 we want to override the default rexml version.


if platform.is_windows? || platform.is_solaris? || platform.is_aix?
proj.component 'rubygem-minitar'
end
Expand Down
1 change: 1 addition & 0 deletions configs/projects/_shared-pe-bolt-server_with_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
proj.setting(:gem_install, "#{proj.host_gem} install --no-rdoc --no-ri --local --bindir=#{proj.bindir}")
end

proj.setting(:gem_cleanup, "#{proj.host_gem} cleanup")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont understand this change. Also, it seems like we are missing this for installer runtime.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, i think this is related to my point here #878 (comment) I think this is a very specialized case. I would suggest the rexml component just encapsulate everything needed for this so that it is clear why we are doing it and when we eventually get to ruby version with the patched version it will be easier to drop.


proj.setting(:datadir, File.join(proj.prefix, "share"))
proj.setting(:mandir, File.join(proj.datadir, "man"))
Expand Down
2 changes: 2 additions & 0 deletions configs/projects/agent-runtime-main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
# platforms that use older rubies.
proj.setting(:gem_install, "#{proj.host_gem} install --no-document --local")

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

########
# Load shared agent components
########
Expand Down
Loading