Skip to content

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

FieldValue
IDCODE-0203
CategoryInjection
SeverityHIGH
CWECWE-98
ConfidenceLOW
ImpactLOW
LikelihoodLOW
ExploitabilityCOMPLEX
Tagsfile inclusion, error-based oracle
OWASPA03:2021 - Injection