Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the “Bucket Should Not Allow Global Access” misconfiguration for GCP using GCP console, follow these steps:
  1. Go to the GCP console and select the project that contains the bucket with global access.
  2. Navigate to the Cloud Storage section of the console.
  3. Find the bucket that is allowing global access and click on its name to open its details page.
  4. Click on the “Permissions” tab.
  5. Scroll down to the “Public access prevention” section and click on the “Edit” button.
  6. In the “Public access prevention” window, select the “Enforced by Bucket Policy” option.
  7. Click on the “Save” button to apply the changes.
  8. Next, click on the “Bucket Policy” tab.
  9. In the bucket policy editor, enter the following JSON code to deny all public access to the bucket:
  1. Click on the “Save” button to apply the policy.
After following these steps, the bucket will no longer allow global access and all public access will be denied.

To remediate the bucket should not allow global access misconfiguration in GCP using GCP CLI, follow these steps:
  1. Open the Google Cloud Console and navigate to the Cloud Shell.
  2. Run the following command to list all the buckets in your project:
  3. Identify the bucket that has global access enabled.
  4. Run the following command to remove the public access from the bucket:
    Replace [BUCKET_NAME] with the name of the bucket that you identified in step 3.
  5. Run the following command to verify that the public access has been removed:
    This command will display the IAM policy for the bucket. Verify that the “allUsers” entity no longer has the “roles/storage.objectViewer” role.
  6. Repeat steps 3 to 5 for all the buckets in your project that have global access enabled.
By following these steps, you can remediate the bucket should not allow global access misconfiguration in GCP using GCP CLI.
To remediate the “Bucket Should Not Allow Global Access” misconfiguration in GCP using Python, you can follow the below steps:Step 1: Install and import the required libraries
Step 2: Authenticate with GCP using service account credentials
Step 3: Get the bucket object that you want to remediate
Step 4: Set the bucket’s IAM policy to deny all public access
Step 5: Verify that the bucket’s IAM policy has been updated to deny all public access
By following these steps, you can remediate the “Bucket Should Not Allow Global Access” misconfiguration in GCP using Python.
Changing IAM bindings does not force replacement of the bucket resource; it updates access in place.To remediate an existing bucket that already has public access, make sure you either:
  • Remove the old binding that contains allUsers / allAuthenticatedUsers from Terraform, or
  • Replace that binding’s members list so it no longer contains those values and instead lists specific principals as above.
Verification: terraform plan should show the members lists on google_storage_bucket_iam_binding resources changing to remove allUsers / allAuthenticatedUsers (or those bindings being destroyed), with the bucket itself left unchanged.