T1505.003 Web Shell
Sub-technique of: T1505
High-Level Description
Adversaries may backdoor web servers with web shells to establish persistent access to systems. A Web shell is a Web script that is placed on an openly accessible Web server to allow an adversary to access the Web server as a gateway into a network. A Web shell may provide a set of functions to execute or a command-line interface on the system that hosts the Web server.
In addition to a server-side script, a Web shell may have a client interface program that is used to talk to the Web server (e.g. China Chopper Web shell client).
Kill Chain Phase
- Persistence (TA0003)
Platforms: Linux, macOS, Network Devices, Windows
What to Check
- Identify if Web Shell technique is applicable to target environment
- Check Linux systems for indicators of Web Shell
- Check macOS systems for indicators of Web Shell
- Check Network Devices systems for indicators of Web Shell
- Verify mitigations are bypassed or absent (2 known mitigations)
- Assess detection coverage (1 detection strategies)
How to Test
Atomic Red Team Tests
The following tests are from Atomic Red Team and provide actionable ways to test this technique:
Atomic Test 1: Web Shell Written to Disk
This test simulates an adversary leveraging Web Shells by simulating the file modification to disk. Idea from APTSimulator. cmd.aspx source - https://github.com/tennc/webshell/blob/master/fuzzdb-webshell/asp/cmd.aspx
Supported Platforms: windows
xcopy /I /Y "#{web_shells}" #{web_shell_path}
Dependencies:
- Web shell must exist on disk at specified location (#{web_shells})
Manual Testing
If Atomic Red Team tests are not applicable, manually verify the technique by:
Identify Attack Surface: Determine if the target environment is susceptible to Web Shell by examining the target platforms (Linux, macOS, Network Devices).
Assess Existing Defenses: Review whether mitigations for T1505.003 are in place. If defenses are absent or misconfigured, this technique may be exploitable.
Execute Test: Use tools and methods described in the MITRE ATT&CK page and external references below.
Remediation Guide
M1042 Disable or Remove Feature or Program
Consider disabling functions from web technologies such as PHP’s evaI() that may be abused for web shells.
M1018 User Account Management
Enforce the principle of least privilege by limiting privileges of user accounts so only authorized accounts can modify the web directory.
Detection
Web Shell Detection via Server Behavior and File Execution Chains
Risk Assessment
| Finding | Severity | Impact |
|---|---|---|
| Web Shell technique applicable | High | Persistence |
CWE Categories
| CWE ID | Title |
|---|---|
| CWE-276 | Incorrect Default Permissions |