Medium severityPythonXML External Entities (XXE)LOW confidence
XML Etree Parse Untrusted
Python's stdlib XML parsers do not defend against entity-expansion and external-entity attacks (CWE-611).
Standards mapping
- OWASP Top 10
- A05:2021 - Security Misconfiguration
- OWASP ASVS
- V5.5.2 (L1)
Vulnerable vs. safe
Flagged by this check
return xml.etree.ElementTree.parse(path)Passes - the safe pattern
return defusedxml.ElementTree.parse(path)Why it matters & how to fix it
Python's stdlib XML parsers do not defend against entity-expansion and external-entity attacks (CWE-611). Parse untrusted XML with the defusedxml package (e.g. defusedxml.ElementTree) instead of xml.etree / xml.dom / xml.sax.
References
Rule ID integsec-python-xml-etree-parse-untrusted - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- Python - XML External Entities (XXE)Lxml XXE Resolve Entities
- Java - XML External Entities (XXE)XXE Documentbuilderfactory
- Java - XML External Entities (XXE)XXE Saxparserfactory
- Java - XML External Entities (XXE)XXE Transformerfactory
- Java - XML External Entities (XXE)XXE Xmlinputfactory
- C# - XML External Entities (XXE)Dtdprocessing Parse