CVE-2026-137951 in Libexpat
Summary
by MITRE • 11/27/2026
libexpat 2.6.0 through 2.11.0 built with XML_GE=0 and XML_UNICODE contains an out-of-bounds read in storeSelfEntityValue() because narrow string literals are treated as wide strings. Attackers can supply an XML document whose DOCTYPE declares a general entity to expose adjacent static memory through the entity value or crash the parser.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 11/27/2026
The vulnerability identified in libexpat versions 2.6.0 through 2.11.0 represents a critical type confusion flaw that arises from incorrect handling of string literals when the library is compiled with specific configuration flags. Specifically, this issue occurs when XML_GE is set to zero and XML_UNICODE is enabled during compilation. Under these conditions, narrow string literals are erroneously treated as wide strings within the storeSelfEntityValue function. This misinterpretation leads directly to an out-of-bounds read operation, where the parser accesses memory locations beyond the intended boundaries of the allocated buffer. The root cause lies in the mismatch between the expected data type and the actual byte representation used by the underlying C runtime when processing entity values defined within XML documents.
From a technical perspective, this flaw allows attackers to craft malicious XML documents that exploit the parsing logic during the declaration of general entities within DOCTYPE sections. When such an entity is processed, the parser attempts to store its value using functions that assume wide string semantics due to the compilation configuration. However, because narrow strings are being interpreted as wide strings, the memory access patterns become unpredictable and unsafe. This can result in reading adjacent static memory contents which were not intended for exposure. The severity of this issue is compounded by the fact that it affects core parsing functionality, making it difficult to mitigate through simple input validation at higher application layers without addressing the underlying library behavior.
The operational impact of this vulnerability is significant, primarily manifesting as either information disclosure or denial of service conditions. In scenarios where the parser successfully reads adjacent memory before encountering an error boundary, sensitive data stored in static memory regions may be leaked to the attacker through the entity value output mechanism. This could potentially expose internal application states, cryptographic keys, or other confidential information depending on how libexpat is integrated into the host software. Alternatively, if the out-of-bounds read triggers a segmentation fault or similar critical failure before data can be safely returned, it results in an immediate crash of the parsing process. For services relying on continuous XML processing, such as web servers or document converters, this leads to service disruption and potential instability across dependent systems.
This vulnerability aligns with Common Weakness Enumeration category CWE-125, which describes out-of-bounds read scenarios where software reads data past the end of a buffer or array. Additionally, from an adversarial tactics perspective, it relates to ATT&CK technique T1083, specifically regarding file and directory discovery if the leaked memory reveals structural information about the host environment. While not directly enabling remote code execution in its current form, the ability to read arbitrary static memory provides a foundation for further exploitation chains that could lead to more severe compromises.
To mitigate this risk, organizations utilizing libexpat should immediately upgrade to version 2.11.1 or later where these type handling errors have been corrected. For environments unable to update promptly, it is crucial to ensure that XML documents processed by the library are strictly validated against expected entity structures and lengths before parsing begins. Implementing strict input sanitization at the application layer can help prevent malformed DOCTYPE declarations from reaching the vulnerable parser functions. Furthermore, developers should review their build configurations to avoid combining XML_GE=0 with XML_UNICODE unless absolutely necessary for legacy compatibility, as this specific combination exposes the type confusion flaw described in the advisory.