Storage Account Allows Unsecure Transfer

  • Query id: 1367dd13-2c90-4020-80b7-e4339a3dc2c4
  • Query name: Storage Account Allows Unsecure Transfer
  • Platform: AzureResourceManager
  • Severity: Medium
  • Category: Encryption
  • CWE: 319
  • URL: Github

Description

'Microsoft.Storage/storageAccounts' should force the use of HTTPS
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - bicep file
resource storageaccount1 'Microsoft.Storage/storageAccounts@2021-02-01' = {
  name: 'storageaccount1'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
  properties: {
    supportsHttpsTrafficOnly: false
  }
}
Positive test num. 2 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "name": "storageaccount1",
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2021-02-01",
      "tags": {
        "displayName": "storageaccount1"
      },
      "location": "[resourceGroup().location]",
      "kind": "StorageV2",
      "sku": {
        "name": "Premium_LRS",
        "tier": "Premium"
      },
      "properties": {
        "supportsHttpsTrafficOnly": false
      }
    }
  ],
  "outputs": {}
}
Positive test num. 3 - bicep file
resource storageaccount1Positive2 'Microsoft.Storage/storageAccounts@2017-10-01' = {
  name: 'storageaccount1Positive2'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
}

Positive test num. 4 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "name": "storageaccount1Positive2",
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2017-10-01",
      "tags": {
        "displayName": "storageaccount1"
      },
      "location": "[resourceGroup().location]",
      "kind": "StorageV2",
      "sku": {
        "name": "Premium_LRS",
        "tier": "Premium"
      }
    }
  ],
  "outputs": {}
}
Positive test num. 5 - bicep file
resource storageaccount1Positive3 'Microsoft.Storage/storageAccounts@2018-02-01' = {
  name: 'storageaccount1Positive3'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
  properties: {}
}
Positive test num. 6 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "name": "storageaccount1Positive3",
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2018-02-01",
      "tags": {
        "displayName": "storageaccount1"
      },
      "location": "[resourceGroup().location]",
      "kind": "StorageV2",
      "sku": {
        "name": "Premium_LRS",
        "tier": "Premium"
      },
      "properties": {}
    }
  ],
  "outputs": {}
}
Positive test num. 7 - bicep file
resource storageaccount1 'Microsoft.Storage/storageAccounts@2021-02-01' = {
  name: 'storageaccount1'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
  properties: {
    supportsHttpsTrafficOnly: false
  }
}
Positive test num. 8 - json file
{
  "properties": {
    "template": {
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "resources": [
          {
            "name": "storageaccount1",
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2021-02-01",
            "tags": {
              "displayName": "storageaccount1"
            },
            "location": "[resourceGroup().location]",
            "kind": "StorageV2",
            "sku": {
              "name": "Premium_LRS",
              "tier": "Premium"
            },
            "properties": {
              "supportsHttpsTrafficOnly": false
            }
          }
        ],
        "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}
Positive test num. 9 - bicep file
resource storageaccount1Positive2 'Microsoft.Storage/storageAccounts@2017-10-01' = {
  name: 'storageaccount1Positive2'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
}
Positive test num. 10 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "resources": [
        {
          "name": "storageaccount1Positive2",
          "type": "Microsoft.Storage/storageAccounts",
          "apiVersion": "2017-10-01",
          "tags": {
            "displayName": "storageaccount1"
          },
          "location": "[resourceGroup().location]",
          "kind": "StorageV2",
          "sku": {
            "name": "Premium_LRS",
            "tier": "Premium"
          }
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}
Positive test num. 11 - bicep file
resource storageaccount1Positive3 'Microsoft.Storage/storageAccounts@2018-02-01' = {
  name: 'storageaccount1Positive3'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
  properties: {}
}
Positive test num. 12 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "resources": [
        {
          "name": "storageaccount1Positive3",
          "type": "Microsoft.Storage/storageAccounts",
          "apiVersion": "2018-02-01",
          "tags": {
            "displayName": "storageaccount1"
          },
          "location": "[resourceGroup().location]",
          "kind": "StorageV2",
          "sku": {
            "name": "Premium_LRS",
            "tier": "Premium"
          },
          "properties": {}
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}

Code samples without security vulnerabilities

Negative test num. 1 - bicep file
resource storageaccount1Negative1 'Microsoft.Storage/storageAccounts@2021-02-01' = {
  name: 'storageaccount1Negative1'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
  properties: {
    supportsHttpsTrafficOnly: true
  }
}
Negative test num. 2 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "name": "storageaccount1Negative1",
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2021-02-01",
      "tags": {
        "displayName": "storageaccount1"
      },
      "location": "[resourceGroup().location]",
      "kind": "StorageV2",
      "sku": {
        "name": "Premium_LRS",
        "tier": "Premium"
      },
      "properties": {
        "supportsHttpsTrafficOnly": true
      }
    }
  ],
  "outputs": {}
}
Negative test num. 3 - bicep file
resource storageaccount1Positive3 'Microsoft.Storage/storageAccounts@2019-06-01' = {
  name: 'storageaccount1Positive3'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
  properties: {}
}

Negative test num. 4 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "name": "storageaccount1Positive3",
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2019-06-01",
      "tags": {
        "displayName": "storageaccount1"
      },
      "location": "[resourceGroup().location]",
      "kind": "StorageV2",
      "sku": {
        "name": "Premium_LRS",
        "tier": "Premium"
      },
      "properties": {}
    }
  ],
  "outputs": {}
}
Negative test num. 5 - bicep file
resource storageaccount1Negative1 'Microsoft.Storage/storageAccounts@2021-02-01' = {
  name: 'storageaccount1Negative1'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
  properties: {
    supportsHttpsTrafficOnly: true
  }
}
Negative test num. 6 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "resources": [
        {
          "name": "storageaccount1Negative1",
          "type": "Microsoft.Storage/storageAccounts",
          "apiVersion": "2021-02-01",
          "tags": {
            "displayName": "storageaccount1"
          },
          "location": "[resourceGroup().location]",
          "kind": "StorageV2",
          "sku": {
            "name": "Premium_LRS",
            "tier": "Premium"
          },
          "properties": {
            "supportsHttpsTrafficOnly": true
          }
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}
Negative test num. 7 - bicep file
resource storageaccount1Positive3 'Microsoft.Storage/storageAccounts@2019-06-01' = {
  name: 'storageaccount1Positive3'
  tags: {
    displayName: 'storageaccount1'
  }
  location: resourceGroup().location
  kind: 'StorageV2'
  sku: {
    name: 'Premium_LRS'
    tier: 'Premium'
  }
  properties: {}
}
Negative test num. 8 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "resources": [
        {
          "name": "storageaccount1Positive3",
          "type": "Microsoft.Storage/storageAccounts",
          "apiVersion": "2019-06-01",
          "tags": {
            "displayName": "storageaccount1"
          },
          "location": "[resourceGroup().location]",
          "kind": "StorageV2",
          "sku": {
            "name": "Premium_LRS",
            "tier": "Premium"
          },
          "properties": {}
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}