Bucket Versioning Should Be Enabled
More Info:
Ensures object versioning is enabled on storage buckets. Object versioning can help protect against the overwriting of objects or data loss in the event of a compromise.
Risk Level
Low
Address
Operational Maturity, Reliability, Security
Compliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- DPDPA
- Digital Operational Resilience Act (EU)
- Essential 8
- HITRUST CSF
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST CSF
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- PCI
- Reserve Bank of India (RBI) Cyber Security Framework
- Reserve Bank of India (RBI) Master Direction – Information Technology Framework
- SOC2
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
To remediate the "Bucket Versioning Should Be Enabled" misconfiguration in GCP using GCP console, follow these steps:
-
Go to the GCP console and select the project where the misconfigured bucket is located.
-
In the top navigation bar, click on the "Storage" option.
-
Click on the name of the bucket that needs to be remediated.
-
In the left-hand menu, click on the "Versions" option.
-
Click on the "Enable versioning" button.
-
A pop-up window will appear asking you to confirm that you want to enable versioning. Click on the "Enable" button.
-
Once versioning is enabled, you will see a message confirming that versioning has been enabled for the bucket.
-
You can now exit the GCP console.
By following these steps, you will have successfully remediated the misconfiguration "Bucket Versioning Should Be Enabled" for the specified bucket in GCP using GCP console.
Using CLI
To remediate the bucket versioning misconfiguration in GCP using GCP CLI, you can follow the below steps:
- Open Cloud Shell from the GCP console.
- Run the following command to enable versioning for a specific bucket:
gsutil versioning set on gs://[BUCKET_NAME]
Note: Replace [BUCKET_NAME] with the name of the bucket you want to enable versioning for.
- Verify that versioning is enabled for the bucket by running the following command:
gsutil versioning get gs://[BUCKET_NAME]
Note: Replace [BUCKET_NAME] with the name of the bucket you enabled versioning for.
- The output of the above command should show "Enabled: True" indicating that versioning has been enabled for the bucket.
By following these steps, you can remediate the misconfiguration of bucket versioning not being enabled in GCP using GCP CLI.
Using Python
To remediate the "Bucket Versioning Should Be Enabled" misconfiguration in GCP using Python, you can follow these steps:
- Install the
google-cloud-storagelibrary using pip:
pip install google-cloud-storage
- Import the necessary modules:
from google.cloud import storage
- Initialize the client object:
client = storage.Client()
- Get the bucket object:
bucket = client.get_bucket('bucket-name')
- Enable versioning for the bucket:
bucket.versioning_enabled = True
bucket.patch()
- Verify that versioning is enabled:
bucket.reload()
print(bucket.versioning_enabled)
This will enable versioning for the specified GCP bucket and ensure that all objects uploaded to the bucket have a unique version ID.
Using Terraform
resource "google_storage_bucket" "TARGET_BUCKET" {
name = "YOUR_BUCKET_NAME" # replace with the exact bucket name
location = "YOUR_BUCKET_LOCATION" # e.g. "US", "EU", "us-central1"
versioning {
enabled = true
}
# include any other existing arguments for this bucket here
}
Enabling versioning.enabled = true on an existing google_storage_bucket does not force bucket replacement; it is an in‑place change.
To verify, terraform plan should show an in-place update (~ update in-place) for google_storage_bucket.TARGET_BUCKET with versioning.enabled changing from false (or null) to true.