top of page

File Inclusion Vulnerabilities

Updated: May 13

Hello guys👋👋 ,Prajit here from the BUG XS Team let's learn about File Inclusion Vulnerability.

What is File Inclusion Vulnerability?

The File Inclusion vulnerability allows an attacker to include a file, usually exploiting a “dynamic file inclusion” mechanism implemented in the target application. The vulnerability occurs due to the use of user-supplied input without proper validation.

A file inclusion vulnerability allows an attacker to access unauthorized or sensitive files available on the web server or to execute malicious files on the web server by making use of the ‘include’ functionality.

The impact of this vulnerability can lead to malicious code execution on the server or reveal data present in sensitive files, code execution on the client side, etc.

What are the Different Types of File Inclusion Vulnerabilities?

There are mainly two types of File Inclusion Vulnerabilities:

Local File Inclusion:

● Local file inclusion (also known as LFI) is the process of including files that are already locally present on the server, through the exploitation of vulnerable inclusion procedures implemented in the application.

● This vulnerability occurs when you enter the file or path of the file you want as an input, and as an response you get the content of that file.

● Mainly to increase the impact of this vulnerability look for files such as

a. /etc/passwd

b. /etc/shadow

c. /var/logs

d. C:\boot.ini

● Some Bypasses of LFI Protection:

1.traversal sequences stripped non-recursively:\/....\/....\/etc/passwd

2. Null byte (%00)

3. Encoding:

4.From Existent Folder:

● Method to escalate LFI to RCE:

1. In this case look for file /proc/self/environ or any other type of log file which takes certain part of request

2. If any part of your request is stored, for eg: via a user agent header, upload the php code there.

3. In case of valid response the php code will be stored into the target server, and you can execute commands through it. Hence RCE via LFI.

Remote File Inclusion:

● RFI allows an attacker to include and execute a remotely hosted file using a script by including it in the attack page. The attacker can use RFI to run malicious code either on the client side or on the server.

● The impact of this attack can vary from temporary theft of stealing session tokens or data when the target is the client, to complete compromise of the system when the target is the application server.

● Normal:

RFI Vuln:

● Some Bypass of RFI Protection:

1. Back Slashes:\\\shared\mal.php

2. Null Byte:

This is all for today’s writeup.

Thanks For Reading 😊

14 views0 comments

Recent Posts

See All
bottom of page