PHP Filter Chain File Read
Description
Detected possible file read caused by the error-based oracle of PHP filter chains. It can be used to leak the content of a local file when passed to vulnerable functions even when the server does not return the file content.
Examples
Insecure Code
php
$file = $_GET['file'];
$file_contents = file_get_contents($file);Secure Code
php
$file = basename($_GET['file']);
if (is_file($file) && strpos($file, '..') !== 0) {
$file_contents = file_get_contents($file);
}Remediation
Validate and sanitize user input to prevent file inclusion vulnerabilities. Use secure functions and avoid using user input in file operations.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0203 |
| Category | Injection |
| Severity | HIGH |
| CWE | CWE-98 |
| Confidence | LOW |
| Impact | LOW |
| Likelihood | LOW |
| Exploitability | COMPLEX |
| Tags | file inclusion, error-based oracle |
| OWASP | A03:2021 - Injection |