In plain English: include $path loads whatever file the variable points
to. If the path comes from a request, an attacker may be able to load an
unexpected file.
Why it matters: Dynamic include paths can load attacker-controlled code, expose local files, and make it difficult to know which files a project uses.
include $_GET['page'];
include $base . '/bootstrap.php';
switch ($page) {
case 'home':
include __DIR__ . '/pages/home.php';
break;
case 'about':
include __DIR__ . '/pages/about.php';
break;
default:
http_response_code(404);
}
Literal paths, __DIR__, __FILE__, and project constants such as APP_ROOT
are treated as safe.
__DIR__ or __FILE__.dirname() or realpath() from a fixed path.switch or match.include or require.dirname() and realpath() are treated as safe only when their path and
level arguments are themselves fixed. Other function calls are treated as
dynamic even when they return a fixed path.E0055 has no configuration options and is enabled by default.