A Limited Local File Inclusion (LFI) vulnerability is a security flaw that allows an attacker to read files on a web server but with certain restrictions. It's a "local" file inclusion because the attacker can only access files already on the server's file system.
The "limited" aspect comes from the attacker's control over which files are included, which is often constrained. They might be limited to specific directories, file types, or naming conventions. Unlike a full Local File Inclusion, where an attacker might be able to include any file on the system, a Limited LFI might restrict them, for example, to files within a designated "uploads" directory or only files with a specific extension like .txt or .PHP.
Attackers exploit LFI vulnerabilities by manipulating input parameters, such as those found in URLs or form fields, to trick the web application into including and executing or displaying the contents of unintended files.
While the limitations might seem to reduce the severity, Limited LFIs can still be quite dangerous, they can be used to:
- Gain access to sensitive information: Even if the attacker can't access the entire file system, they might be able to read configuration files, log files, or other sensitive data within the allowed directories. This information can be used to compromise the system further.
- Bypass authentication: In some cases, Limited LFIs can be used to include files that handle authentication, potentially allowing attackers to bypass login procedures.
- Gain a foothold for further attacks: Even if the directly accessible files aren't immediately exploitable, their information can be used to plan more sophisticated attacks, such as exploiting other vulnerabilities or gaining a better understanding of the server's architecture.
The severity of a Limited LFI depends heavily on the specific restrictions in place and the nature of the accessible files. While not as universally dangerous as a full LFI, it still represents a significant security risk that should be addressed promptly.
Following is the vulnerable code snippet