Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “SQL Database Servers Should Not Have Unrestricted Access” in AZURE using AZURE console, follow these steps:
- Log in to the Azure portal.
- Navigate to the SQL database server that has unrestricted access.
- Click on the “Firewalls and virtual networks” option under the “Security” section in the left-hand menu.
- Under the “Firewall rules” section, click on the “Add client IP” button to add your IP address to the allowed list.
- If you want to allow access to specific IP addresses or ranges, click on the “Add IP range” button and enter the appropriate information.
- Click on the “Save” button to apply the changes.
Using CLI
Using CLI
To remediate the misconfiguration “SQL Database Servers Should Not Have Unrestricted Access” in Azure using Azure CLI, follow these steps:
- Open the Azure CLI and login to your Azure account.
- Identify the SQL Database Server that has unrestricted access by running the following command:
This will list all the SQL Database Servers in your Azure account.
- Once you have identified the SQL Database Server, run the following command to update the firewall rules:
This command will update the firewall rule named “AllowAllWindowsAzureIps” to restrict access to the SQL Database Server to only Azure services and resources.
- Verify that the firewall rule has been updated by running the following command:
This command will show the details of the updated firewall rule.
Using Python
Using Python
To remediate the misconfiguration “SQL Database Servers Should Not Have Unrestricted Access” in Azure using Python, you can use the following steps:These steps will remediate the misconfiguration “SQL Database Servers Should Not Have Unrestricted Access” in Azure using Python.
- Import the necessary libraries and authenticate to Azure using the Azure SDK for Python.
- Retrieve the list of SQL servers in your subscription.
- For each SQL server, check if it has any firewall rules that allow unrestricted access.
- Once all the firewall rules have been deleted, you can verify that the SQL servers no longer have unrestricted access.
Using Terraform
Using Terraform
azurerm_mssql_firewall_rule with start_ip_address = "0.0.0.0" and end_ip_address = "255.255.255.255", remove that resource (or change it to a restricted range as above); Terraform will plan to destroy or update only that firewall rule, not the server. Changing public_network_access_enabled does not force replacement of the SQL server.For verification, terraform plan should show:- Either an update to
azurerm_mssql_server.sql_serversettingpublic_network_access_enabledfromtruetofalse, and/or - A destroy or change of any firewall rule that previously allowed
0.0.0.0–255.255.255.255, replaced by one or more rules with specific IP ranges.

