Azure database firewall rule specifies the full IPv4 range

Restrict public database connections to required sources and review authentication, permissions, and private connectivity together.

Description

A public database firewall rule from 0.0.0.0 to 255.255.255.255 admits every IPv4 source. In Azure SQL Database, using 0.0.0.0 at both ends grants a separate Azure-services exception that can include other customers’ resources. Check exceptions in the documentation for your database service.

Potential impact

Unapproved clients can attempt to sign in. Data access still requires authentication and permissions, so leaked credentials and excessive privileges increase the risk.

Remediation

Allow only the public source addresses Azure sees after NAT. For Azure SQL, review both server and database rules. If only private access is needed, test the private path and DNS before disabling public access. After applying the changes, verify that approved clients connect, unwanted sources are blocked and database users have only the permissions they need.

Examples

These AzureRM v4.50.0 excerpts require azurerm_mssql_server.example. When migrating from azurerm_sql_firewall_rule, review state and the plan for the resource type and address changes.

Before

hcl
resource "azurerm_mssql_firewall_rule" "public_firewall_rule" {
  name                = "FirewallRule1"
  server_id           = azurerm_mssql_server.example.id
  start_ip_address    = "0.0.0.0"
  end_ip_address      = "255.255.255.255"
}

After

hcl
resource "azurerm_mssql_firewall_rule" "public_firewall_rule" {
  name                = "FirewallRule1"
  server_id           = azurerm_mssql_server.example.id
  start_ip_address    = "203.0.113.10"
  end_ip_address      = "203.0.113.10"
}

Explanation:

  • Before: The rule has no IPv4 source restriction on a public path.
  • After: Replace the example address 203.0.113.10 with the approved client’s public source address. Other rules can still grant access.

References