Skip to content

Commit 00f5be6

Browse files
imays11tradebot-elastic
authored andcommitted
[Rule Tuning] AWS S3 Object Encryption Using External KMS Key (#5399)
Rule is alerting as expected, with low telemetry volume. Updates to rule query are to provide more alert context as an ESQL rule. - reduced execution window - added additional fields for more alert context, include customer-requested `data_stream.namespace` field - added highlighted fields - updated description and investigation guide (cherry picked from commit b3d7804)
1 parent 1254235 commit 00f5be6

File tree

1 file changed

+160
-43
lines changed

1 file changed

+160
-43
lines changed

rules/integrations/aws/impact_s3_object_encryption_with_external_key.toml

Lines changed: 160 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,143 @@
22
creation_date = "2024/07/02"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/07/16"
5+
updated_date = "2025/12/02"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Identifies `CopyObject` events within an S3 bucket using an AWS KMS key from an external account for encryption.
11-
Adversaries with access to a misconfigured S3 bucket and the proper permissions may encrypt objects with an external KMS
12-
key to deny their victims access to their own data.
10+
Identifies use of the S3 CopyObject API where the destination object is encrypted using an AWS KMS key from an external
11+
AWS account. This behavior may indicate ransomware-style impact activity where an adversary with access to a
12+
misconfigured S3 bucket encrypts objects using a KMS key they control, preventing the bucket owner from decrypting their
13+
own data. This technique is a critical early signal of destructive intent or cross-account misuse.
1314
"""
1415
false_positives = [
1516
"""
16-
Administrators within an AWS Organization structure may legitimately encrypt bucket objects with a key from an
17-
account different from the target bucket. Ensure that this behavior is not part of a legitimate operation before
18-
taking action.
17+
Cross-account KMS key usage may be legitimate in multi-account AWS Organizations architectures where centralized
18+
encryption keys are used for data governance or auditing workflows. Confirm whether the external KMS key belongs to
19+
an expected account before taking action. Data migration or cross-account backup workflows may legitimately
20+
re-encrypt S3 objects using a key in another account. Ensure these workflows are documented, tied to known IAM
21+
roles, and occur on predictable schedules.
1922
""",
2023
]
21-
from = "now-9m"
24+
from = "now-6m"
2225
language = "esql"
2326
license = "Elastic License v2"
2427
name = "AWS S3 Object Encryption Using External KMS Key"
2528
note = """## Triage and analysis
2629
27-
### Investigating AWS S3 Object Encryption Using External KMS Key
28-
29-
This rule detects the use of an external AWS KMS key to encrypt objects within an S3 bucket. Adversaries with access to a misconfigured S3 bucket may use an external key to copy objects within a bucket and deny victims the ability to access their own data.
30-
This rule uses [ESQL](https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-esql-rule) to look for use of the `CopyObject` operation where the target bucket's `cloud.account.id` is different from the `key.account.id` dissected from the AWS KMS key used for encryption.
31-
32-
#### Possible Investigation Steps:
33-
34-
- **Identify the Actor**: Review the `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.access_key_id` fields to identify who performed the action. Verify if this actor typically performs such actions and if they have the necessary permissions.
35-
- **Review the Request Details**: Examine the `aws.cloudtrail.request_parameters` to understand the specific details of the `CopyObject` action. Look for any unusual parameters that could suggest unauthorized or malicious modifications or usage of an unknown KMS keyId.
36-
- **Analyze the Source of the Request**: Investigate the `source.ip` and `source.geo` fields to determine the geographical origin of the request. An external or unexpected location might indicate compromised credentials or unauthorized access.
37-
- **Contextualize with Timestamp**: Use the `@timestamp` field to check when the object was copied. Changes during non-business hours or outside regular maintenance windows might require further scrutiny.
38-
- **Correlate with Other Activities**: Search for related CloudTrail events before and after this action to see if the same actor or IP address engaged in other potentially suspicious activities.
39-
- **Check for Object Deletion or Access**: Look for `DeleteObject`, `DeleteObjects`, or `GetObject` API calls to the same S3 bucket that may indicate the adversary accessing and destroying objects including older object versions.
40-
- **Interview Relevant Personnel**: If the copy event was initiated by a user, verify the intent and authorization for this action with the person or team responsible for managing S3 buckets.
41-
42-
### False Positive Analysis:
43-
44-
- **Legitimate Administrative Actions**: Confirm if the `CopyObject` action aligns with scheduled updates, maintenance activities, or legitimate administrative tasks documented in change management systems.
45-
- **Consistency Check**: Compare the action against historical data of similar activities performed by the user or within the organization. If the action is consistent with past legitimate activities, it might indicate a false alarm.
46-
47-
### Response and Remediation:
30+
> **Disclaimer**:
31+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance.
32+
> While every effort has been made to ensure its quality, validate and adapt it to suit your operational needs.
4833
49-
- **Immediate Review**: If the activity was unauthorized, search for potential ransom note placed in S3 bucket and review the bucket's access logs for any suspicious activity.
50-
- **Enhance Monitoring and Alerts**: Adjust monitoring systems to alert on similar `CopyObject` actions, especially those involving sensitive data or unusual file extensions.
51-
- **Educate and Train**: Provide additional training to users with administrative rights on the importance of security best practices concerning S3 bucket management and the risks of ransomware.
52-
- **Audit S3 Bucket Policies and Permissions**: Conduct a comprehensive audit of all S3 bucket policies and associated permissions to ensure they adhere to the principle of least privilege.
53-
- **Incident Response**: If there's an indication of malicious intent or a security breach, initiate the incident response protocol to mitigate any damage and prevent future occurrences.
54-
55-
### Additional Information:
34+
### Investigating AWS S3 Object Encryption Using External KMS Key
5635
57-
For further guidance on managing S3 bucket security and protecting against ransomware, refer to the [AWS S3 documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) and AWS best practices for security. Additionally, consult the following resources for specific details on S3 ransomware protection:
58-
- [ERMETIC REPORT - AWS S3 Ransomware Exposure in the Wild](https://s3.amazonaws.com/bizzabo.file.upload/PtZzA0eFQwV2RA5ysNeo_ERMETIC%20REPORT%20-%20AWS%20S3%20Ransomware%20Exposure%20in%20the%20Wild.pdf)
59-
- [S3 Ransomware Part 1: Attack Vector](https://rhinosecuritylabs.com/aws/s3-ransomware-part-1-attack-vector/)
36+
This rule detects when an S3 `CopyObject` operation encrypts an object using a KMS key belonging to a different AWS account than the bucket owner. This behavior is unusual and a strong indicator of:
37+
38+
- Cloud ransomware techniques, where adversaries encrypt data using a key only they control.
39+
- Cross-account privilege misuse, especially when an unauthorized principal has write access to S3.
40+
- Misconfigured bucket permissions, enabling principals from another account to perform privileged copy operations.
41+
- Early impact-stage activity in incidents where attackers prepare to destroy availability or deny the owner access.
42+
43+
The rule uses ESQL to identify cases where the `cloud.account.id` (bucket owner) differs from the dissected `kms_key_account_id` used for encrypting the new object version.
44+
45+
46+
#### Possible investigation steps
47+
48+
**Identify the actor and access pathway**
49+
- Review `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.access_key_id`.
50+
- Check whether the caller is:
51+
- A legitimate cross-account automation role,
52+
- A compromised IAM user or workload identity, or
53+
- A federated identity behaving outside of normal patterns.
54+
- Inspect `user_agent.original` to determine whether the action came from the AWS Console, CLI, SDK, or unusual tooling.
55+
56+
**Analyze the encryption behavior**
57+
- Inspect the dissected KMS key fields:
58+
- `Esql.aws_cloudtrail_request_parameters_kms_key_account_id`
59+
- `Esql.aws_cloudtrail_request_parameters_kms_key_id`
60+
- Confirm whether the external key:
61+
- Belongs to an attacker-controlled account,
62+
- Is unknown to your organization, or
63+
- Lives in a shared or security tooling account.
64+
65+
**Assess the objects affected**
66+
- Review:
67+
- `Esql.aws_cloudtrail_request_parameters_target_bucket_name`
68+
- `Esql.aws_cloudtrail_request_parameters_target_object_key`
69+
- Identify:
70+
- Whether objects were overwritten or new encrypted copies were created.
71+
- The sensitivity or criticality of the affected data.
72+
- Whether object versioning is enabled (important for recovery).
73+
74+
**Correlate surrounding access patterns**
75+
Pivot in CloudTrail on:
76+
- The same access key ID
77+
- The same IAM principal
78+
- Affected bucket ARN
79+
80+
Look for:
81+
- `DeleteObject` or `DeleteObjects` calls (common in ransomware behavior)
82+
- Mass enumeration prior to the event (`ListObjectsV2`, `GetObject`)
83+
- Other impact-stage actions (`PutBucketPolicy`, `PutBucketAcl`, disabling logging)
84+
- Attempts to encrypt additional objects in rapid succession
85+
86+
**Evaluate bucket permissions and exposure**
87+
Review:
88+
- S3 bucket policy changes
89+
- IAM roles with `s3:PutObject` or `s3:PutObjectAcl` permissions
90+
- Whether unintended cross-account `Principal` entries exist
91+
- Whether the KMS key policy explicitly trusts your account or a foreign one
92+
93+
**Validate business justification**
94+
- Confirm with storage, data engineering, or application teams whether:
95+
- Any migration, transformation, or backup workflows should be encrypting objects cross-account.
96+
- Scheduled jobs or CI/CD pipelines were operating at the time of the event.
97+
98+
### False positive analysis
99+
100+
- **Expected cross-account encryption**
101+
Many organizations use centralized encryption accounts or shared security accounts. Validate:
102+
- Whether the KMS key account is part of your AWS Organization
103+
- Whether the workflow, role, or application is documented
104+
- Whether the principal routinely performs CopyObject operations
105+
106+
### Response and remediation
107+
108+
**Contain and prevent further impact**
109+
- Immediately restrict S3 write access for the principal involved.
110+
- If the KMS key is attacker-controlled, the impacted objects may be unrecoverable without versioning.
111+
- If object versioning is disabled, enable it on the affected bucket to strengthen future resilience.
112+
113+
**Investigate scope and severity**
114+
- Identify:
115+
- Additional objects encrypted using external keys
116+
- Related suspicious actions (delete, modify, exfiltration events)
117+
- Whether any ransom markers or unauthorized files were uploaded
118+
- Validate whether the external KMS key grants *decrypt* permission back to the bucket owner (rare in attacker use).
119+
120+
**Recover and secure the bucket**
121+
- Restore accessible previous versions if versioning is enabled.
122+
- Revoke unauthorized access key pairs or session credentials.
123+
- Audit bucket policies, ACLs, and IAM conditions (`aws:PrincipalArn`, `aws:SourceAccount`, `aws:SourceArn`).
124+
- Tighten cross-account access controls:
125+
- Remove unintended `Principal` clauses
126+
- Restrict KMS usage to known accounts
127+
- Enforce SCPs that block cross-account KMS use unless explicitly approved
128+
129+
**Long-term hardening**
130+
- Integrate object-level access logging and S3 server access logging into security monitoring.
131+
- Add AWS Config rules (or Security Hub controls) detecting:
132+
- Public buckets
133+
- Cross-account access to S3
134+
- KMS policies permitting foreign principals
135+
- Document required cross-account workflows and add explicit allowlists.
136+
137+
### Additional information
138+
139+
- **[AWS IR Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/)**
140+
- **[AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/tree/a8c7b313636b406a375952ac00b2d68e89a991f2/docs)**
141+
- **Security Best Practices:** [AWS Knowledge Center – Security Best Practices](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/).
60142
"""
61143
references = [
62144
"https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html/",
@@ -66,7 +148,7 @@ references = [
66148
]
67149
risk_score = 47
68150
rule_id = "ab8f074c-5565-4bc4-991c-d49770e19fc9"
69-
setup = "AWS S3 data event types need to be enabled in the CloudTrail trail configuration."
151+
setup = "AWS S3 data event types need to be enabled in the CloudTrail trail configuration for CopyObject events."
70152
severity = "medium"
71153
tags = [
72154
"Domain: Cloud",
@@ -101,13 +183,25 @@ from logs-aws.cloudtrail-* metadata _id, _version, _index
101183
// keep ECS and dissected fields
102184
| keep
103185
@timestamp,
186+
data_stream.namespace,
187+
user.name,
188+
user_agent.original,
189+
source.ip,
104190
aws.cloudtrail.user_identity.arn,
105-
cloud.account.id,
191+
aws.cloudtrail.user_identity.type,
192+
aws.cloudtrail.user_identity.access_key_id,
193+
aws.cloudtrail.resources.arn,
194+
aws.cloudtrail.resources.type,
106195
event.action,
196+
event.outcome,
197+
cloud.account.id,
198+
cloud.region,
199+
aws.cloudtrail.request_parameters,
200+
aws.cloudtrail.response_elements,
107201
Esql.aws_cloudtrail_request_parameters_target_bucket_name,
202+
Esql.aws_cloudtrail_request_parameters_target_object_key,
108203
Esql.aws_cloudtrail_request_parameters_kms_key_account_id,
109-
Esql.aws_cloudtrail_request_parameters_kms_key_id,
110-
Esql.aws_cloudtrail_request_parameters_target_object_key
204+
Esql.aws_cloudtrail_request_parameters_kms_key_id
111205
'''
112206

113207

@@ -124,3 +218,26 @@ id = "TA0040"
124218
name = "Impact"
125219
reference = "https://attack.mitre.org/tactics/TA0040/"
126220

221+
[rule.investigation_fields]
222+
field_names = [
223+
"@timestamp",
224+
"user.name",
225+
"user_agent.original",
226+
"source.ip",
227+
"aws.cloudtrail.user_identity.arn",
228+
"aws.cloudtrail.user_identity.type",
229+
"aws.cloudtrail.user_identity.access_key_id",
230+
"aws.cloudtrail.resources.arn",
231+
"aws.cloudtrail.resources.type",
232+
"event.action",
233+
"event.outcome",
234+
"cloud.account.id",
235+
"cloud.region",
236+
"aws.cloudtrail.request_parameters",
237+
"aws.cloudtrail.response_elements",
238+
"Esql.aws_cloudtrail_request_parameters_target_bucket_name",
239+
"Esql.aws_cloudtrail_request_parameters_target_object_key",
240+
"Esql.aws_cloudtrail_request_parameters_kms_key_account_id",
241+
"Esql.aws_cloudtrail_request_parameters_kms_key_id",
242+
]
243+

0 commit comments

Comments
 (0)