Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the control plane endpoint access misconfiguration in GCP, you can follow these steps:
  1. Open the Google Cloud Console and navigate to the VPC network page.
  2. Select the VPC network that you want to configure.
  3. Click on the “Firewall rules” tab.
  4. Click on the “Create Firewall Rule” button.
  5. In the “Name” field, enter a name for the firewall rule.
  6. In the “Targets” field, select “All instances in the network”.
  7. In the “Source IP ranges” field, enter the IP address range of the authorized networks that should have access to the control plane endpoint.
  8. In the “Protocols and ports” section, select “Specified protocols and ports”.
  9. In the “Specified protocols and ports” field, enter “tcp:443”.
  10. Click on the “Create” button to create the firewall rule.
This will create a firewall rule that will restrict access to the control plane endpoint to only the authorized networks that you specified.

To remediate the misconfiguration “Control Plane Endpoint Access Should Be Limited To Authorized Networks” for GCP using GCP CLI, follow these steps:
  1. Open the Cloud Shell in the GCP Console.
  2. Run the following command to list the current authorized networks:
Replace [CLUSTER_NAME] and [ZONE] with the name and zone of your cluster.
  1. If the output shows that there are no authorized networks, or if the authorized networks are not correct, run the following command to add authorized networks:
Replace [CLUSTER_NAME], [ZONE], and [CIDR_BLOCK] with your own values. You can specify multiple CIDR blocks separated by commas.
  1. Verify that the authorized networks have been added by running the first command again.
  2. Repeat steps 2-4 for each cluster in your GCP project.
By following these steps, you will restrict access to the control plane endpoint to only the authorized networks, reducing the risk of unauthorized access.
To remediate “Control Plane Endpoint Access Should Be Limited To Authorized Networks” for GCP using python, you can follow these steps:
  1. Import necessary libraries:
  1. Set up authentication using a service account:
  1. Initialize the GCP API client:
  1. Get the current cluster configuration:
  1. Update the cluster configuration to limit control plane endpoint access to authorized networks:
In this example, we are limiting control plane endpoint access to the IP ranges ‘10.0.0.0/8’ and ‘172.16.0.0/12’. You can modify the cidrBlocks list to include the authorized networks for your specific use case.Note: This code assumes that you have the necessary permissions to modify the cluster configuration.
Substitute:
  • GKE_CLUSTER_NAME with your cluster’s name.
  • GKE_CLUSTER_LOCATION with the region/zone where the cluster runs.
  • AUTHORIZED_CIDR_1, AUTHORIZED_CIDR_2, etc. with the exact IPv4 CIDR ranges that should be able to reach the control plane.
This change is an in‑place update and should not force replacement of the cluster (no outage), though the control plane endpoint will stop accepting traffic from sources outside the listed CIDRs.For verification, terraform plan should show an in-place ~ update to google_container_cluster.GKE_CLUSTER with master_authorized_networks_config being added or modified, and no -/+ replacement of the cluster.