More Info:
Ensures that logging and log alerts exist for firewall rule changes.Risk Level
MediumAddress
SecurityCompliance Standards
HIPAATriage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate VPC Firewall Rule Logging for a GCP network using the GCP Console, you generally need to enable logging on each relevant firewall rule.
1. Go to the Firewall rules page
- Sign in to the Google Cloud Console: https://console.cloud.google.com
- Make sure the correct project is selected (top bar).
- In the left-hand menu, go to:
VPC network → Firewall
2. Identify the firewall rule(s)
- In the Firewall rules list, locate the rule(s) for the target VPC network.
- Use filters at the top if needed (e.g., filter by Network or Direction).
3. Edit the firewall rule to enable logging
For each rule that needs logging:- Click the name of the firewall rule.
- Click Edit (top bar).
- Scroll down to the Logs section.
- Set Logs to On.
- Optionally, set:
- Metadata:
- Include all metadata (more detail, more cost)
- or Exclude all metadata (less detail, less cost).
- Sample rate (if visible in your UI): choose 1.0 for all packets or a lower fraction (e.g., 0.1 for 10%).
- Metadata:
- Click Save at the bottom.
4. Verify logging is active
- Go to Logging → Logs Explorer.
- In the Query Builder, choose:
- Resource type: GCE Firewall Rule or GCE VM Instance (depending on what you want to inspect).
- Run the query and confirm you see firewall logs generated when traffic hits that rule.
5. Repeat for all required rules
Repeat steps 3–4 for all firewall rules in the VPC network that must have logging enabled to meet your policy or compliance requirement.Using CLI
Using CLI
In GCP, firewall logging is configured per firewall rule, not per VPC as a whole. To “remediate” the misconfiguration, you need to enable logging on the relevant firewall rules using
Replace:
This:
Other allowed values:
You should see:
These commands remediate the “VPC Firewall Rule Logging disabled” finding by ensuring firewall rule logging is enabled for the required rules on your GCP VPC network.
gcloud.Below are the minimal, practical steps.1. Identify the firewall rules for the VPC network
<VPC-NETWORK-NAME>with your VPC name.
logConfig.enable:True→ logging already enabledFalseor empty → needs remediation
2. Enable logging on a specific firewall rule
- Enables logging for allowed and denied connections
- Uses default metadata logging (
INCLUDE_ALL_METADATAin most projects)
3. (Optional) Control how much metadata is logged
If you want to explicitly control metadata:EXCLUDE_ALL_METADATA– log only minimal info
4. Bulk enable logging for all rules in a VPC (shell loop)
5. Verify logging is enabled
These commands remediate the “VPC Firewall Rule Logging disabled” finding by ensuring firewall rule logging is enabled for the required rules on your GCP VPC network.
Using Python
Using Python
Below are the concrete steps and example Python code to enable VPC firewall rule logging on GCP.
1. Prerequisites
-
Enable APIs
- Ensure
Compute Engine APIis enabled in your project.
- Ensure
-
Install libraries
-
Authentication
- Use a service account with
compute.securityAdminorcompute.networkAdminrole. - Set:
- Use a service account with
2. Key API Concepts
- Firewall rules are per project and network.
- You enable logging per firewall rule using the
logConfigfield. - Operation: use
firewalls().patch()orfirewalls().update().
logConfig example:3. Python: Enable logging on a specific firewall rule
4. Python: Enable logging on all firewall rules in a project
5. Summary of remediation steps
- Identify firewall rules without logging (
logConfig.enableisfalseor absent). - For each such rule, set:
logConfig.enable = true- Optionally choose
metadataasINCLUDE_ALL_METADATAorEXCLUDE_ALL_METADATA.
- Use
firewalls().patch()with the updated firewall body. - Optionally automate this across all rules (second script).
Using Terraform
Using Terraform
After editing,
terraform plan should show an in-place update (~ update in-place) on google_compute_firewall.vpc_firewall_rule adding the log_config block.
