Skip to content

Commit

Permalink
fix: more secure traffic policy (#782)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeet <68876606+jn1119@users.noreply.github.com>
  • Loading branch information
maghirardelli and jn1119 authored Oct 29, 2021
1 parent 6398830 commit 9264b6a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ Resources:
VersioningConfiguration:
Status: Enabled

LogBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref LogBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: Deny requests that do not use TLS/HTTPS
Effect: Deny
Principal: '*'
Action: s3:*
Resource:
- !Join ['/', [!GetAtt LogBucket.Arn, '*']]
- !GetAtt LogBucket.Arn
Condition:
Bool:
aws:SecureTransport: false

MasterSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
Expand Down
46 changes: 40 additions & 6 deletions main/solution/backend/config/infra/cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,13 @@ Resources:
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: Deny requests that do not use TLS
- Sid: Deny requests that do not use TLS/HTTPS
Effect: Deny
Principal: '*'
Action: s3:*
Resource: !Join ['/', [!GetAtt ExternalCfnTemplatesBucket.Arn, '*']]
Resource:
- !Join ['/', [!GetAtt ExternalCfnTemplatesBucket.Arn, '*']]
- !GetAtt ExternalCfnTemplatesBucket.Arn
Condition:
Bool:
aws:SecureTransport: false
Expand Down Expand Up @@ -269,11 +271,13 @@ Resources:
Version: '2012-10-17'
Id: PutObjectPolicy
Statement:
- Sid: Deny requests that do not use TLS
- Sid: Deny requests that do not use TLS/HTTPS
Effect: Deny
Principal: '*'
Action: s3:*
Resource: !Join ['/', [!GetAtt EnvTypeConfigsBucket.Arn, '*']]
Resource:
- !Join ['/', [!GetAtt EnvTypeConfigsBucket.Arn, '*']]
- !GetAtt EnvTypeConfigsBucket.Arn
Condition:
Bool:
aws:SecureTransport: false
Expand Down Expand Up @@ -420,11 +424,13 @@ Resources:
Version: '2012-10-17'
Id: PutObjectPolicy
Statement:
- Sid: Deny requests that do not use TLS
- Sid: Deny requests that do not use TLS/HTTPS
Effect: Deny
Principal: '*'
Action: s3:*
Resource: !Join ['/', [!GetAtt EgressStoreBucket.Arn, '*']]
Resource:
- !Join ['/', [!GetAtt EgressStoreBucket.Arn, '*']]
- !GetAtt EgressStoreBucket.Arn
Condition:
Bool:
aws:SecureTransport: false
Expand All @@ -437,6 +443,34 @@ Resources:
StringNotEquals:
s3:signatureversion: 'AWS4-HMAC-SHA256'

EgressNotificationBucketPolicy:
Condition: EnableEgressStore
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref EgressNotificationBucket
PolicyDocument:
Version: '2012-10-17'
Id: PutObjectPolicy
Statement:
- Sid: Deny requests that do not use TLS/HTTPS
Effect: Deny
Principal: '*'
Action: s3:*
Resource:
- !Join ['/', [!GetAtt EgressNotificationBucket.Arn, '*']]
- !GetAtt EgressNotificationBucket.Arn
Condition:
Bool:
aws:SecureTransport: false
- Sid: Deny requests that do not use SigV4
Effect: Deny
Principal: '*'
Action: s3:*
Resource: !Join ['/', [!GetAtt EgressNotificationBucket.Arn, '*']]
Condition:
StringNotEquals:
s3:signatureversion: 'AWS4-HMAC-SHA256'

# =============================================================================================
# IAM Roles
# =============================================================================================
Expand Down
12 changes: 8 additions & 4 deletions main/solution/infrastructure/config/infra/cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ Resources:
Bucket: !Ref LoggingBucket
PolicyDocument:
Statement:
- Sid: Deny requests that do not use TLS
- Sid: Deny requests that do not use TLS/HTTPS
Effect: Deny
Principal: '*'
Action: s3:*
Resource: !Join ['/', [!GetAtt LoggingBucket.Arn, '*']]
Resource:
- !Join ['/', [!GetAtt LoggingBucket.Arn, '*']]
- !GetAtt LoggingBucket.Arn
Condition:
Bool:
aws:SecureTransport: false
Expand Down Expand Up @@ -85,11 +87,13 @@ Resources:
AWS: !Join ['', ['arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ', !Ref 'CloudFrontOAI']]
Resource:
- !Join ['', ['arn:aws:s3:::', !Ref 'WebsiteBucket', '/*']]
- Sid: Deny requests that do not use TLS
- Sid: Deny requests that do not use TLS/HTTPS
Effect: Deny
Principal: '*'
Action: s3:*
Resource: !Join ['/', [!GetAtt WebsiteBucket.Arn, '*']]
Resource:
- !Join ['/', [!GetAtt WebsiteBucket.Arn, '*']]
- !GetAtt WebsiteBucket.Arn
Condition:
Bool:
aws:SecureTransport: false
Expand Down

0 comments on commit 9264b6a

Please sign in to comment.