Improper Restriction of XML External Entity Reference ('XXE')
ID |
scala.xxe.scala_xxe_rule_document |
Severity |
high |
Resource |
Xxe |
Language |
Scala |
Description
XML External Entity (XXE) attacks can occur when an XML parser supports XML entities while processing XML received from an untrusted source.
Rationale
XML External Entity (XXE) attacks can occur when an XML parser supports XML entities while processing XML received from an untrusted source.
The following code illustrates a vulnerable pattern detected by this rule:
def unsafe1(str: String): Unit = {
val df = DocumentBuilderFactory.newInstance
df.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false)
val builder = df.newDocumentBuilder
// VULNERABLE: Improper Restriction of XML External Entity Reference ('XXE')
builder.parse(str)
}
Remediation
Follow secure coding practices and review the references below for detailed remediation guidance.
References
-
OWASP Top 10 2021 - A05 : Security Misconfiguration.