What Is XML Injection? CWE-91 Explained
Security Beginner 5 min read

What Is XML Injection? CWE-91 Explained

XML injection (CWE-91) puts untrusted input into XML an application builds, changing its structure. How it differs from XXE and why it ends in running commands.

Published: November 26, 2026 • Updated: November 26, 2026
xml injectioncwe-91input validationsecure coding

XML injection is an attack in which untrusted input is written into an XML document or XML-based request without proper escaping, so the attacker's text changes the structure or meaning of the document instead of being treated as data. MITRE tracks it as CWE-91. It is distinct from XXE (XML External Entity injection), which abuses the parser's entity handling. XML injection abuses the application's own document construction, and in the November 2026 Mitel MiCollab case it ended in arbitrary command execution.

What is XML injection?

XML injection happens when an application builds XML by concatenating strings and one of those strings comes from a user. If the user supplies angle brackets, quotes or element names, the resulting document contains elements or attributes the developer never intended. Whatever consumes that document then acts on the attacker's structure.

The flaw lives in the producer of the XML, not the parser. A perfectly configured, hardened parser will faithfully parse an attacker-shaped document because, syntactically, it is valid XML. That is the reason parser hardening alone does not fix CWE-91.

How is XML injection different from XXE?

XXE is a parser-side flaw where a document declares an external entity and a permissive parser fetches it, exposing local files or internal network services. XML injection is an application-side flaw where the application writes untrusted input into a document it generates, and the injected markup changes what the document says. XXE is fixed by disabling external entities in the parser; XML injection is fixed by escaping or validating input before it is placed in the document.

The two are often confused because both have "XML" in the name and both show up in enterprise middleware. The 2026 Cisco BroadWorks attack covered on this site was XXE. The Mitel MiCollab flaw CVE-2026-133303 is XML injection: Mitel describes "insufficient parameter validation" that lets pre-staged malicious content reach an XML handler and ends in command execution.

Where does XML injection show up in practice?

XML remains the wire format for a large part of enterprise infrastructure: SOAP web services, SAML assertions, provisioning interfaces on telephony and conferencing platforms, configuration files that applications regenerate at runtime, and interchange formats between appliance components. Any place where an application writes a value it received over the network into one of these documents is a candidate.

Unified communications products are a recurring example. Conferencing components accept meeting names, participant names, uploaded content and scheduling data, then pass that data to back-end services that still speak XML internally. The Mitel MiCollab AWV exploitation added to CISA KEV on November 25, 2026 is the current case: five flaws in one component, with the XML injection (CVSS 9.0) and a command injection (CVSS 10.0) as the two that execute commands.

Why does XML injection lead to command execution?

On its own, changing the structure of an XML document gives an attacker control over data, not code. The jump to command execution happens when a downstream component treats some element of the document as an instruction. Common patterns:

  • A configuration document is regenerated with attacker-controlled values, and a service reads a path, a hostname or a command-line argument from it.
  • An XML message is transformed into a shell invocation or a script call by a back-end process that trusts the message because it came from "inside" the product.
  • A document is passed to a second parser or templating engine that interprets processing instructions or embedded expressions.

In Mitel's description of CVE-2026-133303, the attacker needs pre-staged content, which is reflected in the high attack complexity in the CVSS vector. The injection is the second step; something must first be placed where the XML handler will read it. The companion flaw CVE-2026-133275, an unrestricted file upload, is the obvious first step. This is why the vendor warned that the flaws amplify each other, and why defenders should read vulnerability sets as chained vulnerabilities rather than isolated CVSS scores.

How do you prevent XML injection?

Prevention belongs in the code that produces XML, and it comes down to never building documents by string concatenation with untrusted data.

  • Use an XML library's DOM or builder API to create elements and set attribute values. The library escapes reserved characters for you.
  • Where a document must be built as text, escape the five XML special characters (less than, greater than, ampersand, double quote and single quote) in every value that originated outside the application.
  • Validate input against the narrowest acceptable format before it goes anywhere near a document. A meeting identifier that must be alphanumeric should be rejected if it is not, regardless of how it will be used later.
  • Validate generated documents against a schema before a downstream component consumes them, so an unexpected element is rejected rather than acted on.
  • Audit the consumers. If any process turns document content into a file path, a hostname or a command, that process needs its own allowlist, independent of whatever the producer did.

For operators who do not own the code, the controls are different: keep the vendor patch level current, restrict who can reach the interfaces that accept the input, and log the requests that feed XML-generating features so a sudden change in request shape is visible.

How do you detect an XML injection attack?

Look for input that contains XML metacharacters where none are expected, and for documents that fail schema validation or contain unexpected elements. In web and application logs, the signal is request parameters containing angle brackets, closing tags, or CDATA markers sent to features that should receive plain text such as names, titles or identifiers.

At the product level you usually cannot see the XML, so watch the outcomes instead: regenerated configuration files with unexpected contents, application processes spawning shells, and new outbound connections from a server whose job is to host conferences. Where a vendor advisory lists a "pre-staged content" condition, review the storage locations that the vulnerable component reads from for files you cannot account for.

What should IT teams take from the Mitel case?

CWE-91 is an old weakness class, and it still produces critical vulnerabilities in 2026 because XML stays embedded in product internals long after it has left the public API. The lesson for teams running enterprise communications platforms is to treat them as web application servers: inventory the interfaces they expose, apply vendor patches on the same schedule as other internet-facing systems, and reduce the network paths to components that accept user-supplied content. The practical steps for the last item are in how to restrict external access to a UC server like MiCollab.