Why it matters
A document can read local files or make the server send requests (XXE).
How to fix it
Parse without LIBXML_NOENT and LIBXML_DTDLOAD; libxml 2.9+ does not load external entities otherwise.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
<?php
function parseFeed(string $xml): SimpleXMLElement
{
return simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOENT);
}<?php
function parseFeed(string $xml): SimpleXMLElement
{
return simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NONET);
}What TrustIvan reads
Runs on repository scans of PHP source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Unserialize without allowed classes (PHP)
PHPSeverity: Medium
trustivan-php-unserialize-without-allowed-classes - Extract request data (PHP)
PHPSeverity: High
trustivan-php-extract-request-data - TLS verification disabled (PHP)
PHPSeverity: High
trustivan-php-tls-verification-disabled - Hardcoded password database connection (PHP)
PHPSeverity: High
trustivan-php-hardcoded-password-database-connection - Mcrypt use (PHP)
PHPSeverity: Medium
trustivan-php-mcrypt-use - JWT hardcoded secret (PHP)
PHPSeverity: High
trustivan-php-jwt-hardcoded-secret
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation