Open
Description
What is the problem?
The rule https://github.com/aws-cloudformation/aws-guard-rules-registry/blob/main/rules/aws/amazon_s3/s3_bucket_ssl_requests_only.guard is overly permissive.
Following the main points:
- The rule checks only for Effect==Deny and Condition Bool.'aws:SecureTransport' == false. It should also be checking for all the attributes specified in the error message: Fix: Set a bucket policy statement to '"Action":"s3:","Effect":"Deny","Principal":"","Resource":"*","Condition":{"Bool":{"aws:SecureTransport":false}}'
- When evaluating a Deny statement, evaluating a single Condition key is not enough. The reason for that is if there is a second condition the statement might not be evaluated to true
- "*" it's not a valid Resource for S3 Bucket
Reproduction Steps
Example below specifying an Action in the Deny to force a no match rule. The same applies for Principal, Resource.
- name: S3 Bucket Policy statement only allows requests to use Secure Socket Layer (SSL), FAIL
input:
Resources:
ExampleS3:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref rLogsBucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Principal: "*"
Action: "s3:AbortMultipartUpload"
Effect: "Deny"
Condition:
Bool:
"aws:SecureTransport": false
Resource: "*"
expectations:
rules:
S3_BUCKET_SSL_REQUESTS_ONLY: FAIL
Example below specifying an additional Condition so the statement returns false
- name: S3 Bucket Policy statement only allows requests to use Secure Socket Layer (SSL), FAIL
input:
Resources:
ExampleS3:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref rLogsBucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Principal: "*"
Action: "s3:*"
Effect: "Deny"
Condition:
Bool:
"aws:SecureTransport": false
StringEquals:
"aws:PrincipalAccount": "123456789012"
Resource: "*"
expectations:
rules:
S3_BUCKET_SSL_REQUESTS_ONLY: FAIL
What did you expect to happen?
I expected the rule to provide the intended guardrail for all scenarios.
What actually happened?
The rule is overly permissive, it does not provide its main objective.
CloudFormation Guard Version
2.1.3
OS
Amazon Linux
OS Version
No response
Other information
The rule should have additional assertions to cover the possible scenarios.