Review Azure Web App HTTPS enforcement

Use HTTPS for web requests and never send sensitive information over plaintext HTTP.

Description

Set https_only = true to redirect incoming App Service HTTP requests to HTTPS. Use HTTPS URLs from the start in app links and API clients.

Potential impact

A redirect cannot protect login data, session cookies or user input already sent in the initial plaintext request.

Remediation

Test the redirect with an HTTP request that contains no sensitive data. Verify that real logins and API calls start over HTTPS with a valid certificate. Check the minimum TLS version, the cookie Secure attribute, a suitable HSTS policy and the app’s authentication and authorization controls.

Examples

The excerpts change only https_only on the AzureRM 3.x azurerm_app_service resource. Current Linux and Windows Web App resources use the same property.

Before

hcl
resource "azurerm_app_service" "example" {
  name                = "example-app-service"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_app_service_plan.example.id

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

  https_only = false
}

After

hcl
resource "azurerm_app_service" "example" {
  name                = "example-app-service"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_app_service_plan.example.id

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

  https_only = true
}

References