Over-permissive SQL firewall rules
An Azure SQL logical server blocks public access by default, so every server-level firewall rule you add widens who can reach the databases on it. Rules that cover all Azure services or very wide address ranges are the ones to review first.
Why it matters
Per Microsoft, a new Azure SQL logical server's firewall blocks all access to its public endpoint, and server-level IP rules apply to every database on that server, which reduces the depth of your defenses compared with database-level rules. The special rule from 0.0.0.0 to 0.0.0.0 (named AllowAllWindowsAzureIps when switched on in the portal) allows connections from all Azure services, including services running in other customers' subscriptions, and does not restrict access to your subscription or resource group. Microsoft suggests virtual network service endpoints or private endpoints as more restrictive alternatives. (Microsoft Learn: IP firewall rules for Azure SQL Database)
Find it yourself
This Azure CLI script is read-only: it only runs list commands and changes nothing. It needs Reader access on the subscription. It prints every server-level rule that starts at 0.0.0.0, which includes the allow-Azure-services rule and any range that begins at the very bottom of the address space.
for sub in $(az account list --query "[].id" -o tsv); do
az account set --subscription "$sub"
az sql server list --query "[].{n:name, rg:resourceGroup}" -o tsv |
while read -r server rg; do
az sql server firewall-rule list --server "$server" --resource-group "$rg" \
--query "[?startIpAddress=='0.0.0.0'].{server:'$server', rule:name, start:startIpAddress, end:endIpAddress}" -o table
done
doneTo see every rule instead, drop the filter. (Microsoft Learn: az sql server firewall-rule list)
Read the result
A row with start and end both 0.0.0.0 is the allow-Azure-services rule: any Azure resource with outbound connectivity to SQL Database can attempt a connection, so only logins and permissions stand between it and your data. A row whose end address is far above its start, for example reaching the top of the address space, opens the server to far more than one office or one application. Rules with a narrow range that matches a known client are normal. Remember that a rule only lets a client try to connect; it must still authenticate.
What to do next
For each flagged rule, find out which application or person depends on it. Replace the allow-Azure-services rule with virtual network service endpoints or private endpoints where the callers allow it, and replace wide ranges with the specific addresses that need access. Where users of one database should be isolated from another, Microsoft recommends database-level rules, which can be managed with Transact-SQL. Firewall changes can take up to five minutes to apply, so test the dependent application after each change. You can audit firewall changes with Auditing for Azure SQL Database. (Microsoft Learn)
See it on every scan
ConfigCobra's Inventory & Insights keeps one inventory across clouds, with a per-cloud and an "All clouds" view, and "Over-permissive SQL firewall rules" is one of its built-in risk views. On Azure, the Inventory lists resources across subscriptions with their security properties, and an over-permissive SQL firewall is one of them. Findings are linked to the inventory objects they concern, the relation graph shows how objects connect, and the list can be exported as CSV. Scheduled scans (daily, weekly or monthly) and drift detection alert you when a control regresses; ConfigCobra is read-only and never changes your environment.
Go further
- Inventory & InsightsEvery user, app, device and resource in one inventory, with built-in risk views
- Identity & Access GovernanceFind inactive users, guests, admins and risky apps
- Microsoft Azure4 CIS Azure benchmarks · 339 controls · read-only
- Azure resources with public network accessMicrosoft Azure insight
- Azure resources below the minimum TLS versionMicrosoft Azure insight
- Key Vault secrets and keys without expiryMicrosoft Azure insight
- Unattached disksMicrosoft Azure insight
See it for your whole tenant, continuously
Inventory & Insights lists these risks with built-in views and CSV export, read-only.