Skip to main content

Cloud CDN Regional Backend Services Should Use Secure

More Info:​

Cloud CDN regional backend services should use only the secure listeners. A listener is a process that checks for connection requests, using the protocol and port that you configure.

Risk Level​

Medium

Address​

Security

Compliance Standards​

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation​

Remediation​

Using Console

To remediate the "Cloud CDN Regional Backend Services Should Use Secure Listeners Only" misconfiguration in GCP using the GCP console, please follow the below steps:

  1. Open the Google Cloud Console and select the project in which the Cloud CDN has been configured.
  2. In the left-hand side menu, click on "Cloud CDN".
  3. In the Cloud CDN dashboard, click on the name of the CDN you want to modify.
  4. In the CDN details page, click on the "Backend configuration" tab.
  5. In the "Backend configuration" tab, click on the "Edit" button.
  6. In the "Edit backend configuration" page, scroll down to the "Backend service" section.
  7. In the "Backend service" section, click on the "Edit" button.
  8. In the "Edit backend service" page, scroll down to the "Protocol" section.
  9. In the "Protocol" section, select "HTTPS" from the drop-down list.
  10. In the same section, select the "Port number" as per your requirement.
  11. Click on the "Save" button to save the changes.
  12. Repeat steps 5-11 for all the backend services used by the CDN.

By following the above steps, you have successfully remediated the "Cloud CDN Regional Backend Services Should Use Secure Listeners Only" misconfiguration in GCP using the GCP console.

Using CLI

To remediate the misconfiguration "Cloud CDN Regional Backend Services Should Use Secure Listeners Only" for GCP using GCP CLI, you can follow the below steps:

  1. Open the Cloud Shell in your GCP console.

  2. Run the following command to list all the backend services in your project:

    gcloud compute backend-services list
  3. Identify the backend service that needs to be remediated and note down its name.

  4. Run the following command to update the backend service and enable secure listeners:

    gcloud compute backend-services update <BACKEND_SERVICE_NAME> --enable-cdn --protocol HTTPS --global

    Replace <BACKEND_SERVICE_NAME> with the actual name of the backend service that needs to be remediated.

  5. Verify the configuration by running the following command:

    gcloud compute backend-services describe <BACKEND_SERVICE_NAME> --global

    This command will display the details of the backend service, including the protocol and port used for the secure listener.

  6. Repeat the above steps for all the backend services in your project that need to be remediated.

By following the above steps, you can remediate the misconfiguration "Cloud CDN Regional Backend Services Should Use Secure Listeners Only" for GCP using GCP CLI.

Using Python

To remediate the misconfiguration "Cloud CDN Regional Backend Services Should Use Secure Listeners Only" for GCP using Python, you can follow the below steps:

  1. Import the required libraries:
from googleapiclient.discovery import build
from google.oauth2 import service_account
  1. Set up the authentication using a service account:
credentials = service_account.Credentials.from_service_account_file(
'path/to/service_account.json')
  1. Build the Cloud CDN API client:
cdn = build('cdn', 'v1', credentials=credentials)
  1. Get the list of backend services using the projects().global().backendServices().list() method:
backend_services = cdn.projects().global().backendServices().list(
project='your-project-id').execute()
  1. Loop through each backend service and check if it has a secure listener:
for backend_service in backend_services['items']:
if '443' not in backend_service['port']:
# Update the backend service to use a secure listener
backend_service['port'].append('443')
cdn.projects().global().backendServices().update(
project='your-project-id',
backendService=backend_service['name'],
body=backend_service).execute()
  1. Save the changes and exit the script.

Note: This script assumes that you have the necessary permissions to modify backend services in your GCP project.

Using Terraform
resource "google_compute_region_backend_service" "cdn_backend" {
name = "REGIONAL_CDN_BACKEND_SERVICE_NAME" # replace with your backend service name
region = "REGION" # replace with the desired region, e.g. "us-central1"
load_balancing_scheme = "EXTERNAL_MANAGED"
enable_cdn = true

# FIX: use only secure listeners by setting the protocol to HTTPS
# This matches: gcloud compute backend-services update ... --protocol HTTPS --region ...
protocol = "HTTPS"

health_checks = [
google_compute_region_health_check.cdn_hc.id,
]

backend {
group = google_compute_region_instance_group_manager.cdn_igm.instance_group
}
}

Changing protocol from HTTP to HTTPS on google_compute_region_backend_service forces replacement of the backend service, which can cause a brief outage while traffic is switched.

terraform plan should show the google_compute_region_backend_service with protocol changing from "HTTP" (or another non-secure value) to "HTTPS" and indicate that the resource will be replaced.

Additional Reading:​