MySQL Server SSL Enforcement Disabled

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

Description

'Microsoft.DBforMySQL/servers' should enforce SSL
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - bicep file
resource server 'Microsoft.DBforMySQL/servers@2017-12-01' = {
  name: 'server'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    version: '5.6'
    createMode: 'GeoRestore'
    sourceServerId: 'id'
  }
  location: 'location'
  tags: {}
}
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",
        "createMode": "GeoRestore",
        "sourceServerId": "id"
      },
      "location": "location",
      "tags": {},
      "resources": []
    }
  ],
  "outputs": {}
}
Positive test num. 3 - bicep file
resource server 'Microsoft.DBforMySQL/servers@2017-12-01' = {
  name: 'server'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    version: '5.6'
    sslEnforcement: 'Disabled'
    createMode: 'GeoRestore'
    sourceServerId: 'id'
  }
  location: 'location'
  tags: {}
}

Positive test num. 4 - 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. 5 - bicep file
resource server 'Microsoft.DBforMySQL/servers@2017-12-01' = {
  name: 'server'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    version: '5.6'
    createMode: 'GeoRestore'
    sourceServerId: 'id'
  }
  location: 'location'
  tags: {}
}
Positive test num. 6 - 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. 7 - bicep file
resource server 'Microsoft.DBforMySQL/servers@2017-12-01' = {
  name: 'server'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    version: '5.6'
    sslEnforcement: 'Disabled'
    createMode: 'GeoRestore'
    sourceServerId: 'id'
  }
  location: 'location'
  tags: {}
}
Positive test num. 8 - 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 - bicep file
resource server 'Microsoft.DBforMySQL/servers@2017-12-01' = {
  name: 'server'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    version: '5.6'
    sslEnforcement: 'Enabled'
    createMode: 'GeoRestore'
    sourceServerId: 'id'
  }
  location: 'location'
  tags: {}
}
Negative 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": "Enabled",
        "createMode": "GeoRestore",
        "sourceServerId": "id"
      },
      "location": "location",
      "tags": {},
      "resources": []
    }
  ],
  "outputs": {}
}
Negative test num. 3 - bicep file
resource server 'Microsoft.DBforMySQL/servers@2017-12-01' = {
  name: 'server'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    version: '5.6'
    sslEnforcement: 'Enabled'
    createMode: 'GeoRestore'
    sourceServerId: 'id'
  }
  location: 'location'
  tags: {}
}

Negative 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": "Enabled",
            "createMode": "GeoRestore",
            "sourceServerId": "id"
          },
          "location": "location",
          "tags": {},
          "resources": []
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}