Skip to main content
Five Steps for Cloud Compliance Readiness·A practical playbook for security teamsDownload
CIS Google Cloud Platform Foundation v5.0.0 · 2.8

Changes to VPC firewall rules should raise an alert

  • Level 2
  • Logging and Monitoring

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_ID

The 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

BenchmarkCIS IDProfile
CIS Google Cloud Platform Foundation v5.0.02.8Level 2

Check this on your Google Cloud

ConfigCobra runs this check with every other control of the CIS Google Cloud Platform Foundation Benchmark, read-only.

Get in touch

Let's talk.

Whether you're evaluating ConfigCobra, running an audit, or managing a client fleet — we respond within one business day.

Free trial