name:Azure PostgreSQL Access From Azure Services Disabled
author:princechaddha
severity:high
description:|
Ensure that the access from Microsoft Azure cloud services to Azure Database for PostgreSQL servers is disabled in order to secure access to PostgreSQL databases by allowing access from trusted Virtual Networks (Vnets) only.
impact:|
Not restricting access to Azure Database for PostgreSQL servers from Azure services can expose sensitive database resources to potentially malicious traffic from within Azure, increasing the risk of breaches and data exposure.
remediation:|
Configure firewall rules to disable the "Allow access to Azure services" setting for Azure PostgreSQL Database servers to restrict access to trusted sources only.
for (let ServerData of iterate(template.serverList)) {
ServerData = JSON.parse(ServerData);
set("name", ServerData.name);
set("resourceGroup", ServerData.resourceGroup);
code(2);
}
self-contained:true
code:
- engine:
- sh
- bash
source:|
az postgres server list --output json --query '[*].{"name":name,"resourceGroup":resourceGroup}'
extractors:
- type:json
name:serverList
internal:true
json:
- '.[]'
- engine:
- sh
- bash
source:|
az postgres server firewall-rule list --server "$name" --resource-group "$resourceGroup" --query '[*].{"ruleName":name,"startIpAddress":startIpAddress,"endIpAddress":endIpAddress}'
matchers:
- type:word
words:
- '"ruleName": "AllowAllWindowsAzureIps"'
- 'startIpAddress": "0.0.0.0"'
- '"endIpAddress": "0.0.0.0"'
condition:and
extractors:
- type:dsl
dsl:
- 'name + " in " + resourceGroup + " allows access to Azure services"'