-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rule Tuning] Add Investigation Guides to AWS Rules (#4249)
* adding investigation guides for existing AWS rules * removing 'AWS EC2 Instance Interaction with IAM Service' rule tuning * adding back newline * adjusted mitre att&ck mapping * adjusted query and rule name * updating date
- Loading branch information
1 parent
c602042
commit 1cc160f
Showing
4 changed files
with
237 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
rules/integrations/aws/execution_ssm_sendcommand_by_rare_user.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
[metadata] | ||
creation_date = "2020/07/06" | ||
integration = ["aws"] | ||
maturity = "production" | ||
updated_date = "2024/11/05" | ||
|
||
[rule] | ||
author = ["Elastic"] | ||
description = """ | ||
Detects the execution of commands or scripts on EC2 instances using AWS Systems Manager (SSM), such as `RunShellScript`, | ||
`RunPowerShellScript` or custom documents. While legitimate users may employ these commands for management tasks, they | ||
can also be exploited by attackers with credentials to establish persistence, install malware, or execute reverse shells | ||
for further access to compromised instances. This is a [New | ||
Terms](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-new-terms-rule) rule that looks for | ||
the first instance of this behavior by the `aws.cloudtrail.user_identity.arn` field in the last 7 days. | ||
""" | ||
false_positives = [ | ||
""" | ||
Verify whether the user identity, user agent, and/or hostname should be making changes in your environment. | ||
Suspicious commands from unfamiliar users or hosts should be investigated. If known behavior is causing false | ||
positives, it can be exempted from the rule. | ||
""", | ||
] | ||
from = "now-9m" | ||
index = ["filebeat-*", "logs-aws.cloudtrail-*"] | ||
language = "kuery" | ||
license = "Elastic License v2" | ||
name = "AWS SSM `SendCommand` Execution by Rare User" | ||
note = """## Triage and Analysis | ||
### Investigating AWS SSM `SendCommand` Execution by Rare User | ||
This rule detects the execution of commands or scripts on EC2 instances using AWS Systems Manager (SSM) by an unexpected or new user. The SSM `SendCommand` action can enable remote command execution, which adversaries may exploit to install backdoors, deploy malware, or interact with compromised instances through reverse shells. | ||
#### Possible Investigation Steps | ||
- **Identify the Target Instance**: | ||
- **Instance ID**: Review the `aws.cloudtrail.flattened.request_parameters.targets` field to identify which EC2 instances were targeted by this command. Confirm if these instances are expected to be managed through SSM. | ||
- **Document Used**: Check the `aws.cloudtrail.flattened.request_parameters.documentName` field, which specifies the document or script being executed. Commands such as `RunShellScript` or `RunPowerShellScript` can indicate interactive sessions or script-based interactions. | ||
- **Review User Context**: | ||
- **User Identity**: Inspect the `aws.cloudtrail.user_identity.arn` field to determine the user or role executing the `SendCommand`. If this user is not typically involved in EC2 or SSM interactions, this could indicate unauthorized access. | ||
- **Access Patterns**: Validate whether the user typically has permissions to perform `SendCommand` operations on instances and whether the frequency of this action matches expected behavior. | ||
- **Analyze Command Parameters**: | ||
- **Document Contents**: While the exact command may not be visible in CloudTrail, use logs to determine the purpose of the script, especially if the document name suggests encryption, data transfer, or reverse shell capabilities. | ||
- **Timing and Context**: Compare this command execution with other recent SSM actions in your environment. A single `SendCommand` event by an unusual user can indicate an early stage of a larger attack. | ||
- **Check User Agent and Source IP**: | ||
- **User Agent Analysis**: Review the `user_agent.original` field to verify the tool or client used (e.g., `aws-cli`). This can provide insight into whether this action was automated, scripted, or executed manually. | ||
- **Source IP and Geolocation**: Use `source.address` and `source.geo` fields to check if the IP address and geolocation align with expected regions for your organization. Unusual IP addresses or locations can indicate external adversaries. | ||
- **Evaluate for Persistence Indicators**: | ||
- **Command Consistency**: Investigate if this action is part of a recurring pattern, such as repeated command executions across instances, which may suggest an attempt to maintain access. | ||
- **Permissions**: Ensure that the IAM policies associated with the user limit `SendCommand` actions to necessary use cases. Consider adding alerts for commands executed by users with minimal roles or permissions. | ||
- **Correlate with Other CloudTrail Events**: | ||
- **Cross-Reference SSM Actions**: Look for other recent SSM actions like `CreateDocument`, `UpdateDocument`, or additional `SendCommand` events that could indicate preparation for further exploitation. | ||
- **Monitor Data Access or Modification**: Correlate with `S3` access patterns, IAM changes, or EC2 modifications in recent events to detect broader malicious activities. | ||
### False Positive Analysis | ||
- **Routine Automation**: SSM `SendCommand` may be used by automation scripts or management tools. Verify if this event aligns with known, routine automated workflows. | ||
- **Maintenance Activity**: Confirm if legitimate administrative activities, such as patching or updates, are expected at this time, which may involve similar commands executed on multiple instances. | ||
### Response and Remediation | ||
- **Limit SSM Permissions**: If unauthorized, immediately revoke `SendCommand` permissions from the user or role to prevent further access. | ||
- **Quarantine Target Instance**: If malicious behavior is confirmed, isolate the affected EC2 instance(s) to limit lateral movement or data exfiltration. | ||
- **Investigate and Contain User Account**: If the action was performed by a compromised account, review recent activity and reset access credentials as necessary. | ||
- **Audit SSM and IAM Configurations**: Periodically review permissions associated with SSM usage and ensure least privilege access principles are in place. | ||
### Additional Information | ||
For further details on managing AWS SSM and security best practices for EC2 instances, refer to the [AWS Systems Manager Documentation](https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-plugins.html) and AWS best practices. | ||
""" | ||
references = ["https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-plugins.html"] | ||
risk_score = 21 | ||
rule_id = "37b211e8-4e2f-440f-86d8-06cc8f158cfa" | ||
severity = "low" | ||
tags = [ | ||
"Domain: Cloud", | ||
"Data Source: AWS", | ||
"Data Source: Amazon Web Services", | ||
"Data Source: AWS SSM", | ||
"Use Case: Log Auditing", | ||
"Use Case: Threat Detection", | ||
"Tactic: Execution", | ||
"Resources: Investigation Guide", | ||
] | ||
timestamp_override = "event.ingested" | ||
type = "new_terms" | ||
|
||
query = ''' | ||
event.dataset: "aws.cloudtrail" | ||
and event.provider: "ssm.amazonaws.com" | ||
and event.action: "SendCommand" | ||
and event.outcome: "success" | ||
and not aws.cloudtrail.user_identity.arn: *AWSServiceRoleForAmazonSSM/StateManagerService* | ||
''' | ||
|
||
|
||
[[rule.threat]] | ||
framework = "MITRE ATT&CK" | ||
[[rule.threat.technique]] | ||
id = "T1651" | ||
name = "Cloud Administration Command" | ||
reference = "https://attack.mitre.org/techniques/T1651/" | ||
|
||
|
||
[rule.threat.tactic] | ||
id = "TA0002" | ||
name = "Execution" | ||
reference = "https://attack.mitre.org/tactics/TA0002/" | ||
|
||
[rule.new_terms] | ||
field = "new_terms_fields" | ||
value = ["aws.cloudtrail.user_identity.arn"] | ||
[[rule.new_terms.history_window_start]] | ||
field = "history_window_start" | ||
value = "now-7d" | ||
|
||
|
114 changes: 0 additions & 114 deletions
114
rules/integrations/aws/initial_access_via_system_manager.toml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.