PostgreSQL Database Server Connection Throttling Disabled
- Query id: a6d774b6-d9ea-4bf4-8433-217bf15d2fb8
- Query name: PostgreSQL Database Server Connection Throttling Disabled
- Platform: AzureResourceManager
- Severity: Medium
- Category: Networking and Firewall
- CWE: 770
- 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 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
resource servers1_connection_throttling 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: servers1
name: 'connection_throttling'
properties: {
value: 'Off'
}
}
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": [
{
"name": "connection_throttling",
"type": "configurations",
"apiVersion": "2017-12-01",
"properties": {
"value": "Off"
}
}
]
}
],
"outputs": {}
}
Positive test num. 3 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
Positive test num. 4 - 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. 5 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
resource servers1_sample_config 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: servers1
name: 'sample_config'
properties: {
value: 'Off'
}
}
Positive test num. 6 - 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. 7 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
resource servers1_connection_throttling 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: servers1
name: 'connection_throttling'
properties: {
value: 'Off'
}
}
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",
"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. 9 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
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",
"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. 11 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
resource servers1_sample_config 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: servers1
name: 'sample_config'
properties: {
value: 'Off'
}
}
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",
"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 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
resource servers1_connection_throttling 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: servers1
name: 'connection_throttling'
properties: {
value: 'On'
}
}
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": {},
"resources": [
{
"name": "connection_throttling",
"type": "configurations",
"apiVersion": "2017-12-01",
"properties": {
"value": "On"
}
}
]
}
],
"outputs": {}
}
Negative test num. 3 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
resource servers1_connection_throttling 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: servers1
name: 'connection_throttling'
properties: {
value: 'On'
}
}
Negative test num. 4 - 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. 5 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
resource servers1_connection_throttling 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: servers1
name: 'connection_throttling'
properties: {
value: 'On'
}
}
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",
"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. 7 - bicep file
resource servers1 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
name: 'servers1'
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: {}
}
resource servers1_connection_throttling 'Microsoft.DBforPostgreSQL/servers/configurations@2017-12-01' = {
parent: servers1
name: 'connection_throttling'
properties: {
value: 'On'
}
}
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",
"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"
}