Description
New S3 uploads use the bucket's default encryption unless the request selects another method. Check the encryption mode and key on the object itself.
Potential impact
A request that explicitly selects SSE-S3 can miss an organizational KMS requirement even when the bucket defaults to KMS. Older objects keep the encryption they had when written.
Remediation
Use AES256 for SSE-S3 or aws:kms with the required key. Enforce mandatory encryption with a bucket policy and restrict object reads, public access and KMS use. When copying older unencrypted objects, verify retained versions and test read access.
Examples
Supply a globally unique bucket name and the local index.html file. The bucket in both examples has versioning enabled.
Use bucket default encryption
resource "aws_s3_bucket" "artifact_bucket" {
bucket = "examplebuckettftest"
versioning {
enabled = true
}
}
resource "aws_s3_bucket_object" "artifact_file" {
key = "someobject"
bucket = aws_s3_bucket.artifact_bucket.id
source = "index.html"
}
Omitting server_side_encryption uses the bucket's default for this upload.
Explicitly request SSE-S3
resource "aws_s3_bucket" "artifact_bucket" {
bucket = "examplebuckettftest"
versioning {
enabled = true
}
}
resource "aws_s3_bucket_object" "artifact_file" {
key = "someobject"
bucket = aws_s3_bucket.artifact_bucket.id
source = "index.html"
server_side_encryption = "AES256"
}
server_side_encryption = "AES256" requests SSE-S3 for this upload, including on a bucket with a KMS default if its policy permits it.