# ##################################### ## Gherkin ## ##################################### # Rule Identifier: # S3_BUCKET_SSL_REQUESTS_ONLY # # Description: # Checks if Amazon S3 buckets have policies that require requests to use Secure Socket Layer (SSL). # # Reports on: # AWS::S3::BucketPolicy # # Evaluates: # AWS CloudFormation # # Rule Parameters: # NA # # Scenarios: # a) SKIP: when there are no S3 Bucket Policy Document resource present # b) PASS: when all S3 Bucket Policy Document set to deny if condition SecureTransport not true # c) FAIL: when all S3 Bucket Policy Document does not have deny on insecure transport actions # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_SSL_REQUESTS_ONLY # # Select all S3 resources from incoming template (payload) # let s3_buckets_policies_ssl_requests_only = Resources.*[ Type == 'AWS::S3::BucketPolicy' Metadata.guard.SuppressedRules not exists or Metadata.guard.SuppressedRules.* != "S3_BUCKET_SSL_REQUESTS_ONLY" ] # Select secure S3 Bucket Policy resources from incoming template let ssl_secure_bucket_policies = %s3_buckets_policies_ssl_requests_only[ Properties.PolicyDocument { some Statement[*] { Effect == 'Deny' Condition { Bool.'aws:SecureTransport' == false } } } ] rule S3_BUCKET_SSL_REQUESTS_ONLY when %s3_buckets_policies_ssl_requests_only !empty { %ssl_secure_bucket_policies !empty << Violation: Bucket policies must feature a statement to enforce TLS usage. Fix: Set a bucket policy statement to '"Action":"s3:*","Effect":"Deny","Principal":"*","Resource":"*","Condition":{"Bool":{"aws:SecureTransport":false}}' . >> }