mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-11 15:25:10 +00:00
53 lines
2.9 KiB
Bash
53 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Prowler - the handy cloud security tool (c) by Toni de la Fuente
|
|
#
|
|
# This Prowler check is licensed under a
|
|
# Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
#
|
|
# You should have received a copy of the license along with this
|
|
# work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
|
#
|
|
# Remediation:
|
|
#
|
|
# https://d1.awsstatic.com/whitepapers/compliance/AWS_CIS_Foundations_Benchmark.pdf
|
|
#
|
|
# aws logs put-metric-filter \
|
|
# --region us-east-1 \
|
|
# --log-group-name CloudTrail/CloudWatchLogGroup \
|
|
# --filter-name S3BucketConfigChanges \
|
|
# --filter-pattern '{ ($.eventSource = s3.amazonaws.com) && (($.eventName = PutBucketAcl) || ($.eventName = PutBucketPolicy) || ($.eventName = PutBucketCors) || ($.eventName = PutBucketLifecycle) || ($.eventName = PutBucketReplication) || ($.eventName = DeleteBucketPolicy) || ($.eventName = DeleteBucketCors) || ($.eventName = DeleteBucketLifecycle) || ($.eventName = DeleteBucketReplication)) }' \
|
|
# --metric-transformations metricName=S3BucketEventCount,metricNamespace=CloudTrailMetrics,metricValue=1
|
|
#
|
|
# aws cloudwatch put-metric-alarm \
|
|
# --region us-east-1 \
|
|
# --alarm-name S3BucketConfigChangesAlarm \
|
|
# --alarm-description "Triggered by AWS S3 Bucket config changes." \
|
|
# --metric-name S3BucketEventCount \
|
|
# --namespace CloudTrailMetrics \
|
|
# --statistic Sum \
|
|
# --comparison-operator GreaterThanOrEqualToThreshold \
|
|
# --evaluation-periods 1 \
|
|
# --period 300 \
|
|
# --threshold 1 \
|
|
# --actions-enabled \
|
|
# --alarm-actions arn:aws:sns:us-east-1:123456789012:CloudWatchAlarmTopic
|
|
|
|
CHECK_ID_check38="3.8"
|
|
CHECK_TITLE_check38="[check38] Ensure a log metric filter and alarm exist for S3 bucket policy changes (Scored)"
|
|
CHECK_SCORED_check38="SCORED"
|
|
CHECK_TYPE_check38="LEVEL1"
|
|
CHECK_SEVERITY_check38="Medium"
|
|
CHECK_ASFF_TYPE_check38="Software and Configuration Checks/Industry and Regulatory Standards/CIS AWS Foundations Benchmark"
|
|
CHECK_ASFF_RESOURCE_TYPE_check38="AwsCloudTrailTrail"
|
|
CHECK_ALTERNATE_check308="check38"
|
|
CHECK_SERVICENAME_check38="s3"
|
|
CHECK_RISK_check38='Monitoring unauthorized API calls will help reveal application errors and may reduce time to detect malicious activity.'
|
|
CHECK_REMEDIATION_check38='It is recommended that a metric filter and alarm be established for unauthorized requests.'
|
|
CHECK_DOC_check38='https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html'
|
|
CHECK_CAF_EPIC_check38='Logging and Monitoring'
|
|
|
|
check38(){
|
|
check3x '\$\.eventSource\s*=\s*s3.amazonaws.com.+\$\.eventName\s*=\s*PutBucketAcl.+\$\.eventName\s*=\s*PutBucketPolicy.+\$\.eventName\s*=\s*PutBucketCors.+\$\.eventName\s*=\s*PutBucketLifecycle.+\$\.eventName\s*=\s*PutBucketReplication.+\$\.eventName\s*=\s*DeleteBucketPolicy.+\$\.eventName\s*=\s*DeleteBucketCors.+\$\.eventName\s*=\s*DeleteBucketLifecycle.+\$\.eventName\s*=\s*DeleteBucketReplication'
|
|
}
|