---
title: "CWE-112: Missing XML Validation"
url: https://radicalnotion.ai/cwe/cwe-112
type: cwe
description: "The product accepts XML from an untrusted source but does not validate the XML against the proper schema."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-112: Missing XML Validation

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 8
- **Of those, in CISA KEV:** 0
- **New in 2026:** 1
- **CWE catalog version:** 4.21

## Description

The product accepts XML from an untrusted source but does not validate the XML against the proper schema.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | The programmer might assume that a provided XML document is well-formed. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Unexpected State, Varies by Context | By accepting an XML document without validating it against a DTD or XML schema, the programmer leaves a door open for attackers to provide unexpected, unreasonable, or malicious input. |

## Potential mitigations

### Architecture and Design (Input Validation)

Always validate XML input against a known XML Schema or DTD.

It is not possible for an XML parser to validate all aspects of a document's content because a parser cannot understand the complete semantics of the data. However, a parser can do a complete and thorough job of checking the document's structure and therefore guarantee to the code that processes the document that the content is well-formed.

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Effectiveness: High

## Demonstrative examples

### Example 1

The following code loads and parses an XML file.

Bad code:

```java
// Read DOM
try {
    ...
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating( false );
    ....
    c_dom = factory.newDocumentBuilder().parse( xmlFile );
} catch(Exception ex) {
    ...
}
```

The XML file is loaded without validating it against a known XML Schema or DTD.

### Example 2

The following code creates a DocumentBuilder object to be used in building an XML document.

Bad code:

```java
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
DocumentBuilder builder = builderFactory.newDocumentBuilder();
```

The DocumentBuilder object does not validate an XML document against a schema, making it possible to create an invalid XML document.

### Example 3

The following PHP code receives XML content from an HTTP request body, loads the XML content into a PHP SimpleXMLElement Object ($xml), and prints the results back to the user.

Bad code:

```php
$xmlContent = file_get_contents('php://input');
if (empty($xmlContent)) {
    http_response_code(400);
    exit('No XML content received.');
}
$xml = simplexml_load_string($xmlContent, 'SimpleXMLElement');
echo $xml->asXML();
```

Good code:

```php
$xmlContent = file_get_contents('php://input');
// We skip a check that $xmlContent is empty
// Disable external entity loading to prevent XXE
libxml_disable_entity_loader(true);
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->loadXML($xmlString, LIBXML_NONET);
if (!$dom->schemaValidate('/xml/schema.xsd')) {
    http_response_code(400);
    exit('Invalid XML file.');
}
echo $dom->saveXML();
```

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2021-1359 | Cisco Web Security Appliance Privilege Escalation Vulnerability | high | 8.8 | - | No | 2021-07-08 |
| CVE-2020-1975 | Missing XML Validation in PAN-OS Web Interface | high | 8.8 | - | No | 2020-02-12 |
| CVE-2022-28213 | Missing XML Validation vulnerability in SAP BusinessObjects Business Intelligence Platform (dswsbobje - SOAP Web services) | high | 8.1 | - | No | 2022-04-12 |
| CVE-2023-40310 | Missing XML Validation vulnerability in SAP PowerDesigner Client BPMN2 import | high | 7.5 | - | No | 2023-10-10 |
| CVE-2013-4002 | Missing XML Validation in Apache Xerces2 | high | 7.1 | - | No | 2013-07-23 |
| CVE-2021-27780 | HCL BigFix Mobile / Modern Client Management is vulnerable to unauthenticated XML interaction | medium | 5.3 | - | No | 2022-05-27 |
| CVE-2020-27282 | Missing XML Validation in Hamilton-T1 | medium | 4.3 | - | No | 2021-03-15 |
| CVE-2026-1190 | Org.keycloak/keycloak-services: keycloak saml brokering: response delay due to unchecked notonorafter in subjectconfirmationdata | low | 3.1 | - | No | 2026-01-26 |

## Related attack patterns (CAPEC)

- [CAPEC-230](https://radicalnotion.ai/capec/capec-230): Serialized Data with Nested Payloads
- [CAPEC-231](https://radicalnotion.ai/capec/capec-231): Oversized Serialized Data Payloads

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-20](https://radicalnotion.ai/cwe/cwe-20) | Improper Input Validation |
| Parent | [CWE-1286](https://radicalnotion.ai/cwe/cwe-1286) | Improper Validation of Syntactic Correctness of Input |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | Missing XML Validation | - | - |
| Software Fault Patterns | Tainted input to command | SFP24 | - |

## Frequently asked questions

### What is CWE-112?

The product accepts XML from an untrusted source but does not validate the XML against the proper schema.

### What CVEs are caused by CWE-112?

8 recorded CVEs are attributed to CWE-112, including CVE-2021-1359, CVE-2020-1975 and CVE-2022-28213.

### How do you prevent CWE-112?

Always validate XML input against a known XML Schema or DTD.

### How is CWE-112 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-112?

Exploiting CWE-112 can lead to: Unexpected State, Varies by Context.

### Is CWE-112 actively exploited?

8 recorded CVEs are caused by CWE-112; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/112.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-112). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
