Why it matters
The caller can run script in another user's browser.
How to fix it
Encode with htmlspecialchars($value, ENT_QUOTES, 'UTF-8') at the point of output, or render through Blade {{ }} or Twig, which encode by default.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
<?php
$name = $_GET['name'];
echo "<h1>Hello " . $name . "</h1>";<?php
$name = $_GET['name'];
echo "<h1>Hello " . htmlspecialchars($name, ENT_QUOTES, 'UTF-8') . "</h1>";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
- SSRF from request input (PHP)
PHPSeverity: High
trustivan-php-taint-ssrf - Deserialization from request input (PHP)
PHPSeverity: High
trustivan-php-taint-deserialization - File inclusion from request input (PHP)
PHPSeverity: High
trustivan-php-taint-file-inclusion - Open redirect from request input (PHP)
PHPSeverity: Medium
trustivan-php-taint-open-redirect - Path traversal from request input (PHP)
PHPSeverity: High
trustivan-php-taint-path-traversal - LDAP injection from request input (PHP)
PHPSeverity: High
trustivan-php-taint-ldap-injection
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