Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate firewall rules being too permissive in GCP using GCP console, follow these steps:
  1. Log in to the GCP console at https://console.cloud.google.com/
  2. Navigate to the VPC network for which you want to remediate the firewall rules.
  3. Click on the “Firewall rules” tab.
  4. Review the existing firewall rules and identify the ones that are too permissive.
  5. Click on the checkbox next to the firewall rule that you want to modify.
  6. Click on the “Edit” button at the top of the page.
  7. Modify the firewall rule to be more restrictive by updating the source or destination IP addresses, protocols, or ports.
  8. Click on the “Save” button to save the changes.
  9. Repeat steps 5-8 for all the firewall rules that need to be remediated.
By following these steps, you can remediate the firewall rules being too permissive in GCP and ensure that your network is secure.

To remediate the firewall rules misconfiguration in GCP using GCP CLI, follow these steps:
  1. Open the Cloud Shell in the GCP console.
  2. Run the following command to list all the firewall rules in your project:
  1. Identify the firewall rules that are not necessary or are overly permissive.
  2. Delete the unnecessary firewall rules using the following command:
Replace [FIREWALL_RULE_NAME] with the name of the firewall rule you want to delete. 5. Modify the overly permissive firewall rules to allow only necessary traffic. You can use the following command to update a firewall rule:
Replace [FIREWALL_RULE_NAME] with the name of the firewall rule you want to update, [IP_ADDRESS_RANGE] with the IP address range that should be allowed, [PROTOCOL] with the protocol that should be allowed (e.g. tcp), [PORT_NUMBER] with the port number that should be allowed, and [PORT_PROTOCOL] with the protocol of the port (e.g. tcp).By following these steps, you can remediate the firewall rules misconfiguration in GCP using GCP CLI.
To remediate the firewall rules misconfiguration in GCP using Python, follow the steps below:
  1. Import the required modules:
  1. Set up the GCP project and firewall client:
  1. Iterate through the firewall rules and delete any unnecessary rules:
  1. Save the Python script and run it to remediate the misconfiguration.
This Python script will delete all the firewall rules except for the default-allow-http and default-allow-https rules which are required for web traffic. By doing this, we are ensuring that the firewall rules are set to a minimum.
To remediate the finding, reduce var.firewall_rules to 30 or fewer entries (merge or delete rules as appropriate); terraform plan should then show at most 30 google_compute_firewall.vpc_rules resources, with any excess rules appearing as - destroy changes.