MySQL Server SSL Enforcement Disabled

  • Query id: 90120147-f2e7-4fda-bb21-6fa9109afd63
  • Query name: MySQL Server SSL Enforcement Disabled
  • Platform: AzureResourceManager
  • Severity: High
  • Category: Networking and Firewall
  • URL: Github

Description

'Microsoft.DBforMySQL/servers' should enforce SSL
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "resources": [
    {
      "name": "server",
      "type": "Microsoft.DBforMySQL/servers",
      "apiVersion": "2017-12-01",
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "version": "5.6",
        "createMode": "GeoRestore",
        "sourceServerId": "id"
      },
      "location": "location",
      "tags": {},
      "resources": []
    }
  ],
  "outputs": {}
}
Positive test num. 2 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "resources": [
    {
      "name": "server",
      "type": "Microsoft.DBforMySQL/servers",
      "apiVersion": "2017-12-01",
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "version": "5.6",
        "sslEnforcement": "Disabled",
        "createMode": "GeoRestore",
        "sourceServerId": "id"
      },
      "location": "location",
      "tags": {},
      "resources": []
    }
  ],
  "outputs": {}
}
Positive test num. 3 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "resources": [
        {
          "name": "server",
          "type": "Microsoft.DBforMySQL/servers",
          "apiVersion": "2017-12-01",
          "identity": {
            "type": "SystemAssigned"
          },
          "properties": {
            "version": "5.6",
            "createMode": "GeoRestore",
            "sourceServerId": "id"
          },
          "location": "location",
          "tags": {},
          "resources": []
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}

Positive test num. 4 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "resources": [
        {
          "name": "server",
          "type": "Microsoft.DBforMySQL/servers",
          "apiVersion": "2017-12-01",
          "identity": {
            "type": "SystemAssigned"
          },
          "properties": {
            "version": "5.6",
            "sslEnforcement": "Disabled",
            "createMode": "GeoRestore",
            "sourceServerId": "id"
          },
          "location": "location",
          "tags": {},
          "resources": []
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}

Code samples without security vulnerabilities

Negative test num. 1 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "2.0.0.0",
  "apiProfile": "2019-03-01-hybrid",
  "parameters": {},
  "variables": {},
  "functions": [],
  "resources": [
    {
      "name": "server",
      "type": "Microsoft.DBforMySQL/servers",
      "apiVersion": "2017-12-01",
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "version": "5.6",
        "sslEnforcement": "Enabled",
        "createMode": "GeoRestore",
        "sourceServerId": "id"
      },
      "location": "location",
      "tags": {},
      "resources": []
    }
  ],
  "outputs": {}
}
Negative test num. 2 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "2.0.0.0",
      "apiProfile": "2019-03-01-hybrid",
      "parameters": {},
      "variables": {},
      "functions": [],
      "resources": [
        {
          "name": "server",
          "type": "Microsoft.DBforMySQL/servers",
          "apiVersion": "2017-12-01",
          "identity": {
            "type": "SystemAssigned"
          },
          "properties": {
            "version": "5.6",
            "sslEnforcement": "Enabled",
            "createMode": "GeoRestore",
            "sourceServerId": "id"
          },
          "location": "location",
          "tags": {},
          "resources": []
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}