GCP Introduction
GCP Pricing
GCP Threats
GCP Misconfigurations
- Getting Started with GCP Audit
- CloudSql Audit
- Cloud Tasks Monitoring
- Dataflow Monitoring
- Function Monitoring
- Monitoring Compliance
- PubSubLite Monitoring
- Spanner Monitoring
- NoSQL Monitoring
- Compute Audit
- IAM Audit
- BigQuery Monitoring
- CDN Monitoring
- DNS Monitoring
- KMS Monitoring
- Kubernetes Audit
- Load Balancer Monitoring
- Log Monitoring
- Storage Audit
- Pub/Sub Monitoring
- VPC Audit
- IAM Deep Dive
GCP Threats
Storage Permissions Change Log Alerts Should Be Enabled
More Info:
Ensures that logging and log alerts exist for storage permission changes. Storage permissions include access to the buckets that store the logs, any changes in storage permissions should be heavily monitored to prevent unauthorized changes.
Risk Level
Medium
Address
Security
Compliance Standards
CISGCP, CBP, HIPAA, ISO27001, HITRUST
Triage and Remediation
Remediation
To remediate the misconfiguration “Storage Permissions Change Log Alerts Should Be Enabled” for GCP using GCP console, follow the below steps:
-
Open the Google Cloud Console and select the project for which you want to enable storage permissions change log alerts.
-
Navigate to the Cloud Storage page and select the bucket for which you want to enable the alerts.
-
Click on the “Edit Bucket Details” button to open the bucket details page.
-
Scroll down to the “Advanced Settings” section and click on the “Edit Bucket Permissions” button.
-
In the “Bucket Permissions” window, click on the “Add Member” button.
-
In the “Add members” window, enter the email address of the user or group that you want to receive the alerts.
-
In the “Select a role” dropdown menu, select the “Storage Object Admin” role.
-
Click on the “Save” button to add the member with the selected role.
-
Now, click on the “Add Notification” button in the “Advanced Settings” section.
-
In the “Add Notification” window, select the “Object Change” event type.
-
In the “Filter” section, select the “All object changes” option.
-
In the “Delivery” section, select the “Email” option and enter the email address of the user or group that you added in step 6.
-
Click on the “Save” button to save the notification.
-
Repeat steps 9 to 13 for each user or group that you want to receive the alerts.
-
Once you have added all the necessary members and notifications, click on the “Save” button to save the changes.
By following these steps, you have successfully enabled storage permissions change log alerts for the selected bucket in GCP.
To remediate the misconfiguration “Storage Permissions Change Log Alerts Should Be Enabled” for GCP using GCP CLI, you can follow the below steps:
- Open the GCP CLI terminal and authenticate with your GCP account using the following command:
gcloud auth login
- Check whether the Stackdriver Logging API is enabled or not using the following command:
If the Stackdriver Logging API is not enabled, then enable it using the following command:
gcloud services list --enabled | grep logging.googleapis.com
gcloud services enable logging.googleapis.com
- Create a sink to export logs to Cloud Pub/Sub using the following command:
Replace the
gcloud logging sinks create [SINK_NAME] pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_NAME] --log-filter='resource.type="gcs_bucket" AND protoPayload.methodName="storage.buckets.update" AND protoPayload.request.updateMask.fieldPaths="iamConfiguration" AND protoPayload.response.iamConfiguration' --include-children
[SINK_NAME]
with a name for the sink,[PROJECT_ID]
with the ID of the GCP project, and[TOPIC_NAME]
with the name of the Cloud Pub/Sub topic to export the logs to. - Grant the Cloud Pub/Sub Publisher role to the service account used by the sink using the following command:
Replace the
gcloud projects add-iam-policy-binding [PROJECT_ID] --member=serviceAccount:[SINK_SERVICE_ACCOUNT] --role=roles/pubsub.publisher
[PROJECT_ID]
with the ID of the GCP project and[SINK_SERVICE_ACCOUNT]
with the email address of the service account used by the sink. - Enable the sink using the following command:
Replace the
gcloud logging sinks update [SINK_NAME] --destination=pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_NAME] --include-children
[SINK_NAME]
with the name of the sink,[PROJECT_ID]
with the ID of the GCP project, and[TOPIC_NAME]
with the name of the Cloud Pub/Sub topic to export the logs to.
With the above steps, you have successfully remediated the misconfiguration “Storage Permissions Change Log Alerts Should Be Enabled” for GCP using GCP CLI.
To remediate the misconfiguration “Storage Permissions Change Log Alerts Should Be Enabled” for GCP using Python, you can follow these steps:
- Import the necessary libraries:
from google.cloud import logging_v2
from google.cloud.logging_v2 import enums
from google.cloud.logging_v2.resource import Resource
- Set up the client:
client = logging_v2.LoggingServiceV2Client()
- Define the project ID:
project_id = 'your-project-id'
- Define the log sink:
log_sink = 'storage-permissions-change-log-alerts'
- Define the log filter:
log_filter = 'logName:"cloudaudit.googleapis.com%2Factivity" AND protoPayload.methodName:"storage.buckets.update" AND protoPayload.serviceName:"storage.googleapis.com"'
- Define the log sink destination:
log_sink_destination = f"storage.googleapis.com/{log_sink}"
- Define the log sink configuration:
sink_config = {
"name": log_sink,
"destination": log_sink_destination,
"filter": log_filter,
"output_version_format": enums.LogSink.VersionFormat.V2
}
- Define the log sink resource:
project_resource = Resource(type="project", labels={"project_id": project_id})
- Create the log sink:
response = client.create_sink(project_resource.project_id, sink_config)
- Verify that the log sink was created successfully:
if response.name == f"projects/{project_id}/sinks/{log_sink}":
print(f"Log sink {log_sink} created successfully.")
else:
print(f"Failed to create log sink {log_sink}.")
These steps will enable the storage permissions change log alerts for GCP using Python.