You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* [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
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.
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."
75
123
severity = "low"
76
124
tags = [
77
125
"Domain: Cloud",
@@ -83,12 +131,13 @@ tags = [
83
131
"Resources: Investigation Guide",
84
132
]
85
133
timestamp_override = "event.ingested"
86
-
type = "query"
134
+
type = "eql"
87
135
88
136
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=")
0 commit comments