More Info:
Ensure that all your Microsoft Azure network security groups (NSGs) restrict inbound/ingress access on TCP port 1433 to trusted IP addresses only in order to implement the principle of least privilege and significantly reduce the attack surface. TCP port 1433 is used by Microsoft Azure SQL Server, the relational database management system developed by Microsoft.Risk Level
HighAddress
SecurityCompliance Standards
SOC2, GDPR, HIPAA, NISTCSF, PCIDSS, FedRAMPTriage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the unrestricted MSSQL Server Access misconfiguration in AZURE, please follow the below steps:
- Open the Azure Portal and login with your credentials.
- Navigate to the Azure SQL Server that you want to remediate.
- Click on “Firewalls and virtual networks” under the “Security” section in the left-hand menu.
- Ensure that the “Allow Azure services and resources to access this server” option is turned off.
- Under the “Firewall rules” section, click on “Add client IP”.
- Enter the IP address of the client that needs to access the SQL server.
- Click on “Save” to apply the changes.
- Repeat steps 5-7 for all the clients that require access to the SQL server.
- Once you have added all the required client IP addresses, turn on the “Allow Azure services and resources to access this server” option.
- Click on “Save” to apply the changes.
Using CLI
Using CLI
To remediate unrestricted MSSQL Server access in Azure using Azure CLI, you can follow the below steps:Step 1: Login to Azure CLIStep 2: Get the resource group name and MSSQL server name where the misconfiguration is presentStep 3: Set the resource group and server name variablesStep 4: Get the firewall rules for the MSSQL serverStep 5: Identify the unrestricted firewall rule that allows all IP addresses to access the MSSQL serverStep 6: Delete the unrestricted firewall ruleStep 7: Create a new firewall rule that allows only specific IP addresses to access the MSSQL serverNote: Replace the placeholders
<resource-group-name>
, <mssql-server-name>
, <firewall-rule-name>
, <start-ip-address>
and <end-ip-address>
with the actual values.Using Python
Using Python
To remediate the unrestricted MSSQL Server Access misconfiguration in AZURE using python, follow the below steps:Step 1: Import the required librariesStep 2: Set the credentials and subscription IDStep 3: Create the SQL Management clientStep 4: Get the list of MSSQL servers in the subscriptionStep 5: For each server, check if the firewall rules allow unrestricted access and remove themStep 6: Run the python script to remediate the unrestricted MSSQL Server Access misconfiguration in AZURE.Note: The above code will remove all the firewall rules that allow unrestricted access to the MSSQL server. It is recommended to review the firewall rules before removing them to ensure that no legitimate access is blocked.