Skip to content

CWE-91: XML Injection (aka Blind XPath Injection)

Base

The product does not properly neutralize special elements that are used in XML, allowing attackers to modify the syntax, content, or commands of the XML before it is processed by an end system.

Within XML, special elements could include reserved words or characters such as "<", ">", """, and "&", which could then be used to add new data or modify XML syntax.

Consequences

  • Confidentiality, Integrity, Availability: Execute Unauthorized Code or Commands, Read Application Data, Modify Application Data

How to prevent it

  • Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.

Recent advisories

  • GHSA-vr34-hp96-76pp — xmldom: requireWellFormed DocType publicId/systemId validation is bypassable via an embedded line terminator
  • GHSA-jxjr-3g7g-3944 — xmldom: requireWellFormed element/attribute name validation is bypassable via an embedded line terminator
  • GHSA-c7q8-3ch8-vqpv — xmldom: Processing Instruction Target Injection Bypasses requireWellFormed
  • GHSA-3px3-54cx-rmw9 — xmldom: Creation-time XML Name/QName validation is bypassable via an embedded line terminator, allowing injection on the default serialization path
  • GHSA-27p8-2357-5qqv — xmldom: DocType `name` Injection Bypasses requireWellFormed
  • GHSA-w2rr-34g9-rvrj — xmldom: Element name injection via createElement() bypasses requireWellFormed
  • GHSA-4w3w-2rp5-g8jm — xmldom: Attribute name injection via setAttribute() bypasses requireWellFormed
  • EEF-CVE-2026-48590 — Element and Attribute Names Injected Verbatim into XML Output in xml_builder
  • EEF-CVE-2026-47080 — CDATA Section Breakout via Unsanitised ]]> in xml_builder
  • GHSA-8j5q-mfj2-5q9q — @astrojs/rss: XML Injection via Unescaped RSS Feed Fields
  • GHSA-5wm8-gmm8-39j9 — fast-xml-builder allows attribute values with unwanted quotes to bypass malicious or unwanted attributes
  • GHSA-45c6-75p6-83cc — fast-xml-builder Comment Value regex can be bypassed
  • GHSA-9wfj-c55w-j9qr — Kirby has XML injection in its XML creator toolkit
  • GHSA-f6ww-3ggp-fr8h — xmldom has XML injection through unvalidated DocumentType serialization
  • GHSA-x6wf-f3px-wcqx — xmldom has XML node injection through unvalidated processing instruction serialization

All advisories for CWE-91

Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor