CAPEC-193

PHP Remote File Inclusion
Haute
Haute
Draft
2014-06-23
00h00 +00:00
2022-09-29
00h00 +00:00
Alerte pour un CAPEC
Restez informé de toutes modifications pour un CAPEC spécifique.
Gestion des notifications

Descriptions du CAPEC

In this pattern the adversary is able to load and execute arbitrary code remotely available from the application. This is usually accomplished through an insecurely configured PHP runtime environment and an improperly sanitized "include" or "require" call, which the user can then control to point to any web-accessible file. This allows adversaries to hijack the targeted application and force it to execute their own instructions.

Informations du CAPEC

Flux d'exécution

1) Explore

[Survey application] Using a browser or an automated tool, an adversary follows all public links on a web site. They record all the links they find.

Technique
  • Use a spidering tool to follow and record all links. Make special note of any links that include parameters in the URL.
  • Use a proxy tool to record all links visited during a manual traversal of the web application. Make special note of any links that include parameters in the URL. Manual traversal of this type is frequently necessary to identify forms that are GET method forms rather than POST forms.
  • Use a browser to manually explore the website and analyze how it is constructed. Many browser's plugins are available to facilitate the analysis or automate the URL discovery.
2) Experiment

[Attempt variations on input parameters] The attack variants make use of a remotely available PHP script that generates a uniquely identifiable output when executed on the target application server. Possibly using an automated tool, an adversary requests variations on the inputs they surveyed before. They send parameters that include variations of payloads which include a reference to the remote PHP script. They record all the responses from the server that include the output of the execution of remote PHP script.

Technique
  • Use a list of probe strings to inject in parameters of known URLs. The probe strings are variants of PHP remote file inclusion payloads which include a reference to the adversary controlled remote PHP script.
  • Use a proxy tool to record results of manual input of remote file inclusion probes in known URLs.
3) Exploit

[Run arbitrary server-side code] As the adversary succeeds in exploiting the vulnerability, they are able to execute server-side code within the application. The malicious code has virtual access to the same resources as the targeted application. Note that the adversary might include shell code in their script and execute commands on the server under the same privileges as the PHP runtime is running with.

Technique
  • Develop malicious PHP script that is injected through vectors identified during the Experiment Phase and executed by the application server to execute a custom PHP script.

Conditions préalables

Target application server must allow remote files to be included in the "require", "include", etc. PHP directives
The adversary must have the ability to make HTTP requests to the target web application.

Compétences requises

To inject the malicious payload in a web page
To bypass filters in the application

Ressources nécessaires

None: No specialized resources are required to execute this type of attack.

Atténuations

Implementation: Perform input validation for all remote content, including remote and user-generated content
Implementation: Only allow known files to be included (allowlist)
Implementation: Make use of indirect references passed in URL parameters instead of file names
Configuration: Ensure that remote scripts cannot be include in the "include" or "require" PHP directives

Faiblesses connexes

CWE-ID Nom de la faiblesse

CWE-98

Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion')
The PHP application receives input from an upstream component, but it does not restrict or incorrectly restricts the input before its usage in "require," "include," or similar functions.

CWE-80

Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.

Références

REF-59

WASC Threat Classification 2.0
http://projects.webappsec.org/Remote-File-Inclusion

REF-60

A Study In Scarlet, Exploiting Common Vulnerabilities in PHP Applications
Shaun Clowes.
http://securereality.com.au/studyinscarlett/

REF-30

OWASP Top 10 2007
https://www.owasp.org/www-pdf-archive/OWASP_Top_10_2007.pdf

REF-621

OWASP Vulnerabilities
https://owasp.org/www-community/vulnerabilities/PHP_File_Inclusion

Soumission

Nom Organisation Date Date de publication
CAPEC Content Team The MITRE Corporation 2014-06-23 +00:00

Modifications

Nom Organisation Date Commentaire
CAPEC Content Team The MITRE Corporation 2017-08-04 +00:00 Updated Attack_Phases, Attack_Prerequisites, Description Summary, Examples-Instances, Payload_Activation_Impact, Resources_Required
CAPEC Content Team The MITRE Corporation 2018-07-31 +00:00 Updated References
CAPEC Content Team The MITRE Corporation 2019-04-04 +00:00 Updated Consequences
CAPEC Content Team The MITRE Corporation 2020-07-30 +00:00 Updated Example_Instances, Execution_Flow, Mitigations
CAPEC Content Team The MITRE Corporation 2020-12-17 +00:00 Updated References
CAPEC Content Team The MITRE Corporation 2021-06-24 +00:00 Updated Related_Weaknesses
CAPEC Content Team The MITRE Corporation 2022-09-29 +00:00 Updated Example_Instances