Table: gcp_compute_firewall - Query Google Cloud Compute Engine Firewalls using SQL
Google Cloud Compute Engine Firewalls are a networking security feature that allows you to control the traffic to your virtual machine instances. They provide a flexible and robust tool for securing your instances by defining what traffic is allowed to and from your instances. Firewalls are implemented at the network level and apply to all traffic that crosses the perimeter of the network.
Table Usage Guide
The gcp_compute_firewall
table can be used to gain insights into firewall rules within Google Cloud Compute Engine. As a network security administrator or a DevOps engineer, you can explore details about each firewall rule, including allowed and denied configurations, network associations, and priority. Utilize it to identify firewall rules that may be overly permissive or misconfigured, enhancing your network security posture.
Examples
Firewall rules basic info
Explore which firewall rules are in place for your Google Cloud Platform (GCP) compute instances. This allows you to understand the direction of traffic flow and assess the overall security configuration.
select name, id, description, directionfrom gcp_compute_firewall;
select name, id, description, directionfrom gcp_compute_firewall;
List of rules which are applied to TCP protocol
Explore which firewall rules are applied specifically to the TCP protocol in your Google Cloud Platform. This will help in assessing network security and identifying potential vulnerabilities.
select name, id, p ->> 'IPProtocol' as ip_protocol, p ->> 'ports' as portsfrom gcp_compute_firewall, jsonb_array_elements(allowed) as pwhere p ->> 'IPProtocol' = 'tcp';
select f.name, f.id, json_extract(p.value, '$.IPProtocol') as ip_protocol, json_extract(p.value, '$.ports') as portsfrom gcp_compute_firewall as f, json_each(allowed) as pwhere json_extract(p.value, '$.IPProtocol') = 'tcp';
List of disabled rules
Determine the areas in which firewall rules are disabled to strengthen your security posture in Google Cloud Platform. This can assist in identifying potential vulnerabilities and maintaining robust network security.
select name, id, description, disabledfrom gcp_compute_firewallwhere disabled;
select name, id, description, disabledfrom gcp_compute_firewallwhere disabled = 1;
List of Egress rules
Explore which firewall rules in your Google Cloud Platform are set to allow outbound traffic. This can help understand your network's security posture and identify potential vulnerabilities.
select name, id, direction, allowed, deniedfrom gcp_compute_firewallwhere direction = 'EGRESS';
select name, id, direction, allowed, deniedfrom gcp_compute_firewallwhere direction = 'EGRESS';
Query examples
- compute_firewalls_for_compute_instance
- compute_firewalls_for_compute_instance_group
- compute_firewalls_for_compute_network
- compute_firewalls_for_kubernetes_cluster
- compute_instance_firewall_detail
- network_firewall_rules_count
- source_compute_firewalls_for_iam_service_account
- target_compute_firewalls_for_iam_service_account
Control examples
- All Controls > Compute > Ensure Firewall Rules for instances behind Identity Aware Proxy (IAP) only allow the traffic from Google Cloud Loadbalancer (GCLB) Health Check and Proxy Addresses
- All Controls > Compute > Ensure no open default firewall rules allow ingress from 0.0.00/0 to any port
- All Controls > Compute > Ensure no open firewall rules allow ingress from 0.0.00/0 to any port without any specific target
- All Controls > Compute > Ensure no open firewall rules allow ingress from 0.0.00/0 to MongoDB port 27017
- All Controls > Compute > Ensure no open firewall rules allow ingress from 0.0.00/0 to NetBIOS SSN port 139
- All Controls > Compute > Ensure no open firewall rules allow ingress from 0.0.00/0 to port 10250
- All Controls > Compute > Ensure no open firewall rules allow ingress from 0.0.00/0 to port 10255
- All Controls > Compute > Use Identity Aware Proxy (IAP) to Ensure Only Traffic From Google IP Addresses are 'Allowed'
- All Controls > Kubernetes > GKE clusters should not allow incoming traffic from all sources across the internet
- Check for open firewall rules allowing RDP from the internet
- Check for open firewall rules allowing SSH from the internet
- Check for open firewall rules allowing TCP/UDP from the internet
- CIS v1.2.0 > 3 Networking > 3.10 Ensure Firewall Rules for instances behind Identity Aware Proxy (IAP) only allow the traffic from Google Cloud Loadbalancer (GCLB) Health Check and Proxy Addresses
- CIS v1.2.0 > 3 Networking > 3.6 Ensure that SSH access is restricted from the internet
- CIS v1.2.0 > 3 Networking > 3.7 Ensure that RDP access is restricted from the Internet
- CIS v1.3.0 > 3 Networking > 3.10 Use Identity Aware Proxy (IAP) to Ensure Only Traffic From Google IP Addresses are 'Allowed'
- CIS v1.3.0 > 3 Networking > 3.6 Ensure that SSH access is restricted from the internet
- CIS v1.3.0 > 3 Networking > 3.7 Ensure that RDP access is restricted from the Internet
- CIS v2.0.0 > 3 Networking > 3.10 Use Identity Aware Proxy (IAP) to Ensure Only Traffic From Google IP Addresses are 'Allowed'
- CIS v2.0.0 > 3 Networking > 3.6 Ensure that SSH access is restricted from the internet
- CIS v2.0.0 > 3 Networking > 3.7 Ensure that RDP access is restricted from the Internet
- CIS v3.0.0 > 3 Networking > 3.10 Use Identity Aware Proxy (IAP) to Ensure Only Traffic From Google IP Addresses are 'Allowed'
- CIS v3.0.0 > 3 Networking > 3.6 Ensure That SSH Access Is Restricted From the Internet
- CIS v3.0.0 > 3 Networking > 3.7 Ensure That RDP Access Is Restricted From the Internet
- Ensure compute firewall rule have logging enabled
- Ensure no open firewall rules allow ingress from 0.0.00/0 to any port
- Ensure no open firewall rules allow ingress from 0.0.00/0 to DNS port 53
- Ensure no open firewall rules allow ingress from 0.0.00/0 to FTP port 21
- Ensure no open firewall rules allow ingress from 0.0.00/0 to HTTP port 80
- Ensure no open firewall rules allow ingress from 0.0.00/0 to Microsoft DS port 445
- Ensure no open firewall rules allow ingress from 0.0.00/0 to MySQL DB port 3306
- Ensure no open firewall rules allow ingress from 0.0.00/0 to Oracle DB port 1521
- Ensure no open firewall rules allow ingress from 0.0.00/0 to POP3 port 110
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 137 to 139
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 27017 to 27019
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 61620 or 6162
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 636
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 6379
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 7000 or 7001
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 7199
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 8888
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 9042
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 9090
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 9160
- Ensure no open firewall rules allow ingress from 0.0.00/0 to port TCP 9200 or 9300
- Ensure no open firewall rules allow ingress from 0.0.00/0 to PostgreSQL port 5432
- Ensure no open firewall rules allow ingress from 0.0.00/0 to SMTP port 25
- Ensure no open firewall rules allow ingress from 0.0.00/0 to TCP or UDP port 11211
- Ensure no open firewall rules allow ingress from 0.0.00/0 to TCP or UDP port 11214 to 11215
- Ensure no open firewall rules allow ingress from 0.0.00/0 to TCP or UDP port 2483 to 24845
- Ensure no open firewall rules allow ingress from 0.0.00/0 to TCP or UDP port 389
- Ensure no open firewall rules allow ingress from 0.0.00/0 to Telnet port 23
Schema for gcp_compute_firewall
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
action | text | Describes the type action specified by the rule. | |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
allowed | jsonb | The list of ALLOW rules specified by this firewall. | |
creation_timestamp | timestamp with time zone | The creation timestamp of the resource. | |
denied | jsonb | The list of DENY rules specified by this firewall. | |
description | text | A user-specified, human-readable description of the firewall. | |
destination_ranges | jsonb | A list of CIDR ranges. The firewall rule applies only to traffic that has destination IP address in these ranges. | |
direction | text | !=, = | Direction of traffic to which this firewall applies. |
disabled | boolean | !=, = | Indicates whether the firewall rule is disabled, or not. |
id | bigint | The unique identifier for the resource. | |
kind | text | Specifies the type of the resource. | |
location | text | The GCP multi-region, region, or zone in which the resource is located. | |
log_config_enable | boolean | Specifies whether to enable logging for a particular firewall rule, or not. | |
log_config_metadata | text | Specifies whether to include or exclude metadata for firewall logs. | |
name | text | = | A friendly name that identifies the resource. |
network | text | The URL of the network resource for this firewall rule. | |
priority | bigint | Specifies the priority for this rule. Relative priorities determine which rule takes effect if multiple rules apply. Lower values indicate higher priority. | |
project | text | =, !=, ~~, ~~*, !~~, !~~* | The GCP Project in which the resource is located. |
self_link | text | The server-defined URL for the resource. | |
source_ranges | jsonb | A list of CIDR ranges. The firewall rule applies only to traffic originating from an instance with a service account in this list. | |
source_service_accounts | jsonb | A list of service account. The firewall rule applies only to traffic that has a source IP address in these ranges. | |
source_tags | jsonb | A list of tags. The firewall rule applies only to traffic with source IPs that match the primary network interfaces of VM instances that have the tag and are in the same VPC network. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
target_service_accounts | jsonb | A list of service accounts indicating sets of instances located in the network that may make network connections as specified in Allowed | |
target_tags | jsonb | A list of tags that controls which instances the firewall rule applies to. | |
title | text | Title of the resource. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- gcp
You can pass the configuration to the command with the --config
argument:
steampipe_export_gcp --config '<your_config>' gcp_compute_firewall