[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6GYDVA6YFD3SHYGSHWFDDGP":3,"skill-same:01M6GYDVA6YFD3SHYGSHWFDDGP":85},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":50,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":53,"install":54,"resources":67},"01M6GYDVA6YFD3SHYGSHWFDDGP","implementing-gcp-vpc-firewall-rules",null,"Implementing and auditing GCP VPC firewall rules to enforce network segmentation, restrict ingress and egress traffic, apply hierarchical firewall policies across the organization, and monitor firewall rule effectiveness using VPC Flow Logs.","micsapp\u002Fmicstec-skills","micsapp","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F82411001?v=4","01M6GWCFQ6D3PV8EHNY62NN5VW","01M6GWCFVE1PA5HG0DKC7AMFJ3",4,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002F_universal\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-gcp-vpc-firewall-rules\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"implementing","gcp","firewall","vpc","Rules","implementing gcp vpc firewall rules","firewall-rules","traffic","network segmentation","across","enforce","organization","segmentation","cybersecurity","network-security","flow","network","cloud-security","logs","monitor","2026-11-10 10:12:30",false,"---\nname: implementing-gcp-vpc-firewall-rules\ndescription: >\n  Implementing and auditing GCP VPC firewall rules to enforce network segmentation,\n  restrict ingress and egress traffic, apply hierarchical firewall policies across\n  the organization, and monitor firewall rule effectiveness using VPC Flow Logs.\ndomain: cybersecurity\nsubdomain: cloud-security\ntags: [cloud-security, gcp, vpc, firewall-rules, network-security, segmentation]\nversion: \"1.0\"\nauthor: mahipal\nlicense: Apache-2.0\n---\n\n# Implementing GCP VPC Firewall Rules\n\n## When to Use\n\n- When deploying new GCP workloads that require network-level access controls\n- When auditing existing firewall configurations for overly permissive rules\n- When implementing zero trust network segmentation within GCP VPC networks\n- When responding to Security Command Center findings about open firewall rules\n- When building hierarchical firewall policies across a GCP organization\n\n**Do not use** for application-layer filtering (use Cloud Armor WAF), for DNS-based filtering (use Cloud DNS response policies), or for VPN\u002Finterconnect traffic filtering without understanding that VPC firewall rules apply to traffic within the VPC.\n\n## Prerequisites\n\n- GCP project with Compute Engine API enabled\n- IAM roles: `roles\u002Fcompute.securityAdmin` for firewall management, `roles\u002Fcompute.networkViewer` for auditing\n- Organization Admin role for hierarchical firewall policies\n- gcloud CLI authenticated with appropriate permissions\n- VPC Flow Logs enabled on target subnets for monitoring\n\n## Workflow\n\n### Step 1: Audit Existing Firewall Rules for Security Gaps\n\nEnumerate all firewall rules and identify overly permissive configurations.\n\n```bash\n# List all firewall rules in the project\ngcloud compute firewall-rules list \\\n  --format=\"table(name, network, direction, priority, allowed[].map().firewall_rule().list():label=ALLOWED, sourceRanges, targetTags)\"\n\n# Find rules allowing all traffic from 0.0.0.0\u002F0\ngcloud compute firewall-rules list \\\n  --filter=\"direction=INGRESS AND sourceRanges=0.0.0.0\u002F0\" \\\n  --format=\"table(name, network, allowed, priority, targetTags)\" \\\n  --sort-by=priority\n\n# Find rules allowing all protocols and ports\ngcloud compute firewall-rules list \\\n  --filter=\"direction=INGRESS AND allowed[].IPProtocol=all\" \\\n  --format=\"table(name, network, sourceRanges, targetTags)\"\n\n# Find rules with SSH (22) or RDP (3389) open to the internet\ngcloud compute firewall-rules list \\\n  --filter=\"direction=INGRESS AND sourceRanges=0.0.0.0\u002F0 AND (allowed[].ports=22 OR allowed[].ports=3389)\" \\\n  --format=\"table(name, network, allowed, sourceRanges)\"\n\n# Check for disabled rules\ngcloud compute firewall-rules list \\\n  --filter=\"disabled=true\" \\\n  --format=\"table(name, network, direction)\"\n```\n\n### Step 2: Create Restrictive Ingress Firewall Rules\n\nImplement least-privilege ingress rules using network tags and service accounts for targeting.\n\n```bash\n# Create rule allowing HTTPS from the internet to web servers only\ngcloud compute firewall-rules create allow-https-web \\\n  --network=production-vpc \\\n  --direction=INGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:443 \\\n  --source-ranges=0.0.0.0\u002F0 \\\n  --target-tags=web-server \\\n  --priority=1000 \\\n  --description=\"Allow HTTPS to web servers from internet\"\n\n# Create rule allowing SSH only from bastion host subnet\ngcloud compute firewall-rules create allow-ssh-bastion \\\n  --network=production-vpc \\\n  --direction=INGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:22 \\\n  --source-ranges=10.0.1.0\u002F24 \\\n  --target-tags=ssh-allowed \\\n  --priority=1000 \\\n  --description=\"Allow SSH only from bastion subnet\"\n\n# Create rule allowing internal communication between app tiers\ngcloud compute firewall-rules create allow-app-to-db \\\n  --network=production-vpc \\\n  --direction=INGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:5432 \\\n  --source-tags=app-server \\\n  --target-tags=db-server \\\n  --priority=1000 \\\n  --description=\"Allow PostgreSQL from app tier to database tier\"\n\n# Create service-account-based rule (more secure than tags)\ngcloud compute firewall-rules create allow-api-internal \\\n  --network=production-vpc \\\n  --direction=INGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:8080 \\\n  --source-service-accounts=api-client@project.iam.gserviceaccount.com \\\n  --target-service-accounts=api-server@project.iam.gserviceaccount.com \\\n  --priority=1000\n```\n\n### Step 3: Implement Egress Restrictions\n\nConfigure egress firewall rules to control outbound traffic and prevent data exfiltration.\n\n```bash\n# Deny all egress by default (low priority)\ngcloud compute firewall-rules create deny-all-egress \\\n  --network=production-vpc \\\n  --direction=EGRESS \\\n  --action=DENY \\\n  --rules=all \\\n  --destination-ranges=0.0.0.0\u002F0 \\\n  --priority=65534 \\\n  --description=\"Default deny all egress traffic\"\n\n# Allow egress to Google APIs via restricted VIP\ngcloud compute firewall-rules create allow-google-apis \\\n  --network=production-vpc \\\n  --direction=EGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:443 \\\n  --destination-ranges=199.36.153.4\u002F30 \\\n  --priority=1000 \\\n  --description=\"Allow HTTPS to Google APIs restricted VIP\"\n\n# Allow DNS resolution\ngcloud compute firewall-rules create allow-dns-egress \\\n  --network=production-vpc \\\n  --direction=EGRESS \\\n  --action=ALLOW \\\n  --rules=udp:53,tcp:53 \\\n  --destination-ranges=169.254.169.254\u002F32,8.8.8.8\u002F32,8.8.4.4\u002F32 \\\n  --priority=1000 \\\n  --description=\"Allow DNS resolution to metadata and Google DNS\"\n\n# Allow egress to specific external services\ngcloud compute firewall-rules create allow-external-apis \\\n  --network=production-vpc \\\n  --direction=EGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:443 \\\n  --destination-ranges=PARTNER_CIDR\u002F32 \\\n  --target-tags=api-client \\\n  --priority=1000\n```\n\n### Step 4: Deploy Hierarchical Firewall Policies\n\nCreate organization and folder-level firewall policies that apply across all projects.\n\n```bash\n# Create an organization-level firewall policy\ngcloud compute firewall-policies create \\\n  --organization=ORG_ID \\\n  --short-name=org-security-policy \\\n  --description=\"Organization-wide security firewall policy\"\n\n# Add rule to block known malicious IP ranges at org level\ngcloud compute firewall-policies rules create 100 \\\n  --firewall-policy=org-security-policy \\\n  --organization=ORG_ID \\\n  --direction=INGRESS \\\n  --action=deny \\\n  --src-ip-ranges=THREAT_INTEL_CIDR_1,THREAT_INTEL_CIDR_2 \\\n  --layer4-configs=all \\\n  --description=\"Block known malicious IPs organization-wide\"\n\n# Add rule to enforce HTTPS-only ingress at org level\ngcloud compute firewall-policies rules create 200 \\\n  --firewall-policy=org-security-policy \\\n  --organization=ORG_ID \\\n  --direction=INGRESS \\\n  --action=allow \\\n  --src-ip-ranges=0.0.0.0\u002F0 \\\n  --layer4-configs=tcp:443 \\\n  --description=\"Allow only HTTPS from external sources\"\n\n# Associate policy with the organization\ngcloud compute firewall-policies associations create \\\n  --firewall-policy=org-security-policy \\\n  --organization=ORG_ID\n```\n\n### Step 5: Enable VPC Flow Logs for Monitoring\n\nConfigure VPC Flow Logs to monitor traffic patterns and validate firewall rule effectiveness.\n\n```bash\n# Enable flow logs on a subnet\ngcloud compute networks subnets update production-subnet \\\n  --region=us-central1 \\\n  --enable-flow-logs \\\n  --logging-aggregation-interval=interval-5-sec \\\n  --logging-flow-sampling=1.0 \\\n  --logging-metadata=include-all\n\n# Query flow logs in Cloud Logging for denied traffic\ngcloud logging read '\n  resource.type=\"gce_subnetwork\"\n  AND jsonPayload.disposition=\"DENIED\"\n  AND timestamp>=\"2026-02-22T00:00:00Z\"\n' --limit=50 --format=json\n\n# Find traffic hitting overly permissive rules\ngcloud logging read '\n  resource.type=\"gce_subnetwork\"\n  AND jsonPayload.rule_details.reference:\"\u002Ffirewall-rules\u002Fdefault-allow-\"\n' --limit=100 --format=\"table(jsonPayload.connection.src_ip,jsonPayload.connection.dest_ip,jsonPayload.connection.dest_port)\"\n\n# Export flow logs to BigQuery for analysis\ngcloud logging sinks create vpc-flow-bq \\\n  bigquery.googleapis.com\u002Fprojects\u002FPROJECT\u002Fdatasets\u002Fvpc_flow_logs \\\n  --log-filter='resource.type=\"gce_subnetwork\"'\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| VPC Firewall Rule | Stateful network-level access control that allows or denies traffic to and from VM instances based on IP ranges, protocols, ports, and tags |\n| Hierarchical Firewall Policy | Organization or folder-level firewall policy that is evaluated before VPC-level rules and applies across all child projects |\n| Network Tag | Label applied to VM instances that determines which firewall rules apply, used for targeting ingress and egress rules |\n| Service Account Firewall Rule | Firewall rule that targets instances based on their attached service account, providing more secure targeting than mutable network tags |\n| VPC Flow Logs | Network telemetry captured at the subnet level that records traffic metadata for monitoring, forensics, and firewall rule validation |\n| Implied Rules | Default GCP firewall rules that allow egress to all destinations and deny ingress from all sources, with lowest priority (65535) |\n\n## Tools & Systems\n\n- **gcloud compute firewall-rules**: CLI commands for creating, listing, and managing VPC firewall rules in GCP\n- **Hierarchical Firewall Policies**: Organization and folder-level policies enforcing security controls across all projects\n- **VPC Flow Logs**: Subnet-level traffic logging for monitoring, troubleshooting, and validating firewall effectiveness\n- **Cloud Logging**: Query engine for analyzing VPC Flow Logs and firewall rule hit counts\n- **Security Command Center**: GCP-native security platform with findings for overly permissive firewall configurations\n\n## Common Scenarios\n\n### Scenario: Locking Down a Production VPC After Discovery of Overly Permissive Rules\n\n**Context**: A security audit reveals that the production VPC has default-allow rules permitting SSH from `0.0.0.0\u002F0` and unrestricted egress. SCC reports 14 firewall findings.\n\n**Approach**:\n1. Enumerate all existing rules with `gcloud compute firewall-rules list` and categorize by risk\n2. Enable VPC Flow Logs on all subnets to capture baseline traffic patterns for 7 days\n3. Analyze flow logs to identify legitimate traffic that needs explicit allow rules\n4. Create targeted ingress rules for each application tier (web: 443, app: 8080, db: 5432)\n5. Replace the SSH-from-anywhere rule with SSH-from-bastion-subnet-only\n6. Implement default-deny egress and add explicit allow rules for required outbound destinations\n7. Delete the overly permissive default-allow rules after verifying applications function correctly\n\n**Pitfalls**: Deleting firewall rules without understanding traffic patterns causes outages. Always enable flow logs and analyze traffic before removing rules. Network tags can be added by anyone with compute.instances.setTags permission, making them less secure than service-account-based targeting for critical rules.\n\n## Output Format\n\n```\nGCP VPC Firewall Audit Report\n================================\nProject: production-project\nVPC Network: production-vpc\nAudit Date: 2026-02-23\n\nRULE INVENTORY:\n  Total firewall rules: 34\n  Ingress rules: 22\n  Egress rules: 12\n  Disabled rules: 3\n\nCRITICAL FINDINGS:\n[FW-001] SSH Open to Internet\n  Rule: default-allow-ssh\n  Source: 0.0.0.0\u002F0 -> tcp:22\n  Target: All instances (no tags)\n  Priority: 65534\n  Remediation: Restrict to bastion subnet CIDR\n\n[FW-002] No Egress Restrictions\n  Issue: Only implied allow-all-egress rule exists\n  Risk: No controls on outbound data exfiltration\n  Remediation: Add default-deny egress and explicit allow rules\n\nREMEDIATION ACTIONS COMPLETED:\n  Rules deleted: 3 (overly permissive defaults)\n  Rules created: 8 (targeted allow rules)\n  Egress deny rule: Created at priority 65534\n  Flow logs enabled: 6 subnets\n```\n","# Implementing GCP VPC Firewall Rules\n\n## When to Use\n\n- When deploying new GCP workloads that require network-level access controls\n- When auditing existing firewall configurations for overly permissive rules\n- When implementing zero trust network segmentation within GCP VPC networks\n- When responding to Security Command Center findings about open firewall rules\n- When building hierarchical firewall policies across a GCP organization\n\n**Do not use** for application-layer filtering (use Cloud Armor WAF), for DNS-based filtering (use Cloud DNS response policies), or for VPN\u002Finterconnect traffic filtering without understanding that VPC firewall rules apply to traffic within the VPC.\n\n## Prerequisites\n\n- GCP project with Compute Engine API enabled\n- IAM roles: `roles\u002Fcompute.securityAdmin` for firewall management, `roles\u002Fcompute.networkViewer` for auditing\n- Organization Admin role for hierarchical firewall policies\n- gcloud CLI authenticated with appropriate permissions\n- VPC Flow Logs enabled on target subnets for monitoring\n\n## Workflow\n\n### Step 1: Audit Existing Firewall Rules for Security Gaps\n\nEnumerate all firewall rules and identify overly permissive configurations.\n\n```bash\n# List all firewall rules in the project\ngcloud compute firewall-rules list \\\n  --format=\"table(name, network, direction, priority, allowed[].map().firewall_rule().list():label=ALLOWED, sourceRanges, targetTags)\"\n\n# Find rules allowing all traffic from 0.0.0.0\u002F0\ngcloud compute firewall-rules list \\\n  --filter=\"direction=INGRESS AND sourceRanges=0.0.0.0\u002F0\" \\\n  --format=\"table(name, network, allowed, priority, targetTags)\" \\\n  --sort-by=priority\n\n# Find rules allowing all protocols and ports\ngcloud compute firewall-rules list \\\n  --filter=\"direction=INGRESS AND allowed[].IPProtocol=all\" \\\n  --format=\"table(name, network, sourceRanges, targetTags)\"\n\n# Find rules with SSH (22) or RDP (3389) open to the internet\ngcloud compute firewall-rules list \\\n  --filter=\"direction=INGRESS AND sourceRanges=0.0.0.0\u002F0 AND (allowed[].ports=22 OR allowed[].ports=3389)\" \\\n  --format=\"table(name, network, allowed, sourceRanges)\"\n\n# Check for disabled rules\ngcloud compute firewall-rules list \\\n  --filter=\"disabled=true\" \\\n  --format=\"table(name, network, direction)\"\n```\n\n### Step 2: Create Restrictive Ingress Firewall Rules\n\nImplement least-privilege ingress rules using network tags and service accounts for targeting.\n\n```bash\n# Create rule allowing HTTPS from the internet to web servers only\ngcloud compute firewall-rules create allow-https-web \\\n  --network=production-vpc \\\n  --direction=INGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:443 \\\n  --source-ranges=0.0.0.0\u002F0 \\\n  --target-tags=web-server \\\n  --priority=1000 \\\n  --description=\"Allow HTTPS to web servers from internet\"\n\n# Create rule allowing SSH only from bastion host subnet\ngcloud compute firewall-rules create allow-ssh-bastion \\\n  --network=production-vpc \\\n  --direction=INGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:22 \\\n  --source-ranges=10.0.1.0\u002F24 \\\n  --target-tags=ssh-allowed \\\n  --priority=1000 \\\n  --description=\"Allow SSH only from bastion subnet\"\n\n# Create rule allowing internal communication between app tiers\ngcloud compute firewall-rules create allow-app-to-db \\\n  --network=production-vpc \\\n  --direction=INGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:5432 \\\n  --source-tags=app-server \\\n  --target-tags=db-server \\\n  --priority=1000 \\\n  --description=\"Allow PostgreSQL from app tier to database tier\"\n\n# Create service-account-based rule (more secure than tags)\ngcloud compute firewall-rules create allow-api-internal \\\n  --network=production-vpc \\\n  --direction=INGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:8080 \\\n  --source-service-accounts=api-client@project.iam.gserviceaccount.com \\\n  --target-service-accounts=api-server@project.iam.gserviceaccount.com \\\n  --priority=1000\n```\n\n### Step 3: Implement Egress Restrictions\n\nConfigure egress firewall rules to control outbound traffic and prevent data exfiltration.\n\n```bash\n# Deny all egress by default (low priority)\ngcloud compute firewall-rules create deny-all-egress \\\n  --network=production-vpc \\\n  --direction=EGRESS \\\n  --action=DENY \\\n  --rules=all \\\n  --destination-ranges=0.0.0.0\u002F0 \\\n  --priority=65534 \\\n  --description=\"Default deny all egress traffic\"\n\n# Allow egress to Google APIs via restricted VIP\ngcloud compute firewall-rules create allow-google-apis \\\n  --network=production-vpc \\\n  --direction=EGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:443 \\\n  --destination-ranges=199.36.153.4\u002F30 \\\n  --priority=1000 \\\n  --description=\"Allow HTTPS to Google APIs restricted VIP\"\n\n# Allow DNS resolution\ngcloud compute firewall-rules create allow-dns-egress \\\n  --network=production-vpc \\\n  --direction=EGRESS \\\n  --action=ALLOW \\\n  --rules=udp:53,tcp:53 \\\n  --destination-ranges=169.254.169.254\u002F32,8.8.8.8\u002F32,8.8.4.4\u002F32 \\\n  --priority=1000 \\\n  --description=\"Allow DNS resolution to metadata and Google DNS\"\n\n# Allow egress to specific external services\ngcloud compute firewall-rules create allow-external-apis \\\n  --network=production-vpc \\\n  --direction=EGRESS \\\n  --action=ALLOW \\\n  --rules=tcp:443 \\\n  --destination-ranges=PARTNER_CIDR\u002F32 \\\n  --target-tags=api-client \\\n  --priority=1000\n```\n\n### Step 4: Deploy Hierarchical Firewall Policies\n\nCreate organization and folder-level firewall policies that apply across all projects.\n\n```bash\n# Create an organization-level firewall policy\ngcloud compute firewall-policies create \\\n  --organization=ORG_ID \\\n  --short-name=org-security-policy \\\n  --description=\"Organization-wide security firewall policy\"\n\n# Add rule to block known malicious IP ranges at org level\ngcloud compute firewall-policies rules create 100 \\\n  --firewall-policy=org-security-policy \\\n  --organization=ORG_ID \\\n  --direction=INGRESS \\\n  --action=deny \\\n  --src-ip-ranges=THREAT_INTEL_CIDR_1,THREAT_INTEL_CIDR_2 \\\n  --layer4-configs=all \\\n  --description=\"Block known malicious IPs organization-wide\"\n\n# Add rule to enforce HTTPS-only ingress at org level\ngcloud compute firewall-policies rules create 200 \\\n  --firewall-policy=org-security-policy \\\n  --organization=ORG_ID \\\n  --direction=INGRESS \\\n  --action=allow \\\n  --src-ip-ranges=0.0.0.0\u002F0 \\\n  --layer4-configs=tcp:443 \\\n  --description=\"Allow only HTTPS from external sources\"\n\n# Associate policy with the organization\ngcloud compute firewall-policies associations create \\\n  --firewall-policy=org-security-policy \\\n  --organization=ORG_ID\n```\n\n### Step 5: Enable VPC Flow Logs for Monitoring\n\nConfigure VPC Flow Logs to monitor traffic patterns and validate firewall rule effectiveness.\n\n```bash\n# Enable flow logs on a subnet\ngcloud compute networks subnets update production-subnet \\\n  --region=us-central1 \\\n  --enable-flow-logs \\\n  --logging-aggregation-interval=interval-5-sec \\\n  --logging-flow-sampling=1.0 \\\n  --logging-metadata=include-all\n\n# Query flow logs in Cloud Logging for denied traffic\ngcloud logging read '\n  resource.type=\"gce_subnetwork\"\n  AND jsonPayload.disposition=\"DENIED\"\n  AND timestamp>=\"2026-02-22T00:00:00Z\"\n' --limit=50 --format=json\n\n# Find traffic hitting overly permissive rules\ngcloud logging read '\n  resource.type=\"gce_subnetwork\"\n  AND jsonPayload.rule_details.reference:\"\u002Ffirewall-rules\u002Fdefault-allow-\"\n' --limit=100 --format=\"table(jsonPayload.connection.src_ip,jsonPayload.connection.dest_ip,jsonPayload.connection.dest_port)\"\n\n# Export flow logs to BigQuery for analysis\ngcloud logging sinks create vpc-flow-bq \\\n  bigquery.googleapis.com\u002Fprojects\u002FPROJECT\u002Fdatasets\u002Fvpc_flow_logs \\\n  --log-filter='resource.type=\"gce_subnetwork\"'\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| VPC Firewall Rule | Stateful network-level access control that allows or denies traffic to and from VM instances based on IP ranges, protocols, ports, and tags |\n| Hierarchical Firewall Policy | Organization or folder-level firewall policy that is evaluated before VPC-level rules and applies across all child projects |\n| Network Tag | Label applied to VM instances that determines which firewall rules apply, used for targeting ingress and egress rules |\n| Service Account Firewall Rule | Firewall rule that targets instances based on their attached service account, providing more secure targeting than mutable network tags |\n| VPC Flow Logs | Network telemetry captured at the subnet level that records traffic metadata for monitoring, forensics, and firewall rule validation |\n| Implied Rules | Default GCP firewall rules that allow egress to all destinations and deny ingress from all sources, with lowest priority (65535) |\n\n## Tools & Systems\n\n- **gcloud compute firewall-rules**: CLI commands for creating, listing, and managing VPC firewall rules in GCP\n- **Hierarchical Firewall Policies**: Organization and folder-level policies enforcing security controls across all projects\n- **VPC Flow Logs**: Subnet-level traffic logging for monitoring, troubleshooting, and validating firewall effectiveness\n- **Cloud Logging**: Query engine for analyzing VPC Flow Logs and firewall rule hit counts\n- **Security Command Center**: GCP-native security platform with findings for overly permissive firewall configurations\n\n## Common Scenarios\n\n### Scenario: Locking Down a Production VPC After Discovery of Overly Permissive Rules\n\n**Context**: A security audit reveals that the production VPC has default-allow rules permitting SSH from `0.0.0.0\u002F0` and unrestricted egress. SCC reports 14 firewall findings.\n\n**Approach**:\n1. Enumerate all existing rules with `gcloud compute firewall-rules list` and categorize by risk\n2. Enable VPC Flow Logs on all subnets to capture baseline traffic patterns for 7 days\n3. Analyze flow logs to identify legitimate traffic that needs explicit allow rules\n4. Create targeted ingress rules for each application tier (web: 443, app: 8080, db: 5432)\n5. Replace the SSH-from-anywhere rule with SSH-from-bastion-subnet-only\n6. Implement default-deny egress and add explicit allow rules for required outbound destinations\n7. Delete the overly permissive default-allow rules after verifying applications function correctly\n\n**Pitfalls**: Deleting firewall rules without understanding traffic patterns causes outages. Always enable flow logs and analyze traffic before removing rules. Network tags can be added by anyone with compute.instances.setTags permission, making them less secure than service-account-based targeting for critical rules.\n\n## Output Format\n\n```\nGCP VPC Firewall Audit Report\n================================\nProject: production-project\nVPC Network: production-vpc\nAudit Date: 2026-02-23\n\nRULE INVENTORY:\n  Total firewall rules: 34\n  Ingress rules: 22\n  Egress rules: 12\n  Disabled rules: 3\n\nCRITICAL FINDINGS:\n[FW-001] SSH Open to Internet\n  Rule: default-allow-ssh\n  Source: 0.0.0.0\u002F0 -> tcp:22\n  Target: All instances (no tags)\n  Priority: 65534\n  Remediation: Restrict to bastion subnet CIDR\n\n[FW-002] No Egress Restrictions\n  Issue: Only implied allow-all-egress rule exists\n  Risk: No controls on outbound data exfiltration\n  Remediation: Add default-deny egress and explicit allow rules\n\nREMEDIATION ACTIONS COMPLETED:\n  Rules deleted: 3 (overly permissive defaults)\n  Rules created: 8 (targeted allow rules)\n  Egress deny rule: Created at priority 65534\n  Flow logs enabled: 6 subnets\n```\n",{"name":5,"tags":43,"author":44,"domain":31,"license":14,"version":45,"subdomain":35,"description":46},[35,19,21,24,32,30],"mahipal","1.0","Implementing and auditing GCP VPC firewall rules to enforce network segmentation, restrict ingress and egress traffic, apply hierarchical firewall policies across the organization, and monitor firewall rule effectiveness using VPC Flow Logs.\n","master","3f5d983eb4ef375b749adcd6b07ec03bd82ae8a8","_universal\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-gcp-vpc-firewall-rules",0,"https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills","https:\u002F\u002Fgithub.com\u002Fmicsapp","2026-03-20 11:24:18",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add micsapp\u002Fmicstec-skills --skill implementing-gcp-vpc-firewall-rules",{"tool":60,"command":61},"bunx","bunx skills add micsapp\u002Fmicstec-skills --skill implementing-gcp-vpc-firewall-rules",{"tool":63,"command":64},"pnpm","pnpm dlx skills add micsapp\u002Fmicstec-skills --skill implementing-gcp-vpc-firewall-rules","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002F_universal\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-gcp-vpc-firewall-rules\u002FSKILL.md",true,[68,73,79],{"path":69,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002F_universal\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-gcp-vpc-firewall-rules\u002FLICENSE",{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fapi-reference.md","REFERENCE","参考文档",2365,"https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002F_universal\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-gcp-vpc-firewall-rules\u002Freferences\u002Fapi-reference.md",{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"scripts\u002Fagent.py","SCRIPT","脚本",7538,"https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002F_universal\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-gcp-vpc-firewall-rules\u002Fscripts\u002Fagent.py",[86,123,152,173,193,218],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":103,"publishedAt":38},"01M6HBTJ02FXBFG9NYEHHYAP52","azure-apim-architecture","Analyzes and explains Azure API Management architecture decisions for enterprise API marketplace implementations using VNet Internal mode, Front Door, hybrid authentication, and multi-environment strategies. Use when discussing APIM component selection, network topology, cost optimization, or comparing alternatives like workspaces vs instances, VNet Internal vs External mode, or Front Door vs Application Gateway.","MIT","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fcopilot-agent-skills\u002F.github\u002Fskills\u002Fazure-apim-architecture\u002FSKILL.md",[93,98],{"categoryNo":94,"categoryName":95,"taxonomyType":96,"taxonomyTypeDesc":97},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":99,"categoryName":100,"taxonomyType":101,"taxonomyTypeDesc":102},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[104,105,106,107,108,109,110,111,34,112,113,114,115,116,117,118,119,120,121,122],"architecture","azure","azure apim architecture","component","authentication","gateway","topology","Optimization","api","team","environment","multi-environment","workspaces","instances","selection","strategies","azure api management","mode","for",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":137,"publishedAt":38},"01M6HBT7J4H082JEEA670B3EQ9","apiops-deployment","Guides deployment of Azure API Management infrastructure using Infrastructure as Code (Bicep\u002FTerraform), CI\u002FCD pipelines (GitHub Actions\u002FAzure DevOps), and APIOps workflows. Use when deploying APIM, creating pipelines, or implementing dev→test→prod promotion strategies.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fcopilot-agent-skills\u002F.github\u002Fskills\u002Fapiops-deployment\u002FSKILL.md",[129,130,133,136],{"categoryNo":94,"categoryName":95,"taxonomyType":96,"taxonomyTypeDesc":97},{"categoryNo":131,"categoryName":132,"taxonomyType":96,"taxonomyTypeDesc":97},"01JBSEEDCAT000000000000011","运维与部署",{"categoryNo":134,"categoryName":135,"taxonomyType":96,"taxonomyTypeDesc":97},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":99,"categoryName":100,"taxonomyType":101,"taxonomyTypeDesc":102},[138,139,140,141,105,142,143,144,145,146,147,148,112,113,119,149,150,120,151,18],"deployment","apiops deployment","workflows","azure devops","infrastructure","code","infrastructure as code","actions","ci","github actions","github-actions","as","guides","CI\u002FCD",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":159,"publishedAt":38},"01M6HBT2HEA23THNE9E00GYQBE","apim-policy-authoring","Creates production-ready Azure API Management policy XML for authentication (OAuth 2.0, JWT validation, subscription keys), rate limiting, CORS configuration, error handling, and API transformations. Use when implementing API security, access control, or request\u002Fresponse processing logic.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fcopilot-agent-skills\u002F.github\u002Fskills\u002Fapim-policy-authoring\u002FSKILL.md",[158],{"categoryNo":94,"categoryName":95,"taxonomyType":96,"taxonomyTypeDesc":97},[160,161,162,163,105,108,112,113,164,165,166,167,168,169,170,120,171,172,18,122],"policy","authoring","apim policy authoring","security","access","use","ready","api security","Access Control","error","processing","cors configuration","production-ready",{"skillNo":174,"name":175,"nameZh":6,"description":176,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":177,"categories":178,"keywords":181,"publishedAt":38},"01M6HBSY65SB29J9WE9KYD0K6T","api-security-review","Reviews Azure API Management configurations for security vulnerabilities, OWASP API Security Top 10 compliance, VNet Internal mode validation, Private Link verification, and Azure Security Benchmark alignment. Use when performing security audits, pre-deployment validation, or compliance reviews.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fcopilot-agent-skills\u002F.github\u002Fskills\u002Fapi-security-review\u002FSKILL.md",[179,180],{"categoryNo":94,"categoryName":95,"taxonomyType":96,"taxonomyTypeDesc":97},{"categoryNo":99,"categoryName":100,"taxonomyType":101,"taxonomyTypeDesc":102},[182,163,183,112,167,184,105,138,185,186,187,188,113,189,120,190,191,192,121,122],"review","security review","api security review","benchmark","verification","owasp","owasp-api","alignment","azure security","reviews","top",{"skillNo":194,"name":195,"nameZh":6,"description":196,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":197,"categories":198,"keywords":199,"publishedAt":38},"01M6HBSRW4PDFE6K4F8JYPZQ05","jira-cli","Interact with Jira from the command line to create, list, view, edit, and transition issues, manage sprints and epics, and perform common Jira workflows. Use when the user asks about Jira tasks, tickets, issues, sprints, or needs to manage project work items.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fawesome-copilot-agents\u002Fskills\u002Fjira-cli\u002FSKILL.md",[],[200,201,202,140,203,204,205,206,112,207,208,209,210,211,212,213,214,215,216,217],"cli","jira","jira cli","init","tasks","create","issues","common","work","command","edit","list","view","project","project work","token","line","sprints",{"skillNo":219,"name":220,"nameZh":6,"description":221,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":222,"categories":223,"keywords":224,"publishedAt":38},"01M6HBSNS3JHMW603G47TWE31H","calculator","Performs arbitrary-precision arithmetic calculations including addition, subtraction, multiplication, division, and exponents. Use when the user asks to calculate, compute, or evaluate math expressions, or when precise decimal arithmetic is needed to avoid floating-point errors.","https:\u002F\u002Fgithub.com\u002Fmicsapp\u002Fmicstec-skills\u002Fblob\u002Fmaster\u002Fcopilot-cli\u002Fawesome-copilot-agents\u002Fskills\u002Fcalculator\u002FSKILL.md",[],[220,225,226,227,228,229,230,165,231,232],"npm","js","calculate","node","math","user","compute","errors"]