CVE-2024-58378: Nokogiri before 1.16.2 Use-After-Free via xmlTextReader
Nokogiri before 1.15.6 and 1.16.x before 1.16.2 (CRuby, when using the packaged libxml2) is affected by a use-after-free vulnerability in libxml2 (CVE-2024-25062) in the xmlTextReader module, which underlies Nokogiri::XML::Reader. When using the XML Reader interface with DTD validation and XInclude expansion enabled, processing a crafted XML document can lead to an xmlValidatePopElement use-after-free. Nokogiri 1.15.6 and 1.16.2 resolve this by upgrading the packaged libxml2 to 2.11.7 and 2.12.5 respectively. JRuby and installations using system libxml2 are not affected.
Security readout for executives and security teams
Plain-English summary
A crafted XML file can trigger unsafe memory reuse in vulnerable Nokogiri installations. Applications are exposed only when they run CRuby with Nokogiri’s packaged libxml2 and process XML through the Reader interface with both DTD validation and XInclude expansion enabled. Successful triggering could compromise confidentiality, integrity, or availability according to the supplied CVSS assessment.
Executive priority
Treat as an urgent, targeted remediation rather than assuming universal Nokogiri exposure. Immediately identify internet-facing or externally fed XML workflows meeting all required conditions, then upgrade them first. The critical score supports rapid action, while the narrow configuration requirements and absence of confirmed active exploitation support evidence-based prioritization.
Technical view
CVE-2024-58378 is a CWE-416 use-after-free inherited from packaged libxml2 CVE-2024-25062. During crafted XML processing, the xmlTextReader path underlying Nokogiri::XML::Reader can reach an xmlValidatePopElement use-after-free when DTD validation and XInclude expansion are enabled. JRuby and system-libxml2 installations are excluded by the supplied advisory.
Likely exposure
Prioritize CRuby applications using Nokogiri versions before 1.15.6, or 1.16.x before 1.16.2, with packaged libxml2. Practical exposure additionally requires Nokogiri::XML::Reader, DTD validation, XInclude expansion, and attacker-influenced XML. Applications lacking any required condition are unlikely to expose this specific path.
Exploitation context
The supplied CVSS is 9.8, reflecting a network-reachable, low-complexity, unauthenticated condition with potentially severe impact. However, the bundle reports that this CVE is not in KEV and provides no evidence of active exploitation or a public working exploit. Treat exploit status as unconfirmed.
Researcher notes
The vulnerable behavior originates in libxml2’s xmlTextReader module and maps to CVE-2024-25062. Assessment should verify the runtime library source, not only the gem version. The supplied affected-version records appear range-oriented and potentially ambiguous; use the explicit advisory boundaries: before 1.15.6 and 1.16.x before 1.16.2.
Mitigation direction
Upgrade affected 1.15.x installations to Nokogiri 1.15.6 or later.
Upgrade affected 1.16.x installations to Nokogiri 1.16.2 or later.
Until upgraded, avoid processing untrusted XML with both DTD validation and XInclude expansion enabled.
Confirm deployed Nokogiri uses the expected patched packaged libxml2 version.
Validation and detection
Inventory Nokogiri versions, Ruby runtime type, and whether packaged or system libxml2 is used.
Identify code paths using Nokogiri::XML::Reader with DTD validation and XInclude expansion.
Trace whether attacker-controlled or externally supplied XML reaches those code paths.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-416: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
2CVSS vectors
3Timeline events
0ADP providers
4Source links
CVSS vector scores
2 official scores
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-416 · source CWE mapping
Use After Free
Use After Free represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.