Load Balancer SSL Should Use Restricted Profile
More Info:
Your Load Balancer SSL policy should use Restricted profile for their SSL negotiation configuration
Risk Level
Medium
Address
Security
Compliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Using Console
To remediate the "Load Balancer SSL Should Use Restricted Profile" misconfiguration in GCP using the GCP console, please follow the steps below:
- Open the GCP console and navigate to the Load Balancing page.
- Select the Load Balancer that you want to remediate.
- Click on the "Edit" button to edit the Load Balancer configuration.
- Under the "Frontend configuration" section, locate the SSL certificate that you want to remediate.
- Click on the "Edit" button next to the SSL certificate.
- In the "Certificate details" section, scroll down to the "Certificate profile" option.
- Select the "Restricted" profile from the dropdown menu.
- Click on the "Save" button to save the changes.
- Repeat steps 4-8 for all SSL certificates associated with the Load Balancer.
By following these steps, you will remediate the "Load Balancer SSL Should Use Restricted Profile" misconfiguration in GCP using the GCP console.
Using CLI
To remediate the "Load Balancer SSL Should Use Restricted Profile" misconfiguration in GCP using GCP CLI, follow these steps:
-
Open the Cloud Shell by clicking on the icon on the top right corner of the GCP Console.
-
Run the following command to list all the HTTPS load balancers in your project:
gcloud compute target-https-proxies list -
Identify the HTTPS load balancer that needs to be remediated and note down its name.
-
Run the following command to update the SSL policy of the HTTPS load balancer:
gcloud compute target-https-proxies update [TARGET_HTTPS_PROXY_NAME] --ssl-policy=RESTRICTEDReplace
[TARGET_HTTPS_PROXY_NAME]with the name of the HTTPS load balancer that needs to be remediated. -
Verify that the SSL policy has been updated by running the following command:
gcloud compute target-https-proxies describe [TARGET_HTTPS_PROXY_NAME] | grep sslPolicyThe output should show
sslPolicy: RESTRICTED. -
Repeat steps 4-5 for all the HTTPS load balancers in your project that need to be remediated.
By following these steps, you have successfully remediated the "Load Balancer SSL Should Use Restricted Profile" misconfiguration for GCP using GCP CLI.
Using Python
To remediate the "Load Balancer SSL Should Use Restricted Profile" misconfiguration for GCP using Python, follow these steps:
-
Install the
google-cloud-load-balancerlibrary using the following command:pip install google-cloud-load-balancer -
Authenticate with GCP by setting up the environment variable
GOOGLE_APPLICATION_CREDENTIALSwith the path to your service account key file. -
Use the
google.cloud.load_balancer_v1beta1module to retrieve the SSL policy that is attached to your load balancer. You can use the following code snippet to achieve this:from google.cloud import load_balancer_v1beta1client = load_balancer_v1beta1.LoadBalancerClient()# Replace <load_balancer_name> with the name of your load balancer.load_balancer_path = client.load_balancer_path('<project_id>', '<location>', '<load_balancer_name>')# Retrieve the SSL policy attached to the load balancer.load_balancer = client.get_load_balancer(load_balancer_path)ssl_policy = load_balancer.ssl_policy -
Check if the SSL policy is set to
RESTRICTEDby checking the value of theprofilefield. If theprofileis not set toRESTRICTED, you need to update the SSL policy. You can use the following code snippet to achieve this:from google.cloud import load_balancer_v1beta1client = load_balancer_v1beta1.LoadBalancerClient()# Replace <load_balancer_name> with the name of your load balancer.load_balancer_path = client.load_balancer_path('<project_id>', '<location>', '<load_balancer_name>')# Retrieve the SSL policy attached to the load balancer.load_balancer = client.get_load_balancer(load_balancer_path)ssl_policy = load_balancer.ssl_policy# Check if the SSL policy is set to RESTRICTED.if ssl_policy.profile != 'RESTRICTED':# Update the SSL policy to use the RESTRICTED profile.ssl_policy.profile = 'RESTRICTED'# Update the load balancer with the new SSL policy.update_mask = {'paths': ['ssl_policy']}update_mask = load_balancer_v1beta1.types.FieldMask(paths=update_mask['paths'])update_mask = update_mask.to_dict()client.update_load_balancer(load_balancer, update_mask) -
Verify that the SSL policy has been updated by checking the value of the
profilefield again.
By following these steps, you can remediate the "Load Balancer SSL Should Use Restricted Profile" misconfiguration for GCP using Python.
Using Terraform
resource "google_compute_ssl_policy" "restricted_ssl_policy" {
name = "RESTRICTED_SSL_POLICY_NAME" # replace with your desired policy name
profile = "RESTRICTED"
min_tls_version = "TLS_1_2" # optional but commonly used with RESTRICTED
project = "GCP_PROJECT_ID" # replace with your project id
}
# Example attachment to a target HTTPS proxy:
resource "google_compute_target_https_proxy" "example_https_proxy" {
name = "HTTPS_PROXY_NAME" # replace with your proxy name
url_map = google_compute_url_map.example.self_link
ssl_certificates = [google_compute_ssl_certificate.example.self_link]
ssl_policy = google_compute_ssl_policy.restricted_ssl_policy.self_link
project = "GCP_PROJECT_ID"
}
Changing an existing google_compute_ssl_policy from another profile to RESTRICTED forces replacement of that SSL policy resource, which briefly affects any proxies/load balancers using it while Terraform recreates and reattaches it.
Verification: terraform plan should show the google_compute_ssl_policy either being created with profile = "RESTRICTED" or being replaced with the profile changed from its previous value to "RESTRICTED", and the relevant target HTTPS proxies referencing this policy.