CVE-2024-41123
Executive Summary
CVE-2024-41123 is a Denial of Service (DoS) vulnerability in the REXML gem for Ruby, affecting versions prior to 3.3.3. The vulnerability is triggered when REXML parses specially crafted XML documents containing an excessive number of specific characters, such as whitespace characters, >], and ]>. This can lead to resource exhaustion, causing the application to become unresponsive. The CVSS score is 5.3 (Medium), and while no public proof-of-concept (PoC) or exploit code is currently available, the vulnerability is considered exploitable remotely without authentication.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the Ruby ecosystem via the REXML gem, a core library for XML parsing. Organizations using Ruby applications that process untrusted XML input are at risk. The gem is widely used in web frameworks (e.g., Ruby on Rails) and standalone scripts. The fix is included in REXML version 3.3.3, and all users should upgrade immediately. No known malicious packages have been reported, but supply chain risks include delayed patching in downstream dependencies.
CVSS Breakdown & Threat Level
- CVSS Score: 5.3 (Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack Vector: Network (AV:N) – Exploitable remotely.
- Attack Complexity: Low (AC:L) – No special conditions required.
- Privileges Required: None (PR:N) – No authentication needed.
- User Interaction: None (UI:N) – No user action required.
- Scope: Unchanged (S:U) – Impact confined to the vulnerable component.
- Confidentiality Impact: None (C:N) – No data exposure.
- Integrity Impact: None (I:N) – No data modification.
- Availability Impact: Low (A:L) – Resource exhaustion leads to degraded performance or denial of service.
Threat Level: Medium. While the impact is limited to availability, the low attack complexity and network vector make it a viable target for DoS attacks.
Deep Dive & Mechanics
The vulnerability resides in REXML's XML parsing logic. When parsing XML documents, REXML processes character sequences inefficiently. Specifically, the parser fails to handle large numbers of whitespace characters, >], and ]> sequences efficiently. This causes excessive CPU and memory consumption, leading to a denial of service.
Root Cause: Inefficient handling of character data in the parser's state machine. The parser does not properly bound the processing of repeated patterns, allowing an attacker to craft a small XML payload that triggers exponential resource usage.
Attack Scenario: An attacker sends a crafted XML payload to a Ruby application that uses REXML to parse XML (e.g., via an API endpoint). The payload contains a high density of the problematic characters, causing the server to hang or crash.
Affected Components:
- REXML gem versions < 3.3.3
- Ruby applications using REXML for XML parsing
Vulnerable vs. Patched Code
Vulnerable Code (REXML < 3.3.3):
The vulnerable code likely resides in the parser's handling of character data. For example, in the Text or Whitespace parsing routines, the code may not limit the number of consecutive whitespace characters or specific sequences.
# Vulnerable example (simplified)
def parse_text(text)
# Inefficient loop that processes each character individually
text.each_char do |c|
# Process character without bounds checking
end
end
Patched Code (REXML >= 3.3.3): The patch introduces bounds checking and optimized processing for repeated characters.
# Patched example (simplified)
def parse_text(text)
# Use efficient scanning with limits
text.scan(/\s+/) do |match|
# Process whitespace in chunks with a maximum size
if match.length > MAX_WHITESPACE
raise "Too many whitespace characters"
end
end
end
Key Differences:
- The patched version adds limits on the number of consecutive problematic characters.
- The patched version uses more efficient scanning methods (e.g., regex with bounds) instead of per-character loops.
Exploitation & Lab Setup
Red Team (Attacker)
Objective: Craft a malicious XML payload to cause a DoS on a Ruby application using REXML.
Lab Setup:
- Install a vulnerable Ruby environment (e.g., Ruby 3.0 with REXML 3.3.2).
- Create a simple Ruby script that parses XML using REXML.
Exploit Payload:
<?xml version="1.0"?>
<root>
<data>
<!-- Large number of whitespace characters -->
<![CDATA[ ... (thousands of spaces) ... ]]>
</data>
</root>
Execution:
# Save the payload as malicious.xml
# Run the vulnerable script
ruby -e "require 'rexml/document'; REXML::Document.new(File.read('malicious.xml'))"
Expected Outcome: The script will consume excessive CPU and memory, potentially hanging or crashing.
Blue Team (Defender)
Detection:
- Monitor for XML payloads with unusually high character counts or repeated patterns.
- Use network monitoring to detect large XML requests to endpoints that parse XML.
Mitigation:
- Upgrade REXML to version 3.3.3 or later.
- Implement input validation and rate limiting on XML parsing endpoints.
- Use a Web Application Firewall (WAF) to block suspicious XML payloads.
Hunting:
- Search logs for XML parsing errors or timeouts.
- Look for requests with
Content-Type: application/xmland large body sizes.
Indicators of Compromise (IOCs)
Network IOCs:
- XML payloads containing excessive whitespace characters (e.g., >10,000 consecutive spaces).
- XML payloads with repeated
>]or]>sequences. - High volume of XML requests to a single endpoint.
Host IOCs:
- High CPU usage by Ruby processes.
- Memory exhaustion in Ruby applications.
- Application logs showing
REXML::ParseExceptionor timeout errors.
File IOCs:
- Temporary files with large XML content in
/tmp/or application temp directories.
- Temporary files with large XML content in
Detection Engineering
YARA Rule
rule CVE_2024_41123_REXML_DoS {
meta:
description = "Detects XML payloads targeting CVE-2024-41123 in REXML"
author = "Valters IT"
date = "2025-04-08"
reference = "https://nvd.nist.gov/vuln/detail/CVE-2024-41123"
strings:
$whitespace = /\s{1000,}/ // Excessive whitespace
$gt_bracket = />\]{100,}/ // Repeated >]
$bracket_gt = /\]>{100,}/ // Repeated ]>
condition:
any of them
}
Sigma Rule
title: CVE-2024-41123 REXML DoS Detection
id: 8a9b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects XML payloads with excessive whitespace or specific character sequences targeting REXML
author: Valters IT
date: 2025-04-08
logsource:
category: webserver
product: generic
detection:
selection:
http.request.body|contains|all:
- '<?xml'
- '<![CDATA['
http.request.body|re: '\s{1000,}|>\]{100,}|]{100,}>'
condition: selection
falsepositives:
- Legitimate large XML files with many whitespace characters (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-41123 REXML DoS Attempt"; flow:to_server; content:"<?xml"; http_client_body; pcre:"/\s{1000,}|>\]{100,}|]{100,}>/R"; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade REXML: Update to version 3.3.3 or later.
gem update rexml - Patch Management: Ensure all Ruby applications using REXML are updated.
- Input Validation: Implement XML payload size limits and character frequency checks.
Long-Term Mitigations:
- Use a more robust XML parser (e.g., Nokogiri) if possible.
- Deploy a WAF with rules to block excessive whitespace or repeated patterns.
- Monitor for anomalous XML parsing behavior.
Workarounds:
- If upgrading is not immediately possible, disable XML parsing for untrusted input.
- Use a reverse proxy to filter XML requests before they reach the application.
Valters IT Signature This report was generated by Valters IT DevSecOps AI. For questions, contact security@valters-it.com.