Improper Restriction of XML External Entity Reference
Description
The application uses the `xml.etree` package for processing XML, which suffers from various XML parsing vulnerabilities, including Billion Laughs and Quadratic Blowup entity expansion attacks. These vulnerabilities can allow an adversary to cause a Denial of Service (DoS) against the application parsing arbitrary XML.
Examples
Insecure Code
python
import xml.etree.cElementTree as ET
et = ET.fromstring('<foo>bar</foo>')Secure Code
python
from defusedxml.ElementTree import parse
et = parse('inventory.xml')Remediation
Use the `defusedxml` library when processing untrusted XML. Replace `xml.etree` imports with `defusedxml.ElementTree` imports.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0172 |
| Category | Injection |
| Severity | MEDIUM |
| CWE | CWE-611 |
| Confidence | HIGH |
| Impact | HIGH |
| Likelihood | MEDIUM |
| Exploitability | MODERATE |
| Tags | xml, xxe, injection |
| OWASP | A4:2017-XML External Entities (XXE), A03:2021-Injection |