CAPEC-193 Metadata
Likelihood of Attack
High
Typical Severity
High
Overview
Summary
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.
Prerequisites
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.
Execution Flow
Step | Phase | Description | Techniques |
---|---|---|---|
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. |
|
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. |
|
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. |
|
Potential Solutions / Mitigations
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
Related Weaknesses (CWE)
Related CAPECs
CAPEC ID | Description |
---|---|
CAPEC-253 | The attacker forces an application to load arbitrary code files from a remote location. The attacker could use this to try to load old versions of library files that have known vulnerabilities, to load malicious files that the attacker placed on the remote machine, or to otherwise change the functionality of the targeted application in unexpected ways. |
Stay Ahead of Attack Patterns
Understanding CAPEC patterns helps security professionals anticipate and thwart potential attacks. Leverage these insights to enhance threat modeling, strengthen your software development lifecycle, and train your security teams effectively.