Ir al contenido

File Inclusion Injection (ARCH7139)

Esta página aún no está disponible en tu idioma.

Key php.security.file-inclusion-injection · Severity critical · Category security · CWE CWE-98

When an include/require path comes from user input it enables local/remote file inclusion (LFI/RFI). An attacker can execute arbitrary PHP files and achieve RCE.

<?php
$page = $_GET['page'];
include $page . '.php'; // ../../etc/passwd, http://evil/shell
<?php
$pages = ['home' => 'home.php', 'about' => 'about.php'];
$page = $_GET['page'] ?? 'home';
if (isset($pages[$page])) {
include __DIR__ . '/views/' . $pages[$page];
}

Map the file to include against a fixed allowlist; never build the path directly from user input.