Skip to content

Commit c1cdfb6

Browse files
imays11tradebot-elastic
authored andcommitted
[Tuning] First Time AWS Cloudformation Stack Creation by User (#5036)
* [Tuning] First Time AWS Cloudformation Stack Creation by User - corrected a creation_date error - Removed `CreateStackSet` API call as this only creates a blueprint for creating stack instances across multiple AWS accounts and regions but does not actually create the resources - Added `CreateStackInstances` API call which is used to create resources defined in the StackSet - removed user from rule name as this also triggers for roles - edited description and investigation guide - added Mitre technique * adding highlighted fields (cherry picked from commit 4cde57d)
1 parent 90355a8 commit c1cdfb6

File tree

1 file changed

+39
-25
lines changed

1 file changed

+39
-25
lines changed

rules/integrations/aws/execution_new_terms_cloudformation_createstack.toml

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
[metadata]
2-
creation_date = "2020/07/25"
2+
creation_date = "2024/07/25"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/01/15"
5+
updated_date = "2025/08/27"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
This rule detects the first time a principal calls AWS Cloudwatch `CreateStack` or `CreateStackSet` API. Cloudformation
11-
is used to create a single collection of cloud resources called a stack, via a defined template file. An attacker with
12-
the appropriate privileges could leverage Cloudformation to create specific resources needed to further exploit the
13-
environment. This is a new terms rule that looks for the first instance of this behavior in the last 10 days for a role
14-
or IAM user within a particular account.
10+
This rule detects the first time a principal calls AWS CloudFormation CreateStack, CreateStackSet or CreateStackInstances API. CloudFormation is used to create a collection of cloud resources called a stack, via a defined template file. An attacker with the appropriate privileges could leverage CloudFormation to create specific resources needed to further exploit the environment. This is a new terms rule that looks for the first instance of this behavior for a role or IAM user within a particular account.
1511
"""
1612
false_positives = [
1713
"""
18-
Verify whether the user identity should be using the `CreateStack` or `CreateStackSet` APIs. If known behavior is
14+
Verify whether the user identity should be using the triggered API. If known behavior is
1915
causing false positives, it can be exempted from the rule. The "history_window_start" value can be modified to
2016
reflect the expected frequency of known activity within a particular environment.
2117
""",
@@ -24,12 +20,10 @@ from = "now-6m"
2420
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
2521
language = "kuery"
2622
license = "Elastic License v2"
27-
name = "First Time AWS Cloudformation Stack Creation by User"
23+
name = "First Time AWS CloudFormation Stack Creation"
2824
references = [
29-
"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-cli-creating-stack.html/",
30-
"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html/",
31-
"https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html/",
32-
"https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateStackSet.html/",
25+
"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html",
26+
"https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html",
3327
]
3428
risk_score = 47
3529
rule_id = "0415258b-a7b2-48a6-891a-3367cd9d4d31"
@@ -38,7 +32,7 @@ tags = [
3832
"Domain: Cloud",
3933
"Data Source: AWS",
4034
"Data Source: Amazon Web Services",
41-
"Data Source: Cloudformation",
35+
"Data Source: CloudFormation",
4236
"Use Case: Asset Visibility",
4337
"Tactic: Execution",
4438
"Resources: Investigation Guide",
@@ -48,23 +42,24 @@ type = "new_terms"
4842

4943
query = '''
5044
event.dataset:aws.cloudtrail and event.provider:cloudformation.amazonaws.com and
51-
event.action: (CreateStack or CreateStackSet) and event.outcome:success
45+
event.action: (CreateStack or CreateStackInstances)
46+
and event.outcome:success
5247
'''
5348
note = """## Triage and analysis
5449
5550
> **Disclaimer**:
5651
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
5752
58-
### Investigating First Time AWS Cloudformation Stack Creation by User
53+
### Investigating First Time AWS CloudFormation Stack Creation
5954
60-
AWS CloudFormation automates the setup of cloud resources using templates, streamlining infrastructure management. Adversaries with access can exploit this to deploy malicious resources, escalating their control. The detection rule identifies unusual activity by flagging the initial use of stack creation APIs by a user, helping to spot potential unauthorized actions early.
55+
AWS CloudFormation automates the setup of cloud resources using templates, streamlining infrastructure management. Adversaries with access can exploit this to deploy malicious resources, escalating their control. The detection rule identifies unusual activity by flagging the initial use of stack creation APIs by a user or role, helping to spot potential unauthorized actions early.
6156
6257
### Possible investigation steps
6358
64-
- Review the CloudTrail logs for the specific event.dataset:aws.cloudtrail and event.provider:cloudformation.amazonaws.com to identify the user or role that initiated the CreateStack or CreateStackSet action.
59+
- Review `aws.cloudtrail.user_identity.arn` to identify the user or role that initiated the `CreateStack` or `CreateStackInstances` action.
6560
- Verify the IAM permissions of the user or role involved in the event to ensure they have the appropriate level of access and determine if the action aligns with their typical responsibilities.
66-
- Examine the stack template used in the CreateStack or CreateStackSet action to identify any unusual or unauthorized resources being provisioned.
67-
- Check the event.outcome:success field to confirm the stack creation was successful and investigate any related resources that were deployed as part of the stack.
61+
- Examine the stack template used to identify any unusual or unauthorized resources being provisioned.
62+
- Investigate any related resources that were deployed as part of the stack.
6863
- Correlate the timing of the stack creation with other logs or alerts to identify any suspicious activity or patterns that might indicate malicious intent.
6964
- Investigate the account's recent activity history to determine if there have been any other first-time or unusual actions by the same user or role.
7065
@@ -78,18 +73,37 @@ AWS CloudFormation automates the setup of cloud resources using templates, strea
7873
7974
### Response and remediation
8075
81-
- Immediately isolate the IAM user or role that initiated the stack creation to prevent further unauthorized actions. This can be done by revoking permissions or disabling the account temporarily.
82-
- Review the created stack and stack set for any unauthorized or suspicious resources. Identify and terminate any resources that are not part of the expected infrastructure.
76+
- Immediately isolate the IAM user or role that initiated the stack creation to prevent further unauthorized actions. This can be done by revoking permissions with a [DenyAll](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSDenyAll.html) permissions policy or disabling the account temporarily.
77+
- Review the created stack for any unauthorized or suspicious resources. Identify and terminate any resources that are not part of the expected infrastructure.
8378
- Conduct a thorough audit of recent IAM activity to identify any other unusual or unauthorized actions that may indicate further compromise.
8479
- If malicious activity is confirmed, escalate the incident to the security operations team for a full investigation and potential involvement of incident response teams.
8580
- Implement additional monitoring and alerting for the affected account to detect any further unauthorized attempts to use CloudFormation or other critical AWS services.
86-
- Review and tighten IAM policies and permissions to ensure that only necessary privileges are granted, reducing the risk of exploitation by adversaries.
87-
- Consider enabling AWS CloudTrail logging and AWS Config rules to maintain a detailed record of all API activity and configuration changes for ongoing monitoring and compliance."""
88-
81+
- Review and tighten IAM policies and permissions to ensure that only necessary privileges are granted, reducing the risk of exploitation by adversaries."""
82+
83+
[rule.investigation_fields]
84+
field_names = [
85+
"@timestamp",
86+
"user.name",
87+
"user_agent.original",
88+
"source.ip",
89+
"aws.cloudtrail.user_identity.arn",
90+
"aws.cloudtrail.user_identity.type",
91+
"aws.cloudtrail.user_identity.access_key_id",
92+
"event.action",
93+
"event.outcome",
94+
"cloud.account.id",
95+
"cloud.region",
96+
"aws.cloudtrail.request_parameters",
97+
"aws.cloudtrail.response_elements"
98+
]
8999

90100
[[rule.threat]]
91101
framework = "MITRE ATT&CK"
92102

103+
[[rule.threat.technique]]
104+
id = "T1648"
105+
name = "Serverless Execution"
106+
reference = "https://attack.mitre.org/techniques/T1648/"
93107
[rule.threat.tactic]
94108
id = "TA0002"
95109
name = "Execution"

0 commit comments

Comments
 (0)