PostgresSQL Database Server Connection Throttling Disabled

  • Query id: a6d774b6-d9ea-4bf4-8433-217bf15d2fb8
  • Query name: PostgresSQL Database Server Connection Throttling Disabled
  • Platform: AzureResourceManager
  • Severity: Medium
  • Category: Networking and Firewall
  • URL: Github

Description

Microsoft.DBforPostgreSQL/servers/configurations should have 'connection_throttling' property set to 'on'
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": "1.0.0.0",
  "parameters": {},
  "functions": [],
  "variables": {},
  "resources": [
    {
      "name": "servers1",
      "type": "Microsoft.DBforPostgreSQL/servers",
      "apiVersion": "2017-12-01",
      "identity": {
        "type": "SystemAssigned"
      },
      "sku": {
        "name": "B_Gen4_1",
        "tier": "Basic",
        "capacity": 500,
        "size": "500MB",
        "family": "family"
      },
      "properties": {
        "version": "11",
        "sslEnforcement": "Enabled",
        "minimalTlsVersion": "TLS1_2",
        "infrastructureEncryption": "Enabled",
        "publicNetworkAccess": "Disabled",
        "storageProfile": {
          "backupRetentionDays": 90,
          "geoRedundantBackup": "Enabled",
          "storageMB": 50,
          "storageAutogrow": "Enabled"
        },
        "createMode": "Replica",
        "sourceServerId": "sample_id"
      },
      "location": "string",
      "tags": {},
      "resources": [
        {
          "name": "connection_throttling",
          "type": "configurations",
          "apiVersion": "2017-12-01",
          "properties": {
            "value": "Off"
          }
        }
      ]
    }
  ],
  "outputs": {}
}
Positive test num. 2 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {},
  "functions": [],
  "variables": {},
  "resources": [
    {
      "name": "servers1",
      "type": "Microsoft.DBforPostgreSQL/servers",
      "apiVersion": "2017-12-01",
      "identity": {
        "type": "SystemAssigned"
      },
      "sku": {
        "name": "B_Gen4_1",
        "tier": "Basic",
        "capacity": 500,
        "size": "500MB",
        "family": "family"
      },
      "properties": {
        "version": "11",
        "sslEnforcement": "Enabled",
        "minimalTlsVersion": "TLS1_2",
        "infrastructureEncryption": "Enabled",
        "publicNetworkAccess": "Disabled",
        "storageProfile": {
          "backupRetentionDays": 90,
          "geoRedundantBackup": "Enabled",
          "storageMB": 50,
          "storageAutogrow": "Enabled"
        },
        "createMode": "Replica",
        "sourceServerId": "sample_id"
      },
      "location": "string",
      "tags": {},
      "resources": []
    }
  ],
  "outputs": {}
}
Positive test num. 3 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {},
  "functions": [],
  "variables": {},
  "resources": [
    {
      "name": "servers1",
      "type": "Microsoft.DBforPostgreSQL/servers",
      "apiVersion": "2017-12-01",
      "identity": {
        "type": "SystemAssigned"
      },
      "sku": {
        "name": "B_Gen4_1",
        "tier": "Basic",
        "capacity": 500,
        "size": "500MB",
        "family": "family"
      },
      "properties": {
        "version": "11",
        "sslEnforcement": "Enabled",
        "minimalTlsVersion": "TLS1_2",
        "infrastructureEncryption": "Enabled",
        "publicNetworkAccess": "Disabled",
        "storageProfile": {
          "backupRetentionDays": 90,
          "geoRedundantBackup": "Enabled",
          "storageMB": 50,
          "storageAutogrow": "Enabled"
        },
        "createMode": "Replica",
        "sourceServerId": "sample_id"
      },
      "location": "string",
      "tags": {},
      "resources": [
        {
          "name": "sample_config",
          "type": "configurations",
          "apiVersion": "2017-12-01",
          "properties": {
            "value": "Off"
          }
        }
      ]
    }
  ],
  "outputs": {}
}

Positive test num. 4 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {},
      "functions": [],
      "variables": {},
      "resources": [
        {
          "name": "servers1",
          "type": "Microsoft.DBforPostgreSQL/servers",
          "apiVersion": "2017-12-01",
          "identity": {
            "type": "SystemAssigned"
          },
          "sku": {
            "name": "B_Gen4_1",
            "tier": "Basic",
            "capacity": 500,
            "size": "500MB",
            "family": "family"
          },
          "properties": {
            "version": "11",
            "sslEnforcement": "Enabled",
            "minimalTlsVersion": "TLS1_2",
            "infrastructureEncryption": "Enabled",
            "publicNetworkAccess": "Disabled",
            "storageProfile": {
              "backupRetentionDays": 90,
              "geoRedundantBackup": "Enabled",
              "storageMB": 50,
              "storageAutogrow": "Enabled"
            },
            "createMode": "Replica",
            "sourceServerId": "sample_id"
          },
          "location": "string",
          "tags": {},
          "resources": [
            {
              "name": "connection_throttling",
              "type": "configurations",
              "apiVersion": "2017-12-01",
              "properties": {
                "value": "Off"
              }
            }
          ]
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}
Positive test num. 5 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {},
      "functions": [],
      "variables": {},
      "resources": [
        {
          "name": "servers1",
          "type": "Microsoft.DBforPostgreSQL/servers",
          "apiVersion": "2017-12-01",
          "identity": {
            "type": "SystemAssigned"
          },
          "sku": {
            "name": "B_Gen4_1",
            "tier": "Basic",
            "capacity": 500,
            "size": "500MB",
            "family": "family"
          },
          "properties": {
            "version": "11",
            "sslEnforcement": "Enabled",
            "minimalTlsVersion": "TLS1_2",
            "infrastructureEncryption": "Enabled",
            "publicNetworkAccess": "Disabled",
            "storageProfile": {
              "backupRetentionDays": 90,
              "geoRedundantBackup": "Enabled",
              "storageMB": 50,
              "storageAutogrow": "Enabled"
            },
            "createMode": "Replica",
            "sourceServerId": "sample_id"
          },
          "location": "string",
          "tags": {},
          "resources": []
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}
Positive test num. 6 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {},
      "functions": [],
      "variables": {},
      "resources": [
        {
          "name": "servers1",
          "type": "Microsoft.DBforPostgreSQL/servers",
          "apiVersion": "2017-12-01",
          "identity": {
            "type": "SystemAssigned"
          },
          "sku": {
            "name": "B_Gen4_1",
            "tier": "Basic",
            "capacity": 500,
            "size": "500MB",
            "family": "family"
          },
          "properties": {
            "version": "11",
            "sslEnforcement": "Enabled",
            "minimalTlsVersion": "TLS1_2",
            "infrastructureEncryption": "Enabled",
            "publicNetworkAccess": "Disabled",
            "storageProfile": {
              "backupRetentionDays": 90,
              "geoRedundantBackup": "Enabled",
              "storageMB": 50,
              "storageAutogrow": "Enabled"
            },
            "createMode": "Replica",
            "sourceServerId": "sample_id"
          },
          "location": "string",
          "tags": {},
          "resources": [
            {
              "name": "sample_config",
              "type": "configurations",
              "apiVersion": "2017-12-01",
              "properties": {
                "value": "Off"
              }
            }
          ]
        }
      ],
      "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": "1.0.0.0",
  "parameters": {},
  "functions": [],
  "variables": {},
  "resources": [
    {
      "name": "servers1",
      "type": "Microsoft.DBforPostgreSQL/servers",
      "apiVersion": "2017-12-01",
      "identity": {
        "type": "SystemAssigned"
      },
      "sku": {
        "name": "B_Gen4_1",
        "tier": "Basic",
        "capacity": 500,
        "size": "500MB",
        "family": "family"
      },
      "properties": {
        "version": "11",
        "sslEnforcement": "Enabled",
        "minimalTlsVersion": "TLS1_2",
        "infrastructureEncryption": "Enabled",
        "publicNetworkAccess": "Disabled",
        "storageProfile": {
          "backupRetentionDays": 90,
          "geoRedundantBackup": "Enabled",
          "storageMB": 50,
          "storageAutogrow": "Enabled"
        },
        "createMode": "Replica",
        "sourceServerId": "sample_id"
      },
      "location": "string",
      "tags": {},
      "resources": [
        {
          "name": "connection_throttling",
          "type": "configurations",
          "apiVersion": "2017-12-01",
          "properties": {
            "value": "On"
          }
        }
      ]
    }
  ],
  "outputs": {}
}
Negative test num. 2 - json file
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {},
  "functions": [],
  "variables": {},
  "resources": [
    {
      "name": "servers1",
      "type": "Microsoft.DBforPostgreSQL/servers",
      "apiVersion": "2017-12-01",
      "identity": {
        "type": "SystemAssigned"
      },
      "sku": {
        "name": "B_Gen4_1",
        "tier": "Basic",
        "capacity": 500,
        "size": "500MB",
        "family": "family"
      },
      "properties": {
        "version": "11",
        "sslEnforcement": "Enabled",
        "minimalTlsVersion": "TLS1_2",
        "infrastructureEncryption": "Enabled",
        "publicNetworkAccess": "Disabled",
        "storageProfile": {
          "backupRetentionDays": 90,
          "geoRedundantBackup": "Enabled",
          "storageMB": 50,
          "storageAutogrow": "Enabled"
        },
        "createMode": "Replica",
        "sourceServerId": "sample_id"
      },
      "location": "string",
      "tags": {}
    },
    {
      "name": "servers1/connection_throttling",
      "type": "Microsoft.DBforPostgreSQL/servers/configurations",
      "apiVersion": "2017-12-01",
      "properties": {
        "value": "On"
      }
    }
  ],
  "outputs": {}
}
Negative test num. 3 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {},
      "functions": [],
      "variables": {},
      "resources": [
        {
          "name": "servers1",
          "type": "Microsoft.DBforPostgreSQL/servers",
          "apiVersion": "2017-12-01",
          "identity": {
            "type": "SystemAssigned"
          },
          "sku": {
            "name": "B_Gen4_1",
            "tier": "Basic",
            "capacity": 500,
            "size": "500MB",
            "family": "family"
          },
          "properties": {
            "version": "11",
            "sslEnforcement": "Enabled",
            "minimalTlsVersion": "TLS1_2",
            "infrastructureEncryption": "Enabled",
            "publicNetworkAccess": "Disabled",
            "storageProfile": {
              "backupRetentionDays": 90,
              "geoRedundantBackup": "Enabled",
              "storageMB": 50,
              "storageAutogrow": "Enabled"
            },
            "createMode": "Replica",
            "sourceServerId": "sample_id"
          },
          "location": "string",
          "tags": {},
          "resources": [
            {
              "name": "connection_throttling",
              "type": "configurations",
              "apiVersion": "2017-12-01",
              "properties": {
                "value": "On"
              }
            }
          ]
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}

Negative test num. 4 - json file
{
  "properties": {
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {},
      "functions": [],
      "variables": {},
      "resources": [
        {
          "name": "servers1",
          "type": "Microsoft.DBforPostgreSQL/servers",
          "apiVersion": "2017-12-01",
          "identity": {
            "type": "SystemAssigned"
          },
          "sku": {
            "name": "B_Gen4_1",
            "tier": "Basic",
            "capacity": 500,
            "size": "500MB",
            "family": "family"
          },
          "properties": {
            "version": "11",
            "sslEnforcement": "Enabled",
            "minimalTlsVersion": "TLS1_2",
            "infrastructureEncryption": "Enabled",
            "publicNetworkAccess": "Disabled",
            "storageProfile": {
              "backupRetentionDays": 90,
              "geoRedundantBackup": "Enabled",
              "storageMB": 50,
              "storageAutogrow": "Enabled"
            },
            "createMode": "Replica",
            "sourceServerId": "sample_id"
          },
          "location": "string",
          "tags": {}
        },
        {
          "name": "servers1/connection_throttling",
          "type": "Microsoft.DBforPostgreSQL/servers/configurations",
          "apiVersion": "2017-12-01",
          "properties": {
            "value": "On"
          }
        }
      ],
      "outputs": {}
    },
    "parameters": {}
  },
  "kind": "template",
  "type": "Microsoft.Blueprint/blueprints/artifacts",
  "name": "myTemplate"
}