Unsanitized user input in XML External Entity
- Rule ID: php_lang_xml_external_entity_vulnerability
- Languages: php
- Source: xml_external_entity_vulnerability.yml
Description
Unsanitized user input in XML External Entity (XXE) processing can lead to security vulnerabilities. When your application parses XML input containing untrusted data, it may interpret URIs that point to unauthorized external resources. This can result in an XXE injection, compromising the security of your application.
Remediations
- Do not enable the parsing of external entities within your XML processing. Disabling the parsing of external entities prevents your application from attempting to access or include external resources based on untrusted input. For LibXML, for example, do not use the LIBXML_NOENT flag
$userInput = $_GET["untrusted"];
DOMDocument::loadXML($userInput, LIBXML_NOENT); // unsafe
References
Associated CWE
OWASP Top 10
Configuration
To skip this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --skip-rule=php_lang_xml_external_entity_vulnerability
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=php_lang_xml_external_entity_vulnerability