XML parsing is set to load external entities

tx0/php:xml-external-entitiesrecommendedwarningsecurity/injectiondepth fastsecurity, cwe-611

What it finds

LIBXML_NOENT and libxml_disable_entity_loader(false): substituting external entities lets an XML document make the parser read local files or fetch URLs and put their contents into the result. Documents from outside should be parsed without it.

From the rule's source, xml_external_entities.rs.

Example from the rule's tests
<?phpfunction parse($xml){    $doc = new DOMDocument();    $doc->loadXML($xml, LIBXML_NOENT | LIBXML_DTDLOAD);tx0 reports: LIBXML_NOENT substitutes external entities    libxml_disable_entity_loader(false);tx0 reports: this turns the loading of external entities on    return simplexml_load_string($xml);}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/php:xml-external-entities" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/php:xml-external-entities] reason="..."

tx0 explain tx0/php:xml-external-entities shows the same in the terminal. Found a false positive? Report it.