Skip to main content

lacework-global-580

9.2 Ensure Web App Redirects All HTTP traffic to HTTPS in Azure App Service (Automated)

Profile Applicability

• Level 1

Description

Azure Web Apps allows sites to run under both HTTP and HTTPS by default. By default, anyone using non-secure HTTP links can access web apps. You can restrict non-secure HTTP requests and redirect all HTTP requests to the secure HTTPS port. Best practices recommend enforcing HTTPS-only traffic.

Rationale

Enabling HTTPS-only traffic will redirect all non-secure HTTP requests to HTTPS ports. HTTPS uses the TLS/SSL protocol to provide a secure connection which is both encrypted and authenticated. It is therefore important to support HTTPS for the security benefits.

Impact

When it is enabled, every incoming HTTP request is redirected to the HTTPS port. This means an extra level of security will be added to the HTTP requests made to the app.

Audit

From Azure Portal

  1. Login to Azure Portal using https://portal.azure.com
  2. Go to App Services
  3. Click on each App
  4. Under Setting section, click on TLS/SSL settings
  5. Under the Bindings pane, ensure that HTTPS Only set to On under Protocol Settings

From Azure CLI

To check HTTPS-only traffic value for an existing app, run the following command,

az webapp show --resource-group <RESOURCE_GROUP_NAME> --name <APP_NAME> --query httpsOnly

The output should return true if HTTPS-only traffic value is set to On.

From Azure Powershell

List all the web apps configured within the subscription.

Get-AzWebApp | Select-Object ResourceGroup, Name, HttpsOnly

For each web app review the HttpsOnly setting and make sure it is set to True.

Remediation

From Azure Portal

  1. Login to Azure Portal using https://portal.azure.com.
  2. Go to App Services.
  3. Click each App.
  4. Under Setting section, click Transport Layer Security (TLS)/SSL settings.
  5. Under the Bindings pane, set HTTPS Only to On under Protocol Settings section.

From Azure CLI

To set HTTPS-only traffic value for an existing app, run the following command:

az webapp update --resource-group <resource_group_name> --name <app_name> --set httpsOnly=true

From Azure Powershell

Set-AzWebApp -ResourceGroupName <resource_group_name> -Name <app_name> -HttpsOnly $true

References

https://docs.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-data-protection#dp-3-encrypt-sensitive-data-in-transit
https://docs.microsoft.com/en-us/powershell/module/az.websites/set-azwebapp?view=azps-8.1.0