Skip to content

Commit 21edd18

Browse files
committed
[Rule Tunings] AWS EC2 EBS Snapshot and Encryption Rules
AWS EC2 Encryption Disabled rule performance is good, telemetry looks low as expected - additional context to description to emphasize the security concern and purpose of the rule - updated investigation guide - added highlighted fields - reduced execution window AWS EC2 EBS Snapshot Access Removed rule alerts as expected, telemetry volume is low as expected. however, this rule can be accomplished using EQL so I've changed the rule type - changed rule type to eql - added index - updated IG - added highlighted fields note: I have to use `any` for the query since there is no `event.category` defined for `event.action: ModifySnapshotAttribute` AWS EC2 EBS Snapshot Shared or Made Public Converted to EQL. As an ESQL rule the primary benefit was being able to definitely exclude instances where a user adds their own account id when calling the ModifySnapshotAttribute instead of an external account id. This is a redundant action as the snapshot when created is automatically shared with the account it's created in. But this could be a false positive if it's done by mistake. Instead of keeping this as an ESQL rule, I still think there is more value to converting this to EQL for both customer alert context and telemetry. When looking at production data, I saw no instances where the owning account id was added in this way. Its a rare mistake that shouldn't happen often enough to support keeping this as an ESQL rule. - converted to EQL - added index - updated IG - updated description - added highlighted fields
1 parent fd64bc4 commit 21edd18

File tree

3 files changed

+233
-135
lines changed

3 files changed

+233
-135
lines changed

rules/integrations/aws/exfiltration_ec2_ebs_snapshot_shared_with_another_account.toml

Lines changed: 80 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,89 @@
22
creation_date = "2024/04/16"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/07/16"
5+
updated_date = "2025/10/16"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Identifies AWS EC2 EBS snaphots being shared with another AWS account or made public. EBS virtual disks can be copied
11-
into snapshots, which can then be shared with an external AWS account or made public. Adversaries may attempt this in
12-
order to copy the snapshot into an environment they control, to access the data.
10+
Detects when an Amazon Elastic Block Store (EBS) snapshot is shared with another AWS account or made public. EBS
11+
snapshots contain copies of data volumes that may include sensitive or regulated information. Adversaries may exploit
12+
ModifySnapshotAttribute to share snapshots with external accounts or the public, allowing them to copy and access data
13+
in an environment they control. This activity often precedes data exfiltration or persistence operations, where the
14+
attacker transfers stolen data out of the victim account or prepares a staging area for further exploitation.
1315
"""
1416
false_positives = [
1517
"""
1618
AMI sharing is a common practice in AWS environments. Ensure that the sharing is authorized before taking action.
1719
""",
1820
]
1921
from = "now-6m"
20-
interval = "5m"
21-
language = "esql"
22+
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
23+
language = "eql"
2224
license = "Elastic License v2"
2325
name = "AWS EC2 EBS Snapshot Shared or Made Public"
2426
note = """## Triage and analysis
2527
28+
> **Disclaimer**:
29+
> 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.
30+
2631
### Investigating AWS EC2 EBS Snapshot Shared or Made Public
2732
28-
This rule detects when an AWS EC2 EBS snapshot is shared with another AWS account or made public. EBS virtual disks can be copied into snapshots, which can then be shared with an external AWS account or made public. Adversaries may attempt this to copy the snapshot into an environment they control to access the data. Understanding the context and legitimacy of such changes is crucial to determine if the action is benign or malicious.
33+
This rule detects when an Amazon Elastic Block Store (EBS) snapshot is shared with another AWS account or made public. EBS snapshots store copies of data volumes that may contain sensitive or regulated information. Adversaries may exploit the `ModifySnapshotAttribute` API to share these snapshots externally, allowing them to copy and access the data in an environment they control. This activity is commonly associated with data exfiltration or persistence techniques, where attackers transfer data outside the victim account or prepare backups they can later retrieve. Public sharing (`group=all`) represents a severe data exposure risk, as it makes the snapshot globally readable.
2934
3035
#### Possible Investigation Steps:
3136
32-
- **Identify the Actor**: Review the `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.access_key_id` fields to identify who made the change. Verify if this actor typically performs such actions and if they have the necessary permissions.
33-
- **Review the Request Details**: Examine the `aws.cloudtrail.request_parameters` to understand the specific changes made to the snapshot permissions. Look for any unusual parameters that could suggest unauthorized or malicious modifications.
34-
- **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.
35-
- **Contextualize with Timestamp**: Use the `@timestamp` field to check when the change occurred. Modifications during non-business hours or outside regular maintenance windows might require further scrutiny.
36-
- **Correlate with Other Activities**: Search for related CloudTrail events before and after this change to see if the same actor or IP address engaged in other potentially suspicious activities.
37-
- **Review UserID**: Check the `userId` field to identify the AWS account with which the snapshot was shared. Verify if this account is authorized to access the data or if it belongs to a known third party. If this value is `all`, the snapshot is made public.
37+
- **Identify who performed the action**: Review `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.access_key_id` to identify who modified the snapshot’s permissions. Evaluate whether this identity is authorized to share EBS snapshots (check IAM policies for `ec2:ModifySnapshotAttribute`).
38+
- **Analyze the source of the request**: Examine `source.ip` and `source.geo` fields to determine the geographical origin of the request. An unfamiliar or external location may indicate compromised credentials or unauthorized access. Review `user_agent.original` to confirm whether the request originated from an expected administrative tool or host.
39+
- **Examine the scope of the change**:
40+
- Review `aws.cloudtrail.request_parameters` to determine which AWS account(s) were added to the `createVolumePermission` list.
41+
- If the account ID matches the snapshot owner’s account, this is redundant and typically non-malicious.
42+
- If another account ID or `group=all` appears, verify whether the target is an approved AWS Organization account or an external party.
43+
- Cross-check the affected `snapshotId` in the AWS console or via CLI (`describe-snapshot-attribute`) to confirm current sharing status.
44+
- Identify whether other snapshots or AMIs were shared in the same timeframe.
45+
- **Correlate with other activities**:
46+
- Search CloudTrail for related events involving the same actor or `source.ip`.
47+
- Look for `CreateSnapshot`, `CopySnapshot`, `ExportImage`, or `PutBucketAcl` events that could indicate broader exfiltration or replication behavior.
48+
- Correlate with detections such as `EBS Snapshot Access Removed` or `EBS Encryption Disabled`, which may signal a coordinated campaign involving both exfiltration and impact.
49+
- Check GuardDuty and Security Hub for findings related to data exposure, cross-account sharing, or unauthorized data transfer.
50+
- **Evaluate timing and intent**: Compare `@timestamp` against scheduled maintenance or approved change windows. Actions performed outside business hours or without documented change tickets should be prioritized for review.
3851
3952
### False Positive Analysis:
4053
41-
- **Legitimate Administrative Actions**: Confirm if the snapshot sharing aligns with scheduled updates, development activities, or legitimate administrative tasks documented in change management systems.
42-
- **Consistency Check**: Compare the action against historical data of similar actions performed by the user or within the organization. If the action is consistent with past legitimate activities, it might indicate a false alarm.
43-
- **Verify through Outcomes**: Check the `aws.cloudtrail.response_elements` and the `event.outcome` to confirm if the change was successful and intended according to policy.
44-
45-
### Response and Remediation:
54+
- **Authorized internal sharing**: Confirm if the snapshot sharing was part of an approved workflow, such as internal replication or migration between AWS Organization accounts.
55+
- **Automated replication or tooling**: Infrastructure-as-code or backup automation may temporarily share snapshots for cross-region or cross-account transfers. Verify automation identifiers, source IPs, and tags.
56+
- **Self-account addition**: Adding the owner’s own account ID to `createVolumePermission` has no operational impact and can be safely ignored.
4657
47-
- **Immediate Review and Reversal if Necessary**: If the change was unauthorized, update the snapshot permissions to remove any unauthorized accounts and restore it to its previous state.
48-
- **Enhance Monitoring and Alerts**: Adjust monitoring systems to alert on similar actions, especially those involving sensitive data or permissions.
49-
- **Educate and Train**: Provide additional training to users with administrative rights on the importance of security best practices concerning snapshot management and sharing permissions.
50-
- **Audit Snapshots and Policies**: Conduct a comprehensive audit of all snapshots and associated policies to ensure they adhere to the principle of least privilege.
51-
- **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.
58+
If verified as legitimate, document the event under change management and reconcile it against organizational policies for snapshot sharing.
5259
53-
### Additional Information:
60+
### Response and Remediation:
5461
55-
For further guidance on managing EBS snapshots and securing AWS environments, refer to the [AWS EBS documentation](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-modifying-snapshot-permissions.html) and AWS best practices for security. Additionally, consult the following resources for specific details on EBS snapshot security:
56-
- [AWS EBS Snapshot Permissions](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-modifying-snapshot-permissions.html)
57-
- [AWS API ModifySnapshotAttribute](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifySnapshotAttribute.html)
58-
- [AWS EBS Snapshot Dump](https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-ebs-snapshot-dump)
62+
**1. Containment and validation**
63+
- If unauthorized, immediately remove added permissions using the AWS CLI:
64+
`aws ec2 modify-snapshot-attribute --snapshot-id <id> --create-volume-permission "Remove=[{UserId=<unauthorized_id>}]"`
65+
- Revoke public sharing (`group=all`) to prevent external access.
66+
- Restrict `ec2:ModifySnapshotAttribute` permissions to trusted administrative roles only.
67+
**2. Investigate for data exfiltration or persistence**
68+
- Determine whether the shared snapshot was copied to another account (`CopySnapshot`).
69+
- Engage AWS Support if evidence suggests external copying or data theft.
70+
- Review subsequent API calls or IAM changes for further persistence or data movement.
71+
**3. Strengthen detection and monitoring**
72+
- Enable AWS Config rules such as `ebs-snapshot-public-restorable-check`.
73+
- Implement continuous monitoring for `ModifySnapshotAttribute` and `CopySnapshot` operations.
74+
- Correlate future detections by actor, access key, and source IP to identify repeated or automated exfiltration attempts.
75+
**4. Recovery and hardening**
76+
- Enable default encryption and validate that all snapshots remain private.
77+
- Apply Service Control Policies (SCPs) to prevent public snapshot sharing organization-wide.
78+
- Audit existing snapshots to ensure no others have unauthorized permissions.
79+
- Implement least-privilege IAM principles and enforce multi-factor authentication (MFA) for administrative accounts.
80+
81+
### Additional information
82+
83+
- **[AWS Incident Response Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/)**: reference playbooks for investigating data exfiltration and unauthorized access.
84+
- **[AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/)**: example framework for developing custom playbooks for snapshot configuration and data protection.
85+
- **AWS Documentation**
86+
- [EBS Snapshot Permissions](https://docs.aws.amazon.com/ebs/latest/userguide/ebs-modifying-snapshot-permissions.html)
87+
- [ModifySnapshotAttribute API Reference](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifySnapshotAttribute.html)
5988
"""
6089
references = [
6190
"https://docs.aws.amazon.com/ebs/latest/userguide/ebs-modifying-snapshot-permissions.html",
@@ -76,35 +105,15 @@ tags = [
76105
"Resources: Investigation Guide",
77106
]
78107
timestamp_override = "event.ingested"
79-
type = "esql"
108+
type = "eql"
80109

81110
query = '''
82-
from logs-aws.cloudtrail-* metadata _id, _version, _index
83-
| where
84-
event.provider == "ec2.amazonaws.com"
111+
any where event.dataset == "aws.cloudtrail"
112+
and event.provider == "ec2.amazonaws.com"
85113
and event.action == "ModifySnapshotAttribute"
86114
and event.outcome == "success"
87-
88-
// Extract snapshotId, attribute type, operation type, and userId
89-
| dissect aws.cloudtrail.request_parameters
90-
"{%{?snapshotId}=%{Esql.aws_cloudtrail_request_parameters_snapshot_id},%{?attributeType}=%{Esql.aws_cloudtrail_request_parameters_attribute_type},%{?createVolumePermission}={%{Esql.aws_cloudtrail_request_parameters_operation_type}={%{?items}=[{%{?userId}=%{Esql_priv.aws_cloudtrail_request_parameters_user_id}}]}}}"
91-
92-
// Check for snapshot permission added for another AWS account
93-
| where
94-
Esql.aws_cloudtrail_request_parameters_operation_type == "add"
95-
and cloud.account.id != Esql_priv.aws_cloudtrail_request_parameters_user_id
96-
97-
// keep ECS and derived fields
98-
| keep
99-
@timestamp,
100-
aws.cloudtrail.user_identity.arn,
101-
cloud.account.id,
102-
event.action,
103-
Esql.aws_cloudtrail_request_parameters_snapshot_id,
104-
Esql.aws_cloudtrail_request_parameters_attribute_type,
105-
Esql.aws_cloudtrail_request_parameters_operation_type,
106-
Esql_priv.aws_cloudtrail_request_parameters_user_id,
107-
source.ip
115+
and stringContains (aws.cloudtrail.request_parameters, "attributeType=CREATE_VOLUME_PERMISSION")
116+
and stringContains (aws.cloudtrail.request_parameters, "add={items")
108117
'''
109118

110119

@@ -121,3 +130,21 @@ id = "TA0010"
121130
name = "Exfiltration"
122131
reference = "https://attack.mitre.org/tactics/TA0010/"
123132

133+
[rule.investigation_fields]
134+
field_names = [
135+
"@timestamp",
136+
"user.name",
137+
"user_agent.original",
138+
"source.ip",
139+
"aws.cloudtrail.user_identity.arn",
140+
"aws.cloudtrail.user_identity.type",
141+
"aws.cloudtrail.user_identity.access_key_id",
142+
"target.entity.id",
143+
"event.action",
144+
"event.outcome",
145+
"cloud.account.id",
146+
"cloud.region",
147+
"aws.cloudtrail.request_parameters",
148+
"aws.cloudtrail.response_elements",
149+
]
150+

0 commit comments

Comments
 (0)