Vulnerability Type: Local File Inclusion (CWE-98 / CWE-22)
Severity: High (8.1/10)
Status: Draft / For CVE Registration
Project URL: https://www.sourcecodester.com/php/18708/pizzafy-ecommerce-system.html
A Local File Inclusion (LFI) vulnerability exists in the Pizzafy application. The page parameter in index.php does not properly validate or sanitize user-supplied input before passing it to a PHP include() function. This allows a remote attacker to traverse directories and potentially include sensitive files on the server or execute arbitrary code if paired with a file upload or log poisoning attack.
-
Vulnerable Endpoint:
http://localhost/pizzafy/admin/index.php -
Vulnerable Parameter:
page(GET request) -
Back-end Technology: PHP 8.2.12 (as seen in previous analysis), Apache 2.4.58
-
Platform: Windows (XAMPP environment)
The vulnerability is confirmed by the error messages generated when a directory traversal payload is supplied.
-
Payload Used:
../../../../../../ -
Observation: The application attempts to execute
include(../../../../../../.php). -
Reference: As shown in LFI 2.png, the server returns a PHP
Warning: include(): Failed opening '../../../../../../.php' for inclusion. This reveals that the application appends a.phpextension to the user input but allows traversal sequences (../) to move outside the intended directory. -
Path Disclosure: The error message in LFI 2.png also reveals the full internal server path:
C:\xampp\htdocs\Pizzafy\admin\index.php.
-
Information Disclosure: Attackers can read sensitive system files (e.g.,
C:\Windows\win.inion Windows or/etc/passwdon Linux) by bypassing the intended directory structure. -
Source Code Leakage: Attackers can read application source files, potentially revealing database credentials or other hardcoded secrets.
-
Remote Code Execution (RCE): If an attacker can upload a file (e.g., an image with embedded PHP code) or poison log files, they can use this LFI vulnerability to execute that code on the server.
-
Navigate to the admin panel:
http://localhost/pizzafy/admin/index.php. -
Modify the URL by adding the
pageparameter with a directory traversal sequence:http://localhost/pizzafy/admin/index.php?page=../../../../../../windows/win.ini -
Observe the server response. If successful, the contents of the requested file will be rendered or a PHP error confirming the attempt will appear (as seen in LFI 2.png).
To mitigate this vulnerability, avoid passing user-controllable input directly into file system APIs.
-
Whitelisting: Maintain a hardcoded list of allowed pages and compare the
pageparameter against this list.PHP
$allowed_pages = ['home', 'orders', 'menu', 'category_list']; $page = $_GET['page']; if (in_array($page, $allowed_pages)) { include($page . '.php'); } else { include('home.php'); }
-
Sanitization: Use
basename()to strip out directory paths, though whitelisting is significantly more secure. -
Disable Remote Inclusion: Ensure
allow_url_includeis set toOffinphp.ini.