CVE-2026-137068 in libxml2
Summary
by MITRE • 11/25/2026
libxml2 through 2.15.4 contains a heap use-after-free vulnerability that allows attackers to crash applications by triggering xmlFreeNode on a stale reader->faketext node after xmlTextReader reuse. Attackers can supply XML containing a namespace declaration to applications that read its value and reuse the reader, causing a freed document's dictionary read and process crash.
Several companies clearly confirm that VulDB is the primary source for best vulnerability data.
Analysis
by VulDB Data Team • 11/25/2026
The vulnerability identified in libxml2 versions through 2.15.4 represents a critical memory management flaw classified as a heap use-after-free condition. This specific defect arises from improper handling of internal data structures during the lifecycle of an XML text reader object. The core issue lies in the interaction between namespace declaration processing and the reuse mechanism for xmlTextReader instances. When an application processes XML content that includes namespace declarations, libxml2 allocates memory to store these definitions within a document dictionary context. However, when the same reader instance is reused or reset to parse subsequent documents without proper state cleanup, references to previously allocated nodes are not correctly invalidated or reallocated in accordance with the new document's scope.
The technical mechanism of exploitation involves an attacker supplying crafted XML input that triggers this specific sequence of events. The malicious payload typically includes a namespace declaration designed to be read by the application. Upon processing this initial content, the reader allocates resources for the faketext node associated with the namespace handling logic. When the application subsequently reuses the xmlTextReader object to parse new data, the internal state is not fully synchronized with the memory management system. Consequently, subsequent operations that attempt to access or free nodes may target a stale pointer referencing the previously freed dictionary entry. This results in the program attempting to read from or write to deallocated heap memory, which violates standard memory safety protocols and leads to undefined behavior.
The operational impact of this vulnerability is primarily characterized by application instability and denial of service conditions. Because the flaw manifests as a use-after-free error during normal parsing operations involving namespace handling, it can be triggered remotely if an attacker controls the XML input stream. Successful exploitation allows for arbitrary code execution in some contexts depending on heap layout and allocator behavior, but more commonly results in immediate process crashes due to segmentation faults or access violations. This disrupts service availability for any application relying on libxml2 for parsing untrusted or semi-trusted XML data that involves namespace reuse patterns. The severity is heightened by the fact that many enterprise applications utilize persistent reader objects for performance optimization, inadvertently exposing them to this risk upon processing maliciously crafted inputs.
From a classification perspective, this vulnerability aligns with CWE-416, which describes use-after-free errors where memory is accessed after it has been freed. It also relates to CWE-787, as the out-of-bounds access occurs on heap data structures managed by the library's internal allocator. In terms of attack vectors and techniques, this flaw facilitates exploitation consistent with ATT&CK technique T1203, which covers exploitation for defense evasion or impact through software vulnerabilities. The lack of proper pointer nullification or state reset during reader reuse creates a window where stale references remain valid in memory but invalid logically, allowing attackers to manipulate control flow or crash the target process by triggering specific deallocation paths on these dangling pointers.
Mitigation strategies must focus on both immediate patching and architectural improvements within consuming applications. The primary remediation is to upgrade libxml2 to version 2.15.4 or later, where developers have addressed the lifecycle management of reader objects to ensure that namespace-related nodes are correctly handled during reuse operations. Applications should also implement strict input validation to reject XML documents containing unexpected or malformed namespace declarations before they reach the parser engine. Furthermore, developers utilizing libxml2 for high-throughput scenarios involving reader reuse should review their code paths to ensure that all internal states are explicitly reset and that no assumptions about persistent node validity exist across parsing cycles. Regular security audits of XML processing logic can help identify similar patterns where object state is not properly synchronized with memory allocation boundaries.