SKY-D255 · Security in code
File inclusion
PHP's include, require, include_once and require_once load a file and run it as PHP code. File inclusion happens when request data chooses which file is loaded. Skylos reports SKY-D255 when $_GET, $_POST, cookies or other request data reach the path of one of these statements.
- Languages
- PHP
- Quality gate
- counted toward the gate limits; a CRITICAL finding fails the gate on its own (full and diff scans)
- Finding type
- review
Why it matters
With ?page=../../../../var/log/nginx/access a visitor can make the server run a log file into which they wrote PHP code, or read files such as /etc/passwd. Where allow_url_include is on, a URL loads code from the attacker's server.
What Skylos flags
<?php $page = $_GET['page'] ?? 'home';include __DIR__ . '/pages/' . $page . '.php';What Skylos leaves alone
<?php $file = match ($_GET['page'] ?? 'home') { 'about' => 'about.php', 'contact' => 'contact.php', default => 'home.php',};include __DIR__ . '/pages/' . $file;Why Skylos leaves it alone
The request value only selects an arm of the match. Every arm returns a fixed file name, so the included path can only be one of three files. Skylos follows the values each arm returns, not the value that was matched.
How Skylos decides
- Runs PHP's flow-sensitive taint check over each function or file: request data starts at
$_GET,$_POST,$_REQUEST,$_COOKIE, the name and type of uploaded files, and the request objects of common frameworks, and follows assignments, string building and branches. - Finds
include,include_once,requireandrequire_onceand checks the path expression after the keyword. - Stops at values that cannot choose the file: numbers from casts and numeric functions,
basename()for paths,matcharms that return literals, and a guard whose failing branch exits, such as a strictin_array($page, [...], true)against a literal list. - Reports CRITICAL when request data still reaches the path. Before 5.6.0 this was reported as SKY-D215.
How to fix it
Map the input to a fixed list of files, or reject anything that is not on a literal allowlist before the include runs. Keep allow_url_include off.
<?php $page = $_GET['page'] ?? 'home';Added: if (!in_array($page, ['home', 'about', 'contact'], true)) {Added: http_response_code(404);Added: exit;Added: }include __DIR__ . '/pages/' . $page . '.php';When it can be wrong
- A check made in a helper function, such as
assert_page($page)that exits on a bad value, is not seen, so the include stays reported. - A loose
in_array()without the third argumenttruedoes not count as a guard, because PHP's loose comparison accepts unexpected values.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Mark a reviewed line and say why. A bare
// noqadoes not hide CRITICAL security findings.PHP include $path; // skylos: ignore[SKY-D255] path checked by assert_page()Accept the findings you already have with
skylos baseline ., then scan with--baselineso only new ones are listed.[tool.skylos] ignore = ["SKY-D255"]turns the rule off for the whole project.