Overview
It is recommended that a metric filter and alarm be established for SQL Instance configuration changes.
Rationale
Monitoring changes to Sql Instance configuration changes may reduce time to detect and correct misconfigurations done on sql server.
Below are the few of configurable Options which may impact security posture of a SQL Instance:
- Enable auto backups and high availability: Misconfiguration may adversely impact Business continuity, Disaster Recovery and High Availability
- Authorize networks : Misconfiguration may increase exposure to the untrusted networks
Impact
Enabling of logging may result in your project being charged for the additional logs usage. These charges could be significant depending on the size of the organization.
Remediation guidance
From Google Cloud Console
Create the Log Metric
- Go to
Logging,Log-based Metricsby visiting https://console.cloud.google.com/logs/metrics - Select
Create metric - For
Metric Type, selectCounter - Under
Details, add a name and set theUnitsto1 - Under
Filter selection, add the following query:
protoPayload.methodName="cloudsql.instances.update"
- Click
Create Metric. This will take toLogging/Logsat https://console.cloud.google.com/logs/metrics?
Create the alert policy
- Go back to
Log-based Metricsand identify the newly created metric underUser-defined metrics - Click the 3-dot icon in rightmost column of that metric to open menu options and select
Create alert from Metric - Fill in the required details. Choose the alerting threshold and configuration that makes sense for the organization. For example, a threshold of zero(0) for the most recent value ensures that a notification is triggered for every owner change in the project:
Set `Aggregator` to `Count`
Set `Configuration`:
- Condition: above
- Threshold: 0
- For: most recent value
- Under
Configure notifications, configure the desired notification channels - Name the policy and select
CREATE POLICY
Using Google Cloud CLI
Create prescribed Log Metric
- Use command: gcloud logging metrics create
- Reference for Command Usage: https://docs.cloud.google.com/sdk/gcloud/reference/logging/metrics/create
Create prescribed Alert Policy
- Use command: gcloud monitoring policies create
- Reference for command Usage: https://docs.cloud.google.com/sdk/gcloud/reference/monitoring/policies/create
References
- https://cloud.google.com/logging/docs/logs-based-metrics/
- https://cloud.google.com/monitoring/custom-metrics/
- https://cloud.google.com/monitoring/alerts/
- https://cloud.google.com/logging/docs/reference/tools/gcloud-logging
- https://cloud.google.com/storage/docs/access-control/iam
- https://docs.cloud.google.com/sdk/gcloud/reference/logging/metrics/create
- https://docs.cloud.google.com/sdk/gcloud/reference/monitoring/policies/create
Service-wide remediation
Recommended when many resources are affected: fix the platform baseline first so new resources inherit the secure setting, then remediate the existing flagged resources in batches.
Google Cloud
Use organization or folder policies where available, shared project templates, logs and alerting baselines, and IaC modules so new resources inherit the secure setting.
Operational rollout
- Fix the baseline first at the account, subscription, project, cluster, or tenant scope that owns this control.
- Remediate the currently affected resources in batches, starting with internet-exposed and production assets.
- Re-scan and track approved exceptions with an owner and expiry date.
Query logic
These are the stored checks tied to this control.
Log metric filter and alerts exist for SQL instance configuration changes
Connectors
Covered asset types
Expected check: eq []
GCPLogging11{...AssetFragment}
Google Cloud