CWE-112 Base Brouillon

Missing XML Validation

This vulnerability occurs when an application processes XML data from an untrusted source without first validating its structure and content against a defined schema.

Définition

What is CWE-112?

This vulnerability occurs when an application processes XML data from an untrusted source without first validating its structure and content against a defined schema.
When you accept XML without schema validation, you're trusting external data to match your code's expectations. Attackers exploit this gap by sending malformed, oversized, or maliciously crafted XML documents that can trigger parsing errors, consume excessive resources, or enable injection attacks. This fundamentally breaks the security assumption that input will be reasonable and well-formed. Consistently validating XML against a strict DTD or XML Schema is a critical first line of defense. While SAST tools can detect missing validation patterns, Plexicus uses AI to analyze your code flow and suggest precise fixes—like implementing schema validation libraries or hardening parser configurations—saving hours of manual security review and helping prevent this common oversight across your entire application portfolio.
Impact réel

Real-world CVEs caused by CWE-112

Aucune référence CVE publique n'est liée à ce CWE dans le catalogue MITRE pour le moment.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    The following code loads and parses an XML file.

  2. 2

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

  3. 3

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

  4. 4

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

Exemple de code vulnérable

Vulnerable Java

The following code loads and parses an XML file.

Vulnérable Java
```
// Read DOM* 
  try {
  ```
  	...
  	DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  	factory.setValidating( false );
  	....
  	c_dom = factory.newDocumentBuilder().parse( xmlFile );
  } catch(Exception ex) {
  	...
  }
Exemple de code sécurisé

Secure pseudo

Sécurisé pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Liste de contrôle de prévention

How to prevent CWE-112

  • Architecture and Design 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.
Signaux de détection

How to detect CWE-112

Automated Static Analysis High

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.)

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-112 et ouvre une PR de correction en moins de 60 secondes.

Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.

Questions fréquentes

Frequently asked questions

Qu'est-ce que CWE-112 ?

This vulnerability occurs when an application processes XML data from an untrusted source without first validating its structure and content against a defined schema.

Quelle est la gravité de CWE-112 ?

MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.

Quels langages ou plateformes sont affectés par CWE-112 ?

MITRE n'a pas spécifié les plateformes affectées pour ce CWE — il peut s'appliquer à la plupart des stacks applicatives.

Comment puis-je prévenir CWE-112 ?

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.

Comment Plexicus détecte et corrige CWE-112 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-112 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.

Où puis-je en savoir plus sur CWE-112 ?

MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/112.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.

Prêt quand vous l'êtes

Arrêtez de payer par développeur.
Commencez à fermer la boucle.

Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.