Remote File Inclusion

critical Web App Scanning Plugin ID 98126

Synopsis

Remote File Inclusion

Description

Web applications occasionally use parameter values to store the location of a file which will later be required by the server.

An example of this is often seen in error pages, where the actual file path for the error page is stored in a parameter value -- for example `example.com/error.php?page=404.php`.

A remote file inclusion occurs when the parameter value (ie. path to file being called by the server) can be substituted with the address of remote resource -- for example: `yoursite.com/error.asp?page=http://anothersite.com/somethingBad.php`

In some cases, the server will process the fetched resource; therefore, if the resource contains server-side code matching that of the framework being used (ASP, PHP, JSP, etc.), it is probable that the resource will be executed as if it were part of the web application.

Scanner discovered that it was possible to substitute a parameter value with an external resource and have the server fetch it and include its contents in the response.

Solution

It is recommended that untrusted data is never used to form a file location to be included.
To validate data, the application should ensure that the supplied value for a file is permitted. This can be achieved by performing whitelisting on the parameter value, by matching it against a list of permitted files. If the supplied value does not match any value in the whitelist, then the server should redirect to a standard error page.
In some scenarios, where dynamic content is being requested, it may not be possible to perform validation against a list of trusted resources, therefore the list must also become dynamic (updated as the files change), or perform filtering to remove extraneous user input (such as semicolons, periods etc.) and only permit `a-z0-9`.
It is also advised that sensitive files are not stored within the web root and that the user permissions enforced by the directory are correct.

See Also

http://en.wikipedia.org/wiki/Remote_File_Inclusion

http://projects.webappsec.org/Remote-File-Inclusion

Plugin Details

Severity: Critical

ID: 98126

Type: remote

Published: 3/31/2017

Updated: 7/13/2023

Scan Template: api, full, pci, scan

Risk Information

VPR

Risk Factor: High

Score: 7.4

CVSS v2

Risk Factor: Critical

Base Score: 10

Vector: CVSS2#AV:N/AC:L/Au:N/C:C/I:C/A:C

CVSS Score Source: Tenable

CVSS v3

Risk Factor: Critical

Base Score: 9.8

Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

CVSS Score Source: Tenable

Reference Information