Skip to content

Commit 70ee55d

Browse files
authored
[Rule Tuning] AWS S3 Bucket Expiration Lifecycle Configuration Added (#5251)
* [Rule Tuning] AWS S3 Bucket Expiration Lifecycle Configuration Added AWS S3 Bucket Expiration Lifecycle Configuration Added - changed rule type to EQL so as not to use the double wildcard - used `event.type` as event category override field because `event.category` is not mapped for `PutBucketLifecycle` action - removed unnecessary `*LifecycleConfiguration*` check from query, this field is required for any `PutBucketLifecycle` API call so unnecessary to include in the query. - updated description and IG - reduced execution window - updated Mitre mapping - removed incorrect setup notes - added highlighted fields * fixing Mitre mapping error * adding IG disclaimer
1 parent cc5387d commit 70ee55d

File tree

1 file changed

+147
-53
lines changed

1 file changed

+147
-53
lines changed

rules/integrations/aws/defense_evasion_s3_bucket_lifecycle_expiration_added.toml

Lines changed: 147 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,124 @@
22
creation_date = "2024/04/12"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2025/01/15"
5+
updated_date = "2025/10/24"
66

77
[rule]
88
author = ["Elastic"]
99
description = """
10-
Identifies an expiration lifecycle configuration added to an S3 bucket. Lifecycle configurations can be used to manage
11-
objects in a bucket, including setting expiration policies. This rule detects when a lifecycle configuration is added to
12-
an S3 bucket, which could indicate that objects in the bucket will be automatically deleted after a specified period of
13-
time. This could be used to evade detection by deleting objects that contain evidence of malicious activity.
10+
Identifies the addition of an expiration lifecycle configuration to an Amazon S3 bucket. S3 lifecycle rules can
11+
automatically delete or transition objects after a defined period. Adversaries can abuse them by configuring
12+
auto-deletion of logs, forensic evidence, or sensitive objects to cover their tracks. This rule detects the use of the
13+
PutBucketLifecycle or PutBucketLifecycleConfiguration APIs with Expiration parameters, which may indicate an attempt to
14+
automate the removal of data to hinder investigation or maintain operational secrecy after malicious activity.
1415
"""
16+
event_category_override = "event.type"
1517
false_positives = [
1618
"""
17-
Bucket components may be deleted or adjusted by a system or network administrator. Verify whether the user identity,
18-
user agent, and/or hostname should be making changes in your environment. Bucket component deletions by unfamiliar
19-
users or hosts should be investigated. If known behavior is causing false positives, it can be exempted from the
20-
rule.
19+
Legitimate administrators may add lifecycle expiration configurations to reduce storage costs or enforce retention
20+
policies. Confirm whether this change aligns with an approved data management policy or infrastructure-as-code
21+
workflow. Known lifecycle automation processes (e.g., cost-management tools, data-lifecycle governance jobs) can be
22+
safely excluded from alerting once verified.
2123
""",
2224
]
23-
from = "now-60m"
25+
from = "now-6m"
2426
index = ["filebeat-*", "logs-aws.cloudtrail*"]
25-
interval = "10m"
26-
language = "kuery"
27+
language = "eql"
2728
license = "Elastic License v2"
2829
name = "AWS S3 Bucket Expiration Lifecycle Configuration Added"
29-
note = """
30-
## Triage and analysis
30+
note = """## Triage and analysis
3131
3232
### Investigating AWS S3 Bucket Expiration Lifecycle Configuration Added
3333
34-
This rule detects when an expiration lifecycle configuration is added to an S3 bucket in AWS. Such configurations can automate the deletion of objects within a bucket after a specified period, potentially obfuscating evidence of unauthorized access or malicious activity by automatically removing logs or other data.
35-
36-
#### Detailed Investigation Steps
37-
38-
- **Review the Affected S3 Bucket**: Check the bucket details (`bucketName`) where the lifecycle configuration has been added.
39-
- Determine the contents and importance of the data stored in this bucket to assess the impact of the lifecycle policy.
40-
- **Analyze the Lifecycle Configuration**:
41-
- **Expiration Policy**: Note the `Days` parameter under `Expiration` in the lifecycle rule. This indicates how long after creation data will remain in the bucket before being automatically deleted.
42-
- **Rule ID and Status**: Review the `ID` and `Status` of the lifecycle rule to understand its operational scope and activation status.
43-
- **User Identity and Activity**:
44-
- **User Details**: Investigate the user (`user_identity.arn`) who made the change. Determine whether this user's role typically involves managing S3 bucket configurations.
45-
- **Authentication Details**: Examine the authentication method and whether the access key used (`access_key_id`) is routinely used for such configurations or if it has deviated from normal usage patterns.
46-
- **Source IP and User Agent**:
47-
- **Source IP Address**: The IP address (`source.ip`) from which the request was made can provide clues about the geographical location of the requester. Determine if this location aligns with the user’s known locations.
48-
- **User Agent**: Analyze the user agent string to understand the type of client or service that made the request, which can help identify scripted automation versus manual changes.
49-
50-
#### Possible Indicators of Compromise or Misuse
51-
52-
- **Frequent Changes**: Look for frequent modifications to lifecycle policies in the same or multiple buckets, which can indicate attempts to manipulate data retention dynamically.
53-
- **Unusual User Activity**: Activities that do not correlate with the user's typical behavior patterns, such as making changes during odd hours or from unusual locations, should be flagged for further investigation.
54-
55-
### False Positive Analysis
56-
57-
- Verify the operational requirements that might necessitate such lifecycle policies, especially in environments where data retention policies are strictly governed for compliance and cost-saving reasons.
58-
59-
### Response and Remediation
60-
61-
- **Immediate Review**: If the change was unauthorized, consider reverting the lifecycle configuration change immediately to prevent potential data loss.
62-
- **Enhance Monitoring**: Implement monitoring to alert on changes to lifecycle configurations across your S3 environments.
63-
- **User Education**: Ensure that users with access to critical resources like S3 buckets are aware of the best practices and company policies regarding data retention and security.
64-
65-
### Additional Information
66-
67-
For further guidance on managing S3 lifecycle policies and ensuring compliance with organizational data retention and security policies, refer to the AWS official documentation on [S3 Lifecycle Configuration](https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-expire-general-considerations.html).
34+
> **Disclaimer**:
35+
> 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.
36+
37+
This rule detects when a lifecycle expiration policy is added to an S3 bucket via the `PutBucketLifecycle` or `PutBucketLifecycleConfiguration` API. Note: `PutBucketLifecycleConfiguration` is the newer supported API call, however both of these API calls show up as `PutBucketLifecycle` in Cloudtrail [ref](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cloudtrail-logging-s3-info.html#cloudtrail-bucket-level-tracking).
38+
Lifecycle expiration automatically deletes objects after a defined period (`Expiration:Days`), which can be leveraged by adversaries to erase logs, exfiltration evidence, or security artifacts before detection and response teams can review them.
39+
40+
Because deletion is automated and often silent, detecting the initial configuration event is critical.
41+
42+
#### Possible investigation steps
43+
44+
**Identify the actor and execution context**
45+
46+
- **Principal and Identity Type**:
47+
Review `aws.cloudtrail.user_identity.arn`, `aws.cloudtrail.user_identity.type`, and `aws.cloudtrail.user_identity.access_key_id`.
48+
Determine if the actor is an IAM user, role, or automation service account.
49+
- Unusual: temporary credentials, federated roles, or previously inactive accounts.
50+
- **Source Information**:
51+
Review `source.ip`, `cloud.region`, and `user_agent.original` for unexpected geolocations, tool usage (CLI, SDK, automation service), or newly-observed hosts.
52+
- **Timestamp correlation**:
53+
Use `@timestamp` to check if this activity occurred during change windows or off-hours.
54+
55+
**Examine the lifecycle configuration details**
56+
- Extract details from `aws.cloudtrail.request_parameters`:
57+
- `Expiration`: Number of days until deletion (e.g., `Days=1` indicates rapid expiry).
58+
- `Prefix`: If limited to certain object paths (e.g., `/logs/`, `/tmp/`).
59+
- `Status`: `Enabled` vs. `Disabled`.
60+
- `ID` or rule name: May reveal purpose (“cleanup-test”, “delete-logs”).
61+
- Determine the affected bucket from `aws.cloudtrail.resources.arn` or `aws.cloudtrail.resources.type`.
62+
Cross-check the bucket’s purpose (e.g., log storage, data lake, analytics export, threat forensics).
63+
- High-risk if the bucket contains audit, CloudTrail, or application logs.
64+
65+
**Correlate with related AWS activity**
66+
Use AWS CloudTrail search or your SIEM to pivot for:
67+
- **Prior suspicious activity**:
68+
- `DeleteObject`, `PutBucketPolicy`, `PutBucketAcl`, or `PutBucketLogging` changes to disable visibility.
69+
- IAM changes such as `AttachUserPolicy` or `CreateAccessKey` that may have enabled this modification.
70+
- **Subsequent changes**:
71+
- `PutBucketLifecycle` events in other buckets (repeated pattern).
72+
- Rapid `DeleteObject` events or object expiration confirmations.
73+
- **Cross-account activity**:
74+
- Lifecycle rules followed by replication or cross-account copy events may indicate lateral exfiltration setup.
75+
76+
**Assess intent and risk**
77+
- Verify if the actor has a valid business case for altering object retention.
78+
- If the bucket is used for security, compliance, or audit data, treat this as potential defense evasion.
79+
- Evaluate whether the lifecycle rule removes data faster than your retention policy permits.
80+
81+
### False positive analysis
82+
83+
- **Cost optimization**: Storage teams may automate lifecycle policies to reduce cost on infrequently accessed data.
84+
- **Compliance enforcement**: Organizations implementing legal retention policies may set expiration for specific datasets.
85+
- **Automation and IaC pipelines**: Terraform or CloudFormation templates often apply `PutBucketLifecycle` during resource deployment.
86+
87+
### Response and remediation
88+
89+
**Containment and validation**
90+
1. **Revert or disable** the lifecycle configuration if it is unauthorized:
91+
- Use the AWS Console or CLI (`delete-bucket-lifecycle` or `put-bucket-lifecycle-configuration --lifecycle-configuration Disabled`).
92+
2. **Preserve evidence**:
93+
- Copy existing objects (especially logs or forensic data) before they expire.
94+
- Enable object versioning or replication to protect against loss.
95+
96+
**Investigation**
97+
3. Review CloudTrail and S3 Access Logs for the same bucket:
98+
- Identify who and what performed previous deletions.
99+
- Determine whether any objects of investigative value have already been removed.
100+
4. Search for other S3 buckets where similar lifecycle configurations were added in a short timeframe.
101+
102+
**Recovery and hardening**
103+
5. Implement guardrails:
104+
- Use AWS Config rules like `s3-bucket-lifecycle-configuration-check` to monitor lifecycle changes.
105+
- Restrict `s3:PutLifecycleConfiguration` to specific administrative roles.
106+
- Enable [S3 Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) on log or evidence buckets to enforce immutability.
107+
6. Enable Security Hub and GuardDuty findings for additional anomaly detection on S3 data management activity.
108+
109+
### Additional information
110+
111+
- **AWS Documentation**
112+
- [S3 Lifecycle Configuration](https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-expire-general-considerations.html)
113+
- [DeleteBucketLifecycle API Reference](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketLifecycle.html)
114+
- **AWS Playbooks**
115+
- [Data Exposure and Exfiltration Response](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/IRP-PersonalDataBreach.md)
116+
- [AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/tree/main)
68117
"""
69118
references = [
70119
"https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-expire-general-considerations.html",
71120
]
72121
risk_score = 21
73122
rule_id = "ff320c56-f8fa-11ee-8c44-f661ea17fbce"
74-
setup = "This rule requires S3 data events to be logged to CloudTrail. CloudTrail trails can be configured to log S3 data events in the AWS Management Console or using the AWS CLI."
75123
severity = "low"
76124
tags = [
77125
"Domain: Cloud",
@@ -83,12 +131,13 @@ tags = [
83131
"Resources: Investigation Guide",
84132
]
85133
timestamp_override = "event.ingested"
86-
type = "query"
134+
type = "eql"
87135

88136
query = '''
89-
event.dataset: "aws.cloudtrail" and event.provider: "s3.amazonaws.com" and
90-
event.action: PutBucketLifecycle and event.outcome: success and
91-
aws.cloudtrail.request_parameters: (*LifecycleConfiguration* and *Expiration=*)
137+
info where event.dataset == "aws.cloudtrail"
138+
and event.action == "PutBucketLifecycle"
139+
and event.outcome == "success"
140+
and stringContains(aws.cloudtrail.request_parameters, "Expiration=")
92141
'''
93142

94143

@@ -99,9 +148,54 @@ id = "T1070"
99148
name = "Indicator Removal"
100149
reference = "https://attack.mitre.org/techniques/T1070/"
101150

151+
[[rule.threat.technique]]
152+
id = "T1562"
153+
name = "Impair Defenses"
154+
reference = "https://attack.mitre.org/techniques/T1562/"
155+
[[rule.threat.technique.subtechnique]]
156+
id = "T1562.008"
157+
name = "Disable or Modify Cloud Logs"
158+
reference = "https://attack.mitre.org/techniques/T1562/008/"
159+
160+
102161

103162
[rule.threat.tactic]
104163
id = "TA0005"
105164
name = "Defense Evasion"
106165
reference = "https://attack.mitre.org/tactics/TA0005/"
166+
[[rule.threat]]
167+
framework = "MITRE ATT&CK"
168+
[[rule.threat.technique]]
169+
id = "T1485"
170+
name = "Data Destruction"
171+
reference = "https://attack.mitre.org/techniques/T1485/"
172+
[[rule.threat.technique.subtechnique]]
173+
id = "T1485.001"
174+
name = "Lifecycle-Triggered Deletion"
175+
reference = "https://attack.mitre.org/techniques/T1485/001/"
176+
177+
178+
179+
[rule.threat.tactic]
180+
id = "TA0040"
181+
name = "Impact"
182+
reference = "https://attack.mitre.org/tactics/TA0040/"
183+
184+
[rule.investigation_fields]
185+
field_names = [
186+
"@timestamp",
187+
"user.name",
188+
"user_agent.original",
189+
"source.ip",
190+
"aws.cloudtrail.user_identity.arn",
191+
"aws.cloudtrail.user_identity.type",
192+
"aws.cloudtrail.user_identity.access_key_id",
193+
"aws.cloudtrail.resources.arn",
194+
"aws.cloudtrail.resources.type",
195+
"event.action",
196+
"event.outcome",
197+
"cloud.account.id",
198+
"cloud.region",
199+
"aws.cloudtrail.request_parameters",
200+
]
107201

0 commit comments

Comments
 (0)