HawkScan Test Info for Remote File Inclusion

Remote File Inclusion


Plugin Id: 7 | CWE: 98


To mitigate the risk of Remote File Inclusion (RFI) attacks, web application developers should implement the following security measures:

  1. Input validation: Validate and sanitize all user-supplied input, including URL parameters and file paths, to ensure they conform to expected formats and do not contain any malicious code or characters. Use server-side validation techniques such as regular expressions or whitelist-based filtering to validate input.

  2. Avoid dynamic file inclusion: Whenever possible, avoid using user-supplied input to construct file paths for inclusion. Instead, use static file paths or predefined variables to reference include files. This reduces the risk of including remote files with malicious code.

  3. Use whitelisting: Maintain a whitelist of allowed file paths and only include files from this list. This prevents the inclusion of arbitrary files from external sources.

  4. Disable remote file inclusion: If remote file inclusion is not required for the application’s functionality, disable it entirely. This can be done by configuring the server or application framework to disallow the inclusion of files from remote sources.

  5. Implement access controls: Restrict access to sensitive files and directories by setting appropriate file permissions and using access control mechanisms provided by the operating system or web server. This helps prevent unauthorized access to critical files.

  6. Regularly update and patch: Keep the web application framework, server software, and any third-party libraries up to date with the latest security patches. Vulnerabilities in these components can be exploited to bypass security measures and execute remote file inclusion attacks.


Remote File Inclusion (RFI) is an attack technique that targets web applications with “dynamic file include” mechanisms. It exploits the ability of web applications to include external files based on user-supplied input, such as URLs or parameter values. By manipulating this input, an attacker can trick the web application into including remote files containing malicious code.

Web application frameworks commonly support file inclusion to modularize code and improve maintainability. However, if the choice of module to include is based on elements from the HTTP request without proper validation, the application becomes vulnerable to RFI attacks.

PHP is particularly susceptible to RFI attacks due to its extensive use of file includes and default server configurations that increase vulnerability.


Remote File Inclusion (RFI) attacks pose several risks to web applications and their users:

  1. Server compromise: By including malicious files, an attacker can execute arbitrary code on the server. If the file inclusion is not properly wrapped or executed, the code in the included files runs in the context of the server user, potentially leading to a complete system compromise.

  2. Client compromise: Attackers can manipulate the content of the response sent to clients, embedding malicious code such as JavaScript. When executed by the client’s browser, this code can steal sensitive information, such as session cookies, leading to unauthorized access to user accounts.

  3. Data leakage: RFI attacks can allow attackers to access and retrieve sensitive data stored on the server. This includes confidential user information, intellectual property, or other sensitive data that may be accessible through the compromised server.

  4. Application integrity: By including malicious files, attackers can modify the behavior of the web application, potentially altering or deleting data, defacing the website, or disrupting its normal operation.

It is crucial for web application developers to understand and address the risks associated with RFI attacks to ensure the security and integrity of their applications and protect user data.