Changes to VPC firewall rules should raise an alert
This check looks at whether a logs-based metric and an alerting policy exist that fire when a VPC firewall rule is created, changed or deleted. The safe setting is a metric on firewall rule changes in Cloud Logging with an alert that notifies the people responsible for the network.
Why it matters
Firewall rules decide what traffic can reach your virtual machines and services. A change that opens a port to the whole internet can expose a system within minutes, and the change might come from a mistake or from an attacker who has taken over an account. If nobody is told when firewall rules change, the exposure can last for weeks.
Google Cloud records these changes in the Admin Activity audit logs, and you can turn them into a metric and an alert. See Logs-based metrics overview and Create alerting policies in the Google Cloud documentation.
How to check it yourself
Portal path: Google Cloud console → Logging → Logs-based metrics, and look for a metric whose filter covers firewall rule changes. Then Monitoring → Alerting, and open the policy that uses that metric to confirm it has a notification channel.
Read-only commands:
# List log-based metrics in the project and show their filters
gcloud logging metrics list --project=PROJECT_ID --format="table(name, filter)"
# Look at one metric in detail
gcloud logging metrics describe METRIC_NAME --project=PROJECT_IDThe setting is in place when a metric filters on firewall rule creation, update and deletion events and an enabled alerting policy is attached to it. Repeat for every project in scope.
How to fix it
Portal steps: in Logs-based metrics choose Create metric, type Counter, and use a filter such as the one below. Then, in Monitoring → Alerting, create a policy on that metric that fires when the count is above zero and points at a notification channel your network or security team reads.
resource.type="gce_firewall_rule"
AND (protoPayload.methodName:"firewalls.insert"
OR protoPayload.methodName:"firewalls.patch"
OR protoPayload.methodName:"firewalls.update"
OR protoPayload.methodName:"firewalls.delete")Scripted alternative for the metric. It creates a new metric in your project, so review it first; ConfigCobra itself never changes your Google Cloud and only reads it:
gcloud logging metrics create firewall-rule-changes \
--project=PROJECT_ID \
--description="VPC firewall rule created, changed or deleted" \
--log-filter='resource.type="gce_firewall_rule" AND (protoPayload.methodName:"firewalls.insert" OR protoPayload.methodName:"firewalls.patch" OR protoPayload.methodName:"firewalls.update" OR protoPayload.methodName:"firewalls.delete")'Create the alerting policy in the console and attach a notification channel.
What changes when you fix it
Nothing in your running workloads changes: a metric and an alert only observe the logs. The people affected are the ones who receive the notifications, so decide who that is and what they should do when an alert arrives.
Expect alerts whenever your own team or your infrastructure-as-code pipeline updates a firewall rule. That can be noisy at first, so agree on change windows or add a note to each change so the receiver can tell expected changes from surprises. Logs-based metrics and alert notifications can carry costs in Google Cloud; check the current billing documentation for your project before rolling this out to every project.
Included in
| Benchmark | CIS ID | Profile |
|---|---|---|
| CIS Google Cloud Platform Foundation v5.0.0 | 2.8 | Level 2 |
More checks in Logging and Monitoring
- Configure Cloud Audit Logging across all services and usersCIS 2.1
- Enable Workspace/Cloud Identity data sharing for admin audit loggingCIS 2.2
- Configure sinks to export copies of all log entriesCIS 2.3
- Apply Bucket Lock retention policies to log-export storage bucketsCIS 2.4
- Alert on project-ownership assignments/changes via log metric filterCIS 2.5
Go further
- Logging and Monitoring17 controls in this section
- CIS Google Cloud Platform Foundation v5.0.093 controls
- CIS Google Cloud Platform Foundation checklistEvery control in one list, as CSV
- RemediationSee what a fix changes in your tenant before you apply it, then use the generated script
- Monitoring & DriftScheduled scans, drift detection and email alerts when a control regresses
Check this on your Google Cloud
ConfigCobra runs this check with every other control of the CIS Google Cloud Platform Foundation Benchmark, read-only.