Skip to content

Commit

Permalink
Allow blocking use of SSE-C encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
ab77 committed Jan 21, 2025
1 parent 07addfc commit ad9ea79
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions state/s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Parameters:
Type: String
Default: true
AllowedValues: [true, false, 'false-but-was-true']
RestrictCustomerKeys:
Description: 'Block the use of SSE-C encryption (https://aws.amazon.com/blogs/security/preventing-unintended-encryption-of-amazon-s3-objects/).'
Type: String
Default: true
AllowedValues: [true, false]
NoncurrentVersionExpirationInDays:
Description: 'Remove noncurrent object versions after days (set to 0 to disable).'
Type: Number
Expand Down Expand Up @@ -161,6 +166,7 @@ Conditions:
HasBlockPublicAccess: !Not [!Or [!Condition HasPublicReadAccess, !Condition HasPublicWriteAccess]]
HasPermissionsBoundary: !Not [!Equals [!Ref PermissionsBoundary, '']]
HasBucketOwnerPreferred: !Or [!Condition HasCloudFrontAccessLogWrite, !Condition HasS3AccessLogWrite, !Not [!Condition HasBlockPublicAccess]]
HasRestrictCustomerKeys: !Equals [!Ref RestrictCustomerKeys, 'true']
Resources:
Bucket: # cannot be deleted with data
Type: 'AWS::S3::Bucket'
Expand Down Expand Up @@ -208,6 +214,17 @@ Resources:
Condition:
Bool:
'aws:SecureTransport': false
- !If
- HasRestrictCustomerKeys
- Principal: '*'
Sid: 'RestrictSSECObjectUploads'
Action: 's3:PutObject'
Effect: Deny
Resource: !Sub '${Bucket.Arn}/*'
Condition:
Null:
's3:x-amz-server-side-encryption-customer-algorithm': 'false'
- !Ref 'AWS::NoValue'
- !If
- HasPrivateAccessAndKmsKey
- Principal: '*'
Expand Down

0 comments on commit ad9ea79

Please sign in to comment.