Why it matters
If the data can ever be influenced by a user (a cookie, a cache entry, a queued job), a crafted payload builds objects whose magic methods run attacker-chosen code paths.
How to fix it
Store the data as JSON, or pass ['allowed_classes' => false] (or the exact list of classes you expect).
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
<?php
function cached(Redis $redis, string $key)
{
return unserialize($redis->get($key));
}<?php
function cached(Redis $redis, string $key)
{
return unserialize($redis->get($key), ['allowed_classes' => false]);
}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
- TLS verification disabled (PHP)
PHPSeverity: High
trustivan-php-tls-verification-disabled - XXE libxml NOENT (PHP)
PHPSeverity: High
trustivan-php-xxe-libxml-noent - Mcrypt use (PHP)
PHPSeverity: Medium
trustivan-php-mcrypt-use - Extract request data (PHP)
PHPSeverity: High
trustivan-php-extract-request-data - Weak cipher (PHP)
PHPSeverity: High
trustivan-php-weak-cipher - Hardcoded password database connection (PHP)
PHPSeverity: High
trustivan-php-hardcoded-password-database-connection
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