Executive brief
xmldom is a JavaScript library that parses and serializes XML documents. The XMLSerializer component has a security feature (requireWellFormed flag) designed to reject malformed element and attribute names that could be used for XML injection attacks. An attacker can bypass this protection by embedding line-break characters in element names, allowing them to inject arbitrary XML or HTML markup that breaks out of the intended tag structure. Applications relying on this feature to safely serialize untrusted data remain vulnerable unless they update to the patched version.
Technical details
The vulnerability is a regex validation bypass in xmldom's element and attribute name validation. The shared regexp builder uses the multiline flag ('m') when constructing anchored matchers (^…$), causing the anchors to match line boundaries rather than string boundaries. When `requireWellFormed: true` is set, the validator tests element/attribute names using `QName_exact.test(name)`, but the 'm' flag makes '