App Service の FTP 転送保護の確認

ファイル転送には FTPS を使い、不要な FTP アクセスは無効にしてください。

説明

Web App のデプロイに FTP を使わない場合は site_config.ftps_state を Disabled にします。FTP で発行する必要があれば FtpsOnly に設定してください。

想定される影響

AllAllowed では平文 FTP も許可されます。平文でファイルを送ると、発行用の認証情報が漏えいしたり、デプロイファイルが改ざんされたりするおそれがあります。

対処方法

FtpsOnly を使う場合は、アプリの受信 TLS の最小バージョンを 1.2 以上に設定します。 FTPS でのデプロイには、FTP と SCM の両方で発行用の基本認証が必要です。発行用の認証情報を使える人を制限し、クライアントがサーバー証明書を検証して TLS で転送すること、平文 FTP が拒否されることを確認します。別のデプロイ経路を使う場合は、その経路の認証と通信の暗号化を確認してください。

例

AzureRM 3.x の azurerm_app_service で AllAllowed を FtpsOnly に変更する例です。現在の Linux・Windows Web App もこの設定に対応します。Web リクエストの HTTPS とユーザー認証は別途設定してください。

変更前

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"
    ftps_state               = "AllAllowed"
  }
}

変更後

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"
    ftps_state               = "FtpsOnly"
  }
}

参考資料