Skip to main content

More Info:

Ensure that Google Cloud Platform - Detailed Audit Logging Mode policy is enforced at the organization level in order to enable Detailed Audit Logging feature for the supported Cloud Storage resources available within your GCP organization.

Risk Level

Medium

Address

Operational Maturity, Reliability, Security

Compliance Standards

  • CIS GCP
  • Cloudanix Best Practice
  • GDPR
  • HIPAA
  • ISO 27001
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration of not enforcing detailed audit logging mode in GCP, you can follow the steps below using the GCP console:
  1. Log in to your Google Cloud Console.
  2. Navigate to the “Logging” page by clicking on the hamburger menu on the top left corner of the page and selecting “Logging” under the “TOOLS” section.
  3. Click on “Log Router” on the left-hand side of the page.
  4. Click on “Create Sink” at the top of the page.
  5. In the “Create Sink” page, enter a name for the sink in the “Name” field.
  6. In the “Sink Service” field, select the service you want to enable detailed audit logging for. For example, you can select “Cloud Storage”.
  7. In the “Sink Destination” field, select “BigQuery” or “Cloud Pub/Sub” as the destination for the logs.
  8. In the “Sink Filter” field, enter the filter expression to specify the logs you want to collect. For example, you can enter “protoPayload.serviceName=storage.googleapis.com” to collect logs related to Cloud Storage.
  9. Click on “Create Sink” to create the sink.
  10. Repeat steps 4 to 9 for each service you want to enable detailed audit logging for.
By following these steps, you will have enabled detailed audit logging mode for the selected GCP services and can now monitor and analyze the logs for security and compliance purposes.

To remediate the misconfiguration “Enforce Detailed Audit Logging Mode” for GCP using GCP CLI, follow these steps:
  1. Open the Cloud Shell in the GCP Console.
  2. Run the following command to enable audit logging for all services in the current project:
Note: Replace [PROJECT_ID] with the ID of your GCP project and [USER_EMAIL] with the email address of the user who should be exempted from audit logging.
  1. Run the following command to verify that audit logging is enabled:
This command should return the configuration details for audit logging.
  1. Run the following command to enable enforced audit logging mode:
This command will enable enforced audit logging mode for all services in the current project.
  1. Run the following command to verify that enforced audit logging mode is enabled:
This command should return the configuration details for enforced audit logging mode.
  1. Verify that audit logs are being generated for all services in the project by checking the audit logs in the Logging console.
By following these steps, you will remediate the misconfiguration “Enforce Detailed Audit Logging Mode” for GCP using GCP CLI.
To remediate the misconfiguration “Enforce Detailed Audit Logging Mode” in GCP using Python, you can follow the below steps:Step 1: Install the necessary packages
Step 2: Set the project ID and the log sink name
Step 3: Create a client object for the Logging API
Step 4: Create a sink filter to include all audit logs
Step 5: Create a sink object with the filter and destination
Step 6: Create or update the sink in the project
Step 7: Verify that the sink is created and that audit logs are being exported
This will create or update the sink in the project and start exporting all audit logs to BigQuery. You can verify that the sink is created and that audit logs are being exported by checking the output of the list_sinks method.
This updates policy in place and does not force replacement of other GCP resources; it may change logging behavior for Cloud Storage across the organization.Verification: terraform plan should show creation or update of google_org_policy_policy.detailed_audit_logging_mode with spec.rules[0].enforce set to true.