S3 bucket versioning is disabled Affecting S3 service in AWS


Severity

0.0
medium
0
10
Severity Framework
Snyk CCSS
Rule category
General/ Storage

Is your environment affected by this misconfiguration?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
Frameworks
CIS-ControlsCSA-CCMISO-27001NIST-800-53PCI-DSSSOC-2
  • Snyk IDSNYK-CC-00023
  • creditSnyk Research Team

Description

By enabling object versioning, data is protected from overwrites and deletions.

How to fix?

Set the aws_s3_bucket versioning block enabled field to true.

  • Ensure that an aws_s3_bucket versioning block sets the field enabled to true.
  • If you're using a version greater or equal to version 4.0 of the AWS provider, you can now use the aws_s3_bucket_versioning resource to provide versioning. Ensure that the versioning_configuration block sets the field status to Enabled.

Example Configuration

# Example < v4.0.0
resource "aws_s3_bucket" "example" {
  bucket = "example"
  versioning {
    enabled = true
  }
}

# Example >= v4.0.0
resource "aws_s3_bucket" "example2" {
  bucket = "example2"
}

resource "aws_s3_bucket_versioning" "example" {
  bucket = aws_s3_bucket.example2.id
  versioning_configuration {
    status = "Enabled"
  }
}