VYPR
Critical severityOSV Advisory· Published May 2, 2024· Updated Nov 25, 2024

libxmljs attrs type confusion RCE

CVE-2024-34391

Description

libxmljs is vulnerable to a type confusion vulnerability when parsing a specially crafted XML while invoking a function on the result of attrs() that was called on a parsed node. This vulnerability might lead to denial of service (on both 32-bit systems and 64-bit systems), data leak, infinite loop and remote code execution (on 32-bit systems with the XML_PARSE_HUGE flag enabled).

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
libxmljsnpm
<= 1.0.11

Affected products

2

Patches

Vulnerability mechanics

Root cause

"A type confusion vulnerability exists in libxmljs when parsing XML containing entities and invoking the attrs() function on a specific node."

Attack vector

An attacker can trigger this vulnerability by providing a specially crafted XML document that includes a DOCTYPE with an entity reference. When the `attrs()` function is invoked on a grand-child node that refers to this entity, a type confusion occurs. This can lead to denial of service, data leaks, infinite loops, and remote code execution, particularly on 32-bit systems when the `XML_PARSE_HUGE` flag is enabled [ref_id=1].

Affected code

The vulnerability lies within the SWIG-generated function `_wrap__xmlNode_properties_get()` in `libxml2.cc`. This function incorrectly casts `info.Holder()` to an `_xmlNode` pointer when it might actually be an `_xmlEntity`. The subsequent call to `_xmlNode_properties_get()` then accesses the `properties` member, which is at the same offset as the `length` member in `_xmlEntity`, leading to the type confusion [ref_id=1].

What the fix does

The advisory suggests that the `_wrap__xmlNode_properties_get()` function should include a check to verify that the `arg10` variable is indeed an `xmlNode` before proceeding. This would prevent the function from misinterpreting an `xmlEntity` as an `xmlNode`, thereby mitigating the type confusion that leads to the vulnerability.

Preconditions

  • inputSpecially crafted XML document with a DOCTYPE containing an entity reference.
  • configThe `XML_PARSE_HUGE` flag may be enabled for enhanced impact on 32-bit systems.

Reproduction

```javascript const libxmljs = require('libxmljs');

var d = `<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE note [ <!ENTITY writer "JFrog Security"> ]> <from>&writer;</from> `;

t = libxmljs.parseXml(d) from = t.get('//from') c = from.childNodes()[0] console.log("c.name = ", c.name()); //prints "c.name = entity_ref" c2 = c.childNodes()[0] //writer console.log("c2.name = ", c2.name()); //prints c2.name = entity_decl" c2_attrs = c2.attrs() //segmentation fault happens here console.log(c2_attrs[0].name()) ``` Run the script: `$ node DoS.js` Segmentation fault

Generated on Jun 7, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.