Potential Shell via Web Server
Identifies suspicious commands executed via a web server, which may suggest a vulnerability and remote shell access.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2020/02/18"
3deprecation_date = "2023/03/04"
4integration = ["endpoint"]
5maturity = "deprecated"
6min_stack_comments = "New fields added: required_fields, related_integrations, setup"
7min_stack_version = "8.3.0"
8updated_date = "2023/03/04"
9
10[rule]
11author = ["Elastic"]
12description = "Identifies suspicious commands executed via a web server, which may suggest a vulnerability and remote shell access."
13false_positives = [
14 """
15 Network monitoring or management products may have a web server component that runs shell commands as part of normal
16 behavior.
17 """,
18]
19from = "now-9m"
20index = ["auditbeat-*", "logs-endpoint.events.*", "endgame-*"]
21language = "kuery"
22license = "Elastic License v2"
23name = "Potential Shell via Web Server"
24note = """## Triage and analysis
25
26### Investigating Potential Shell via Web Server
27
28Adversaries 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 use 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.
29
30This rule detects a web server process spawning script and command line interface programs, potentially indicating attackers executing commands using the web shell.
31
32#### Possible investigation steps
33
34- Investigate abnormal behaviors observed by the subject process such as network connections, file modifications, and
35any other spawned child processes.
36- Examine the command line to determine which commands or scripts were executed.
37- Investigate other alerts associated with the user/host during the past 48 hours.
38- If scripts or executables were dropped, retrieve the files and determine if they are malicious:
39 - Use a private sandboxed malware analysis system to perform analysis.
40 - Observe and collect information about the following activities:
41 - Attempts to contact external domains and addresses.
42 - Check if the domain is newly registered or unexpected.
43 - Check the reputation of the domain or IP address.
44 - File access, modification, and creation activities.
45 - Cron jobs, services and other persistence mechanisms.
46
47### False positive analysis
48
49- This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.
50
51### Response and remediation
52
53- Initiate the incident response process based on the outcome of the triage.
54- Isolate the involved host to prevent further post-compromise behavior.
55- If the triage identified malware, search the environment for additional compromised hosts.
56 - Implement temporary network rules, procedures, and segmentation to contain the malware.
57 - Stop suspicious processes.
58 - Immediately block the identified indicators of compromise (IoCs).
59 - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
60- Remove and block malicious artifacts identified during triage.
61- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
62- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
63- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
64- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
65"""
66references = [
67 "https://pentestlab.blog/tag/web-shell/",
68 "https://www.elastic.co/security-labs/elastic-response-to-the-the-spring4shell-vulnerability-cve-2022-22965",
69]
70risk_score = 47
71rule_id = "231876e7-4d1f-4d63-a47c-47dd1acdc1cb"
72severity = "medium"
73tags = ["Elastic", "Host", "Linux", "Threat Detection", "Persistence", "Investigation Guide", "Elastic Endgame"]
74timestamp_override = "event.ingested"
75type = "query"
76
77query = '''
78event.category:process and host.os.type:linux and event.type:(start or process_started) and
79process.name:(bash or dash or ash or zsh or "python*" or "perl*" or "php*") and
80process.parent.name:("apache" or "nginx" or "www" or "apache2" or "httpd" or "www-data")
81'''
82
83
84[[rule.threat]]
85framework = "MITRE ATT&CK"
86[[rule.threat.technique]]
87id = "T1505"
88name = "Server Software Component"
89reference = "https://attack.mitre.org/techniques/T1505/"
90[[rule.threat.technique.subtechnique]]
91id = "T1505.003"
92name = "Web Shell"
93reference = "https://attack.mitre.org/techniques/T1505/003/"
94
95
96
97[rule.threat.tactic]
98id = "TA0003"
99name = "Persistence"
100reference = "https://attack.mitre.org/tactics/TA0003/"
Triage and analysis
Investigating Potential Shell via Web Server
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 use 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.
This rule detects a web server process spawning script and command line interface programs, potentially indicating attackers executing commands using the web shell.
Possible investigation steps
- Investigate abnormal behaviors observed by the subject process such as network connections, file modifications, and any other spawned child processes.
- Examine the command line to determine which commands or scripts were executed.
- Investigate other alerts associated with the user/host during the past 48 hours.
- If scripts or executables were dropped, retrieve the files and determine if they are malicious:
- Use a private sandboxed malware analysis system to perform analysis.
- Observe and collect information about the following activities:
- Attempts to contact external domains and addresses.
- Check if the domain is newly registered or unexpected.
- Check the reputation of the domain or IP address.
- File access, modification, and creation activities.
- Cron jobs, services and other persistence mechanisms.
- Attempts to contact external domains and addresses.
- Observe and collect information about the following activities:
- Use a private sandboxed malware analysis system to perform analysis.
False positive analysis
- This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.
Response and remediation
- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove and block malicious artifacts identified during triage.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
References
Related rules
- Persistence via Kernel Module Modification
- Potential Persistence via Cron Job
- Strace Process Activity
- Attempt to Disable IPTables or Firewall
- Auditd Login Attempt at Forbidden Time