Local File Inclusion

How common?


Local File Inclusion (also known as LFI) is the process of including files, that are already locally present on the server, through the exploiting of vulnerable inclusion procedures implemented in the application. This vulnerability occurs, for example, when a page receives, as input, the path to the file that has to be included and this input is not properly sanitized, allowing directory traversal characters (such as dot-dot-slash) to be injected. Although most examples point to vulnerable PHP scripts, we should keep in mind that it is also common in other technologies such as JSP, ASP and others.


  • Code execution on the web server

  • Code execution on the client-side such as JavaScript which can lead to other attacks such as cross site scripting (XSS)

  • Denial of Service (DoS)

  • Sensitive Information Disclosure


Vulnerable Objects:

  • URL forms

  • FTP cli interface

How to find:

Locate phpinfo page?




Google dork example:


Interesting files to include:



/etc/passwd /etc/shadow /etc/issue /etc/group /etc/hostname /etc/ssh/ssh_config /etc/ssh/sshd_config /root/.ssh/id_rsa /root/.ssh/authorized_keys /home/user/.ssh/authorized_keys /home/user/.ssh/id_rsa

– %SYSTEMROOT%\repair\system – %SYSTEMROOT%\repair\SAM – %WINDIR%\win.ini – %SYSTEMDRIVE%\boot.ini – %WINDIR%\Panther\sysprep.inf – %WINDIR%\system32\config\AppEvent.Evt

More LFI paths to test:

Automating the audit:

Filtering bypass:

  • Try / and \ at the start of the folder name to try and reach the root directory.

  • Try %2f and %5c (percent encoded versions of the above).

  • Try using 16-bit Unicode encoding (. = %u002e, / = %u2215, \ = %u2216).

  • Try double URL encoding (. = %252e, / = %252f, \ = %255c).

  • Try overlong UTF-8 Unicode encoding (. can be %c0%2e, %e0%40%ae, %c0ae, / can be %c0%af, %e0%80%af, %c0%2f, etc, \ can be %c0%5c, %c0%80%5c).

An URL-encoded nullbyte %00 can be used on PHP ≤ v.5.3. to cut off a hard-coded file-extension

Practice Labs: