AWS SSM SendCommand
with Run Shell Command Parameters
Identifies the use of the AWS Systems Manager (SSM) SendCommand
API with the either AWS-RunShellScript
or
AWS-RunPowerShellScript
parameters. The SendCommand
API call allows users to execute commands on EC2 instances using
the SSM service. Adversaries may use this technique to execute commands on EC2 instances without the need for SSH or RDP
access. This behavior may indicate an adversary attempting to execute commands on an EC2 instance for malicious
purposes. This is a New Terms rule that only flags
when this behavior is observed for the first time on a host in the last 7 days.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2022/09/03"
3integration = ["endpoint", "auditd_manager"]
4maturity = "production"
5updated_date = "2024/11/07"
6
7[rule]
8author = ["Elastic"]
9description = """
10Identifies the use of the AWS Systems Manager (SSM) `SendCommand` API with the either `AWS-RunShellScript` or
11`AWS-RunPowerShellScript` parameters. The `SendCommand` API call allows users to execute commands on EC2 instances using
12the SSM service. Adversaries may use this technique to execute commands on EC2 instances without the need for SSH or RDP
13access. This behavior may indicate an adversary attempting to execute commands on an EC2 instance for malicious
14purposes. This is a [New Terms](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-new-terms-rule) rule that only flags
15when this behavior is observed for the first time on a host in the last 7 days.
16"""
17false_positives = [
18 """
19 Legitimate use of the `SendCommand` API call to execute commands on EC2 instances using the SSM service may be done
20 by system administrators or DevOps engineers for legitimate purposes.
21 """,
22]
23from = "now-9m"
24index = ["logs-endpoint.events.*", "endgame-*", "auditbeat-*", "logs-auditd_manager.auditd-*"]
25language = "kuery"
26license = "Elastic License v2"
27name = "AWS SSM `SendCommand` with Run Shell Command Parameters"
28references = [
29 "https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ssm-privesc",
30 "https://securitycafe.ro/2023/01/17/aws-post-explitation-with-ssm-sendcommand/",
31]
32risk_score = 47
33rule_id = "c371e9fc-6a10-11ef-a0ac-f661ea17fbcc"
34setup = """## Setup
35
36This rule requires data coming in from Elastic Defend.
37
38### Elastic Defend Integration Setup
39Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
40
41#### Prerequisite Requirements:
42- Fleet is required for Elastic Defend.
43- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
44
45#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
46- Go to the Kibana home page and click "Add integrations".
47- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
48- Click "Add Elastic Defend".
49- Configure the integration name and optionally add a description.
50- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
51- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
52- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
53- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
54For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
55- Click "Save and Continue".
56- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
57For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
58"""
59severity = "medium"
60tags = [
61 "Domain: Endpoint",
62 "Domain: Cloud",
63 "OS: Linux",
64 "OS: macOS",
65 "OS: Windows",
66 "Use Case: Threat Detection",
67 "Tactic: Execution",
68 "Data Source: Elastic Defend",
69 "Data Source: Elastic Endgame",
70 "Data Source: Auditd Manager"
71]
72timestamp_override = "event.ingested"
73type = "new_terms"
74
75query = '''
76event.category: "process" and event.type: "start" and process.name: "aws"
77and (
78 host.os.type: ("windows" or "macos")
79 or (
80 host.os.type: "linux"
81 and event.action: ("exec" or "exec_event" or "executed" or "process_started")
82 )
83)
84and process.args: (
85 "send-command" and "--parameters" and commands=*
86 and ("AWS-RunShellScript" or "AWS-RunPowerShellScript")
87)
88'''
89
90[rule.investigation_fields]
91field_names = [
92 "@timestamp",
93 "process.user.name",
94 "process.entry_leader.group.name",
95 "process.entry_leader.real_user.name",
96 "event.action",
97 "event.type",
98 "host.os.type",
99 "host.os.kernel",
100 "process.entry_leader.executable",
101 "process.entry_leader.working_directory",
102 "process.parent.executable",
103 "process.executable",
104 "process.hash.sha256",
105 "process.parent.command_line",
106 "process.command_line",
107 "process.args"
108]
109
110[[rule.threat]]
111framework = "MITRE ATT&CK"
112[[rule.threat.technique]]
113id = "T1651"
114name = "Cloud Administration Command"
115reference = "https://attack.mitre.org/techniques/T1651/"
116
117
118[rule.threat.tactic]
119id = "TA0002"
120name = "Execution"
121reference = "https://attack.mitre.org/tactics/TA0002/"
122
123[rule.new_terms]
124field = "new_terms_fields"
125value = ["host.id"]
126[[rule.new_terms.history_window_start]]
127field = "history_window_start"
128value = "now-7d"
References
Related rules
- Potential Linux Hack Tool Launched
- Hidden Files and Directories via Hidden Flag
- Unix Socket Connection
- Tampering of Shell Command-Line History
- Process Started from Process ID (PID) File