Skip to main content

More Info:

Ensure that BigQuery Audit Logging is configured properly across all projects.

Risk Level

Medium

Address

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
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “GCP BigQuery Should Have Audit Logging Enabled” for GCP using GCP console, you can follow the below steps:
  1. Open the Google Cloud Console and select the project where BigQuery is enabled.
  2. Go to the Navigation menu and select “BigQuery”.
  3. In the BigQuery console, click on the “More” button (three dots) on the left-hand side and select “View in APIs Explorer”.
  4. In the APIs Explorer, search for “tables.insert” in the search bar.
  5. In the “tables.insert” API, scroll down to the “Request body” section and add the following JSON code:
  1. Click on the “Authorize and execute” button.
  2. On the next screen, click on the “Execute” button.
  3. Go back to the BigQuery console and click on the “More” button (three dots) on the left-hand side.
  4. Select “Audit logs” and ensure that the logs are enabled.
By following these steps, you will remediate the misconfiguration “GCP BigQuery Should Have Audit Logging Enabled” for GCP using GCP console.

To remediate the misconfiguration of GCP BigQuery not having audit logging enabled, follow these steps using GCP CLI:
  1. Open the Cloud Shell in your GCP console.
  2. Run the following command to verify if audit logging is enabled for BigQuery:
If you see any results, it means audit logging is already enabled. If not, proceed to the next step.
  1. Run the following command to enable audit logging for BigQuery:
Note: Replace <project-id> with your GCP project ID.
  1. Run the following command to verify if the sink was created successfully:
  1. Run the following command to grant the necessary permissions to the sink:
  1. Run the following command to create a dataset in BigQuery to store the audit logs:
Note: Replace <dataset-name> with the desired name for your dataset.
  1. Run the following command to create a table in the dataset to store the audit logs:
Note: Replace <dataset-name> and <table-name> with the desired names for your dataset and table.
  1. Run the following command to create a sink to export the audit logs to the BigQuery table:
Note: Replace <project-id>, <dataset-name> and <table-name> with the names you used in steps 6 and 7.
  1. Run the following command to verify if the sink was created successfully:
After following these steps, audit logging will be enabled for BigQuery in your GCP project, and the audit logs will be exported to the BigQuery table you created.
To remediate the misconfiguration “GCP BigQuery should have audit logging enabled” for GCP using Python, follow the below steps:
  1. Install the Google Cloud SDK and authenticate using the following command:
  1. Install the necessary Python libraries:
  1. Create a Python script with the following code:
  1. Replace my_dataset with the ID of the dataset you want to enable audit logging for.
  2. Run the script using the following command:
This will enable audit logging for the specified dataset in GCP BigQuery.
BigQuery audit logging is not configured on individual datasets/tables in Terraform; it is enabled at the project (or organization/folder) IAM audit config level as shown above.This change is non-destructive and does not force replacement of any BigQuery datasets or tables.For verification, terraform plan should show creation (or update) of a google_project_iam_audit_config resource with service = "bigquery.googleapis.com" and the three audit_log_config blocks for ADMIN_READ, DATA_READ, and DATA_WRITE.

Additional Reading: