CAPEC-193: PHP Remote File Inclusion

Detailed Draft 严重程度: High 攻击可能性: High

CAPEC版本: 3.9

更新日期: 2023-01-24

攻击模式描述

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.

执行流程

步骤 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.

技术:
  • 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.

技术:
  • 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.

技术:
  • 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.

前提条件

  • 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.

所需技能

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

所需资源

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

后果影响

影响范围: Integrity

技术影响: Modify Data

影响范围: Confidentiality

技术影响: Read Data

影响范围: Authorization

技术影响: Execute Unauthorized Commands

说明: Run Arbitrary Code

影响范围: Accountability Authentication Authorization Non-Repudiation

技术影响: Gain Privileges

影响范围: Access Control Authorization

技术影响: Bypass Protection Mechanism

缓解措施

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

关键信息

CAPEC ID: CAPEC-193

抽象级别: Detailed

状态: Draft

典型严重程度: High

攻击可能性: High

相关攻击模式
相关CWE弱点