Description
A public database firewall should allow the source addresses the service sees for approved applications and administrators. In Azure SQL Database, setting both ends to 0.0.0.0 grants an exception to Azure resources, including those in other customers’ subscriptions. Other services can interpret exceptions differently.
Potential impact
An unnecessary public rule lets more clients attempt sign-in. Leaked credentials or excessive database permissions can then expose data.
Remediation
Check the combined firewall rules, including Azure-service exceptions. Remove unneeded ranges and use the approved clients’ post-NAT addresses. Splitting a range preserves its coverage. For private-only access, test DNS and client connectivity before disabling public access. Verify the expected connections and denials, and apply least-privilege database permissions.
Examples
These AzureRM v4.50.0 excerpts require azurerm_mssql_server.example and real client addresses. When migrating the rule from an older resource type, check Terraform state and the plan before applying.
Before
resource "azurerm_mssql_firewall_rule" "wide_firewall_rule" {
name = "FirewallRule1"
server_id = azurerm_mssql_server.example.id
start_ip_address = "203.0.113.0"
end_ip_address = "203.0.113.255"
}
After
resource "azurerm_mssql_firewall_rule" "wide_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 covers all 256 addresses from
203.0.113.0through203.0.113.255. - After: Matching start and end addresses allow only
203.0.113.10through this rule.