Fixed Improper Restriction of XML External Entity Reference #831
+1
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix the XXE vulnerability, we should disable external entity expansion and DTD loading when parsing untrusted XML. In
libxml2
, this is done by omitting theXML_PARSE_NOENT
andXML_PARSE_DTDLOAD
flags from the parser options. If DTDs are required for valid XML, useXML_PARSE_DTDATTR
or other safer options, but neverXML_PARSE_NOENT
orXML_PARSE_DTDLOAD
on untrusted input. The fix is to change line 384 insrc/http/modules/ngx_http_xslt_filter_module.c
to remove these flags, leaving only safe options such asXML_PARSE_NOWARNING
. If you need to allow DTDs for validation, useXML_PARSE_DTDVALID
instead, but do not allow loading external DTDs or entity expansion.References
XML External Entity (XXE) Processing
XML External Entity Prevention Cheat Sheet
Timothy Morgen: XML Schema, DTD, and Entity Attacks
Timur Yunusov, Alexey Osipov: XML Out-Of-Band Data Retrieval