AWS Introduction
AWS Pricing
AWS Threats
AWS Misconfigurations
- Getting Started with AWS Audit
- Permissions required for Misconfigurations Detection
- API Gateway Audit
- Cloudformation Audit
- CloudFront Audit
- CloudTrail Audit
- Cloudwatch Audit
- DynamoDB Audit
- EC2 Audit
- Elastic Search Audit
- ELB Audit
- IAM Audit
- KMS Audit
- Kubernetes Audit
- Lambda Audit
- RDS Audit
- Redshift Audit
- Route53 Audit
- S3 Audit
- Security Groups Audit
- SES Audit
- SNS Audit
- IAM Deep Dive
- App Sync Audit
- Code Build Audit
- Open Search Audit
- Shield Audit
- SQS Audit
CloudTrail Must Log Data Events
More Info:
Your AWS CloudTrail trails should be configured to log Data events in order to record S3 object-level API operations, such as GetObject, DeleteObject and PutObject.
Risk Level
Low
Address
Security
Compliance Standards
HIPAA, SOC2, GDPR, NIST, ISO27001, AWSWAF
Triage and Remediation
Remediation
To remediate the CloudTrail Must Log Data Events misconfiguration for AWS using the AWS console, follow these steps:
- Log in to the AWS Management Console.
- Navigate to the CloudTrail service.
- Select the trail that is not logging data events.
- Click on the “Edit” button.
- Scroll down to the “Data events” section.
- Click on the “Add data event” button.
- Select the AWS service(s) that you want to log data events for.
- Select the specific data events that you want to log.
- Click on the “Save” button to save the changes.
After completing these steps, CloudTrail will be configured to log data events for the selected AWS service(s) and specific data events.
To remediate the CloudTrail must log data events misconfiguration for AWS using AWS CLI, you can follow the below steps:
-
Open the AWS CLI on your local machine or EC2 instance.
-
Run the following command to check if CloudTrail is enabled:
aws cloudtrail describe-trails
-
If CloudTrail is not enabled, run the following command to create a trail:
aws cloudtrail create-trail --name <trail-name> --s3-bucket-name <bucket-name> --is-multi-region-trail
Replace
<trail-name>
with a name for your trail and<bucket-name>
with the name of the S3 bucket where you want to store the log files. -
Run the following command to update the trail to log data events:
aws cloudtrail update-trail --name <trail-name> --include-global-service-events --is-multi-region-trail
This command updates the trail to include global service events and enables multi-region logging.
-
Run the following command to start logging data events:
aws cloudtrail start-logging --name <trail-name>
This command starts logging data events to the specified trail.
-
Verify that data events are being logged by checking the S3 bucket for log files.
By following these steps, you can remediate the CloudTrail must log data events misconfiguration for AWS using AWS CLI.
To remediate the misconfiguration “CloudTrail Must Log Data Events” in AWS using Python, you can follow the below steps:
- Import the necessary libraries:
import boto3
- Create a boto3 client for CloudTrail:
client = boto3.client('cloudtrail')
- Get the current CloudTrail configuration:
response = client.get_trail(Name='my-trail')
- Check if data events logging is enabled:
if not response['Trail']['IsMultiRegionTrail'] or not response['Trail']['IncludeGlobalServiceEvents'] or not response['Trail']['IsLogging']:
# Data events logging is not enabled
- Update the CloudTrail configuration to enable data events logging:
response = client.update_trail(
Name='my-trail',
IncludeGlobalServiceEvents=True,
IsMultiRegionTrail=True,
IsLogging=True,
S3BucketName='my-bucket',
S3KeyPrefix='my-prefix'
)
- Verify that data events logging is enabled:
response = client.get_trail(Name='my-trail')
if response['Trail']['IsMultiRegionTrail'] and response['Trail']['IncludeGlobalServiceEvents'] and response['Trail']['IsLogging']:
# Data events logging is enabled
- Optionally, you can also create a CloudWatch alarm to monitor the CloudTrail logs for specific events:
cloudwatch = boto3.client('cloudwatch')
response = cloudwatch.put_metric_alarm(
AlarmName='my-alarm',
AlarmDescription='My alarm description',
MetricName='NumberOfErrors',
Namespace='AWS/CloudTrail',
Statistic='Sum',
Period=300,
EvaluationPeriods=1,
Threshold=1,
ComparisonOperator='GreaterThanThreshold',
AlarmActions=[
'arn:aws:sns:us-east-1:123456789012:my-topic'
],
Dimensions=[
{
'Name': 'TrailName',
'Value': 'my-trail'
}
]
)
By following these steps, you can remediate the “CloudTrail Must Log Data Events” misconfiguration in AWS using Python.