REXML contains a denial of service vulnerability
Description
REXML is an XML toolkit for Ruby. The REXML gem before 3.2.6 has a denial of service vulnerability when it parses an XML that has many <s in an attribute value. Those who need to parse untrusted XMLs may be impacted to this vulnerability. The REXML gem 3.2.7 or later include the patch to fix this vulnerability. As a workaround, don't parse untrusted XMLs.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
REXML gem before 3.2.7 has a denial of service vulnerability when parsing XML with many `<` characters in attribute values.
Vulnerability
Overview
CVE-2024-35176 is a denial of service (DoS) vulnerability in the REXML XML toolkit for Ruby. The vulnerability exists in versions of the REXML gem prior to 3.2.7 [1]. The root cause is inefficient handling of attribute values containing many < characters during XML parsing. When the parser encounters such input, it can become stuck processing the malformed attribute, leading to excessive resource consumption [2].
Attack
Vector
An attacker can exploit this vulnerability by providing a crafted XML document that includes attribute values with a large number of < characters [1]. No authentication or special network position is required, as any application parsing untrusted XML with REXML is susceptible. The attack surface is broad, affecting any Ruby application that accepts user-supplied XML input [4].
Impact
Successful exploitation results in a denial of service condition. The parser can consume excessive CPU time, potentially causing the application to become unresponsive or crash [4]. This can be used to disrupt services that rely on REXML for XML processing, impacting availability.
Mitigation
The vulnerability is patched in REXML gem version 3.2.7 or later [1]. Users are strongly recommended to upgrade immediately. If upgrading is not possible, the only workaround is to avoid parsing untrusted XML [1]. Users of end-of-life Ruby versions should be aware of compatibility limitations [3].
AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
rexmlRubyGems | < 3.2.7 | 3.2.7 |
Affected products
108- osv-coords107 versionspkg:apk/chainguard/jruby-9.4pkg:apk/chainguard/jruby-9.4-default-rubypkg:apk/chainguard/kube-fluentd-operatorpkg:apk/chainguard/kube-fluentd-operator-compatpkg:apk/chainguard/kube-fluentd-operator-default-configpkg:apk/chainguard/kube-fluentd-operator-oci-entrypointpkg:apk/chainguard/logstashpkg:apk/chainguard/logstash-compatpkg:apk/chainguard/logstash-env2yamlpkg:apk/chainguard/logstash-jre-bcfipspkg:apk/chainguard/logstash-jre-bcfips-compatpkg:apk/chainguard/logstash-jre-bcfips-env2yamlpkg:apk/chainguard/logstash-jre-bcfips-with-output-opensearchpkg:apk/chainguard/logstash-output-opensearchpkg:apk/chainguard/logstash-with-output-opensearchpkg:apk/chainguard/ruby-3.1pkg:apk/chainguard/ruby-3.1-basepkg:apk/chainguard/ruby-3.1-base-devpkg:apk/chainguard/ruby-3.1-devpkg:apk/chainguard/ruby-3.1-docpkg:apk/chainguard/ruby-3.2pkg:apk/chainguard/ruby-3.2-basepkg:apk/chainguard/ruby-3.2-base-devpkg:apk/chainguard/ruby-3.2-devpkg:apk/chainguard/ruby-3.2-docpkg:apk/chainguard/ruby3.2-rexmlpkg:apk/chainguard/ruby-3.3pkg:apk/chainguard/ruby-3.3-basepkg:apk/chainguard/ruby-3.3-base-devpkg:apk/chainguard/ruby-3.3-devpkg:apk/chainguard/ruby-3.3-docpkg:apk/wolfi/jruby-9.4pkg:apk/wolfi/jruby-9.4-default-rubypkg:apk/wolfi/kube-fluentd-operatorpkg:apk/wolfi/kube-fluentd-operator-compatpkg:apk/wolfi/kube-fluentd-operator-default-configpkg:apk/wolfi/kube-fluentd-operator-oci-entrypointpkg:apk/wolfi/logstashpkg:apk/wolfi/logstash-compatpkg:apk/wolfi/logstash-env2yamlpkg:apk/wolfi/logstash-output-opensearchpkg:apk/wolfi/logstash-with-output-opensearchpkg:apk/wolfi/ruby-3.1pkg:apk/wolfi/ruby-3.1-basepkg:apk/wolfi/ruby-3.1-base-devpkg:apk/wolfi/ruby-3.1-devpkg:apk/wolfi/ruby-3.1-docpkg:apk/wolfi/ruby-3.2pkg:apk/wolfi/ruby-3.2-basepkg:apk/wolfi/ruby-3.2-base-devpkg:apk/wolfi/ruby-3.2-devpkg:apk/wolfi/ruby-3.2-docpkg:apk/wolfi/ruby3.2-rexmlpkg:apk/wolfi/ruby-3.3pkg:apk/wolfi/ruby-3.3-basepkg:apk/wolfi/ruby-3.3-base-devpkg:apk/wolfi/ruby-3.3-devpkg:apk/wolfi/ruby-3.3-docpkg:gem/rexmlpkg:rpm/almalinux/pcspkg:rpm/almalinux/pcs-snmppkg:rpm/almalinux/rubypkg:rpm/almalinux/ruby-develpkg:rpm/almalinux/ruby-docpkg:rpm/almalinux/rubygem-abrtpkg:rpm/almalinux/rubygem-abrt-docpkg:rpm/almalinux/rubygem-bigdecimalpkg:rpm/almalinux/rubygem-bsonpkg:rpm/almalinux/rubygem-bson-docpkg:rpm/almalinux/rubygem-bundlerpkg:rpm/almalinux/rubygem-bundler-docpkg:rpm/almalinux/rubygem-did_you_meanpkg:rpm/almalinux/rubygem-io-consolepkg:rpm/almalinux/rubygem-jsonpkg:rpm/almalinux/rubygem-minitestpkg:rpm/almalinux/rubygem-mongopkg:rpm/almalinux/rubygem-mongo-docpkg:rpm/almalinux/rubygem-mysql2pkg:rpm/almalinux/rubygem-mysql2-docpkg:rpm/almalinux/rubygem-net-telnetpkg:rpm/almalinux/rubygem-opensslpkg:rpm/almalinux/rubygem-pgpkg:rpm/almalinux/rubygem-pg-docpkg:rpm/almalinux/rubygem-power_assertpkg:rpm/almalinux/rubygem-psychpkg:rpm/almalinux/rubygem-rakepkg:rpm/almalinux/rubygem-rdocpkg:rpm/almalinux/rubygemspkg:rpm/almalinux/rubygems-develpkg:rpm/almalinux/rubygem-test-unitpkg:rpm/almalinux/rubygem-xmlrpcpkg:rpm/almalinux/ruby-irbpkg:rpm/almalinux/ruby-libspkg:rpm/opensuse/rubygem-rexml&distro=openSUSE%20Leap%2015.6pkg:rpm/suse/ruby2.5&distro=SUSE%20Enterprise%20Storage%207.1pkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-LTSSpkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP3-LTSSpkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP4-LTSSpkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP5pkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP6pkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP2-LTSSpkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP3-LTSSpkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP4-LTSSpkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015%20SP2pkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015%20SP3pkg:rpm/suse/ruby2.5&distro=SUSE%20Manager%20Server%204.3pkg:rpm/suse/rubygem-rexml&distro=SUSE%20Package%20Hub%2015%20SP6
< 9.4.8.0-r0+ 106 more
- (no CPE)range: < 9.4.8.0-r0
- (no CPE)range: < 9.4.8.0-r0
- (no CPE)range: < 1.18.2-r11
- (no CPE)range: < 1.18.2-r11
- (no CPE)range: < 1.18.2-r11
- (no CPE)range: < 1.18.2-r11
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 2.0.3-r2
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.8-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 9.4.8.0-r0
- (no CPE)range: < 9.4.8.0-r0
- (no CPE)range: < 1.18.2-r11
- (no CPE)range: < 1.18.2-r11
- (no CPE)range: < 1.18.2-r11
- (no CPE)range: < 1.18.2-r11
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 2.0.3-r2
- (no CPE)range: < 8.15.0-r0
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.1.6-r2
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.4-r4
- (no CPE)range: < 3.2.8-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.3.2-r0
- (no CPE)range: < 3.2.7
- (no CPE)range: < 0.10.18-2.el8_10.1
- (no CPE)range: < 0.10.18-2.el8_10.1
- (no CPE)range: < 2.5.9-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.5.9-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.5.9-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 0.3.0-4.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 0.3.0-4.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 1.3.4-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 4.3.0-2.module_el8.5.0+2625+ec418553
- (no CPE)range: < 4.3.0-2.module_el8.5.0+2625+ec418553
- (no CPE)range: < 1.16.1-4.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 1.16.1-4.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 1.2.0-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 0.4.6-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.1.0-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 5.10.3-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.5.1-2.module_el8.5.0+2625+ec418553
- (no CPE)range: < 2.5.1-2.module_el8.5.0+2625+ec418553
- (no CPE)range: < 0.4.10-4.module_el8.5.0+259+8cec6917
- (no CPE)range: < 0.4.10-4.module_el8.5.0+2625+ec418553
- (no CPE)range: < 0.1.1-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.1.2-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 1.0.0-3.module_el8.9.0+3635+c6f99506
- (no CPE)range: < 1.0.0-3.module_el8.9.0+3635+c6f99506
- (no CPE)range: < 1.1.1-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 3.0.2-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 12.3.3-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 6.0.1.1-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.7.6.3-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.7.6.3-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 3.2.7-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 0.3.0-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.5.9-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 2.5.9-112.module_el8.10.0+3871+342e2c2f
- (no CPE)range: < 3.3.9-bp156.4.3.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 2.5.9-150000.4.32.1
- (no CPE)range: < 3.3.9-bp156.4.3.1
- ruby/rexmlv5Range: < 3.2.7
Patches
14325835f92f3Read quoted attributes in chunks (#126)
4 files changed · +46 −15
Gemfile+1 −0 modified@@ -10,4 +10,5 @@ group :development do gem "bundler" gem "rake" gem "test-unit" + gem "test-unit-ruby-core" end
lib/rexml/parsers/baseparser.rb+10 −10 modified@@ -628,17 +628,17 @@ def parse_attributes(prefixes, curr_ns) message = "Missing attribute equal: <#{name}>" raise REXML::ParseException.new(message, @source) end - unless match = @source.match(/(['"])(.*?)\1\s*/um, true) - if match = @source.match(/(['"])/, true) - message = - "Missing attribute value end quote: <#{name}>: <#{match[1]}>" - raise REXML::ParseException.new(message, @source) - else - message = "Missing attribute value start quote: <#{name}>" - raise REXML::ParseException.new(message, @source) - end + unless match = @source.match(/(['"])/, true) + message = "Missing attribute value start quote: <#{name}>" + raise REXML::ParseException.new(message, @source) + end + quote = match[1] + value = @source.read_until(quote) + unless value.chomp!(quote) + message = "Missing attribute value end quote: <#{name}>: <#{quote}>" + raise REXML::ParseException.new(message, @source) end - value = match[2] + @source.match(/\s*/um, true) if prefix == "xmlns" if local_part == "xml" if value != "http://www.w3.org/XML/1998/namespace"
lib/rexml/source.rb+24 −5 modified@@ -65,7 +65,11 @@ def encoding=(enc) encoding_updated end - def read + def read(term = nil) + end + + def read_until(term) + @scanner.scan_until(Regexp.union(term)) or @scanner.rest end def ensure_buffer @@ -158,16 +162,31 @@ def initialize(arg, block_size=500, encoding=nil) end end - def read + def read(term = nil) begin - @scanner << readline + @scanner << readline(term) true rescue Exception, NameError @source = nil false end end + def read_until(term) + pattern = Regexp.union(term) + data = [] + begin + until str = @scanner.scan_until(pattern) + @scanner << readline(term) + end + rescue EOFError + @scanner.rest + else + read if @scanner.eos? and !@source.eof? + str + end + end + def ensure_buffer read if @scanner.eos? && @source end @@ -218,8 +237,8 @@ def current_line end private - def readline - str = @source.readline(@line_break) + def readline(term = nil) + str = @source.readline(term || @line_break) if @pending_buffer if str.nil? str = @pending_buffer
test/test_document.rb+11 −0 modified@@ -1,8 +1,12 @@ # -*- coding: utf-8 -*- # frozen_string_literal: false +require 'core_assertions' + module REXMLTests class TestDocument < Test::Unit::TestCase + include Test::Unit::CoreAssertions + def test_version_attributes_to_s doc = REXML::Document.new(<<~eoxml) <?xml version="1.0" encoding="UTF-8" standalone="no"?> @@ -198,6 +202,13 @@ def test_xml_declaration_standalone assert_equal('no', doc.stand_alone?, bug2539) end + def test_gt_linear_performance + seq = [10000, 50000, 100000, 150000, 200000] + assert_linear_performance(seq) do |n| + REXML::Document.new('<test testing="' + ">" * n + '"></test>') + end + end + class WriteTest < Test::Unit::TestCase def setup @document = REXML::Document.new(<<-EOX)
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- github.com/advisories/GHSA-vg3r-rm7w-2xghghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-35176ghsaADVISORY
- github.com/ruby/rexml/commit/4325835f92f3f142ebd91a3fdba4e1f1ab7f1cfbghsax_refsource_MISCWEB
- github.com/ruby/rexml/security/advisories/GHSA-vg3r-rm7w-2xghghsax_refsource_CONFIRMWEB
- lists.debian.org/debian-lts-announce/2025/01/msg00011.htmlghsaWEB
- security.netapp.com/advisory/ntap-20250306-0001ghsaWEB
- www.ruby-lang.org/en/news/2024/05/16/dos-rexml-cve-2024-35176ghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.